Created
May 30, 2016 13:16
-
-
Save czkimura/f5122a15468dc436c7a1a65828b66281 to your computer and use it in GitHub Desktop.
getterが定義されているプロパティだけを列挙したかった
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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