Skip to content

Instantly share code, notes, and snippets.

@alejandro
Forked from jfhbrook/inherits.js
Created November 9, 2011 04:36
Show Gist options
  • Select an option

  • Save alejandro/1350401 to your computer and use it in GitHub Desktop.

Select an option

Save alejandro/1350401 to your computer and use it in GitHub Desktop.
Am I the only one that finds this more readable?
var util = require("util");
var inherits = function (inherits, fn) {
util.inherits(fn, inherits);
return fn;
}
josh@onix:/tmp/inherits$ node
> var inherits = require("./inherits");
> var EE = require("events").EventEmitter;
>
> var FooBar = inherits(EE, function () {
... this.on("foo", function () {
... console.log("bar");
... });
... });
>
> var foobar = new FooBar;
>
> foobar.emit("foo");
bar
true
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment