Skip to content

Instantly share code, notes, and snippets.

@dineshsprabu
Last active August 18, 2017 23:54
Show Gist options
  • Save dineshsprabu/2365cae699af8da9c0a2 to your computer and use it in GitHub Desktop.
Save dineshsprabu/2365cae699af8da9c0a2 to your computer and use it in GitHub Desktop.
Export multiple Prototypes from one file in Nodejs
/* protos.js*/
var hey = function(){
}
hey.prototype.sayHey = function(){
console.log('Hey');
}
var bye = function(){
}
bye.prototype.sayBye = function(){
console.log('Bye');
}
module.exports.hey = hey;
module.exports.bye = bye;
/* use.js */
var hey = require('./protos').hey
var bye = require('./protos').bye
hey = new hey();
hey.sayHey();
bye = new bye();
bye.sayBye();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment