Skip to content

Instantly share code, notes, and snippets.

@czkimura
Created May 30, 2016 13:16
Show Gist options
  • Save czkimura/f5122a15468dc436c7a1a65828b66281 to your computer and use it in GitHub Desktop.
Save czkimura/f5122a15468dc436c7a1a65828b66281 to your computer and use it in GitHub Desktop.
getterが定義されているプロパティだけを列挙したかった
'use strict';
const isFunction = (any) => {
const str = Object.prototype.toString.call(any);
return /^\[object (Generator)?Function\]$/.test(str);
}
const listupGetter = (obj) => {
const proto = Object.getPrototypeOf(obj);
return Object.getOwnPropertyNames(proto).filter((v) => {
const descriptor = Object.getOwnPropertyDescriptor(proto, v);
return isFunction(descriptor.get);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment