emit.js 433 B

123456789101112131415161718
  1. (function emit (event) {
  2. if (! (event instanceof Function)) {
  3. console.error("won't be able to emit", event, "(not a function)")
  4. return function () {
  5. console.error("can't emit", event, "(not a function)");
  6. }
  7. }
  8. var args1 = Array.prototype.slice.call(arguments, 1);
  9. return function emitEvent () {
  10. var args2 = Array.prototype.slice.call(arguments, 0);
  11. event.apply(null, args1.concat(args2));
  12. }
  13. })