Skip to content

Instantly share code, notes, and snippets.

@diegodfsd
Forked from marcric/howto.js
Created November 6, 2011 02:51
Show Gist options
  • Save diegodfsd/1342388 to your computer and use it in GitHub Desktop.
Save diegodfsd/1342388 to your computer and use it in GitHub Desktop.
cumulative export example
// node.js exercise
function privateSay(message) {
console.log("private: ", message);
};
function say(message) {
console.log("public: ", message);
};
function User(name) {
this.name = name;
};
function create(name) {
count += 1;
return new User(name);
};
function count() {
var accumulated = 0;
return function(){
accumulated += 1;
return accumulated;
};
};
// from now on I decide what to export
exports.say = say;
exports.User = User;
exports.create = create;
exports.count = count;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment