Skip to content

Instantly share code, notes, and snippets.

@davo
Created June 4, 2018 14:30
Show Gist options
  • Save davo/58f66e77cf238b26af603cd66babc0fd to your computer and use it in GitHub Desktop.
Save davo/58f66e77cf238b26af603cd66babc0fd to your computer and use it in GitHub Desktop.
Debugging with Coffeescript
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
@davo
Copy link
Author

davo commented Jun 4, 2018

Usage:

console.log getInstanceMethodNames(Framer.Device)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment