bind-actor.js 382 B

12345678910111213141516
  1. module.exports = bindActor
  2. function bindActor () {
  3. var args =
  4. Array.prototype.slice.call
  5. (arguments) // jswtf.
  6. , obj = null
  7. , fn
  8. if (typeof args[0] === "object") {
  9. obj = args.shift()
  10. fn = args.shift()
  11. if (typeof fn === "string")
  12. fn = obj[ fn ]
  13. } else fn = args.shift()
  14. return function (cb) {
  15. fn.apply(obj, args.concat(cb)) }
  16. }