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
// using ES6 Proxy to deal with methods of Promise'd objects. works for me in Edge though not Chrome somehow. | |
let handler = { | |
get: (target, prop) => function() { | |
if(target instanceof Promise) { | |
let args = arguments; | |
return target.then((o) => o[prop].apply(o, args)); | |
} else { | |
let value = target[prop]; | |
return typeof value == 'function' ? value.bind(target) : value; | |
} |
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
# See http://www.traitsjs.org/tutorial.html | |
Trait = require('traits').Trait | |
EnumerableTrait = Trait | |
# the trait requires these properties | |
forEach: Trait.required | |
# the trait provides these properties: | |
map: (fun) -> |