Skip to content

Instantly share code, notes, and snippets.

@yvesvanbroekhoven
Created December 3, 2013 10:08
Show Gist options
  • Save yvesvanbroekhoven/7766911 to your computer and use it in GitHub Desktop.
Save yvesvanbroekhoven/7766911 to your computer and use it in GitHub Desktop.
How can I use CommonJS modules to extend eachother or create inheritance? (This is pseudo code)
var ModuleA = require('module-a');
function ModuleAExt() {
ModuleA.prototype.change_name = function(name) {
this.name = name;
};
return ModuleA;
}
module.exports = ModuleAExt;
function ModuleA() {
this.name = "module-a";
}
module.exports = ModuleA;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment