Skip to content

Instantly share code, notes, and snippets.

@gs-ysingh
Created June 29, 2015 19:18
Show Gist options
  • Save gs-ysingh/e5c368bd506676fdc13e to your computer and use it in GitHub Desktop.
Save gs-ysingh/e5c368bd506676fdc13e to your computer and use it in GitHub Desktop.
//index.js
var Project = function() {
this.info = {};
this.setValues = function(info) {
for(var prop in info) {
if(this.info[prop] !== 'undefined') {
this.info[prop] = info[prop];
}
}
};
this.getInfo = function () {
return this.info;
};
}
module.exports = function (info, type) {
//if(type == "Project") {
var instance = new Project();
//}
//else if(type == "Other") {}
instance.setValues(info);
return instance;
}
//app.js
var Project = require('./Project');
var webApp = Project({
name: 'Twitter',
members: 3,
startDate: 2015
});
var mobileApp = Project({
name: 'Facebook',
members: 5,
startDate: 2016
});
console.log(webApp.getInfo());
console.log(mobileApp.getInfo());
console.log(webApp.getInfo());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment