Skip to content

Instantly share code, notes, and snippets.

@mzdv
Created February 13, 2015 22:00
Show Gist options
  • Save mzdv/1a6305113835c035e1ca to your computer and use it in GitHub Desktop.
Save mzdv/1a6305113835c035e1ca to your computer and use it in GitHub Desktop.
Something I whipped up.
var events = require("events");
var util = require("util");
var _ = require("lodash");
var Greeter = function() {
events.EventEmitter.call(this);
console.log("I greet you");
};
util.inherits(Greeter, events.EventEmitter);
_.forEach(["hello", "moreHello", "mostHello"], function(n) {
Greeter.prototype[n] = function() {
this.emit(n)
}
});
var butler = new Greeter();
_.forEach(["hello", "moreHello", "mostHello"], function(n) {
butler.on(n, function () {
console.log(n);
});
});
_.forEach([butler.hello(), butler.moreHello(), butler.mostHello()]); // FUNCTIONAL PROGRAMMING AWWWW YISS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment