Created
June 4, 2018 14:30
-
-
Save davo/58f66e77cf238b26af603cd66babc0fd to your computer and use it in GitHub Desktop.
Debugging with Coffeescript
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
hasMethod = (obj, name) -> | |
desc = Object.getOwnPropertyDescriptor(obj, name) | |
! !desc and typeof desc.value == 'function' | |
getInstanceMethodNames = (obj, stop) -> | |
array = [] | |
proto = Object.getPrototypeOf(obj) | |
while proto and proto != stop | |
Object.getOwnPropertyNames(proto).forEach (name) -> | |
if name != 'constructor' | |
if hasMethod(proto, name) | |
array.push name | |
return | |
proto = Object.getPrototypeOf(proto) | |
array | |
getOwnMethods = (obj) -> | |
props = Object.getOwnPropertyNames(obj) | |
props.filter (prop) -> | |
obj[prop] and obj[prop].constructor and obj[prop].call and obj[prop].apply |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: