Skip to content

Instantly share code, notes, and snippets.

@boombang
Last active April 6, 2019 16:51
Show Gist options
  • Save boombang/2b4e446e9a6c542ba326f47cc82eea95 to your computer and use it in GitHub Desktop.
Save boombang/2b4e446e9a6c542ba326f47cc82eea95 to your computer and use it in GitHub Desktop.
//my-module.js
var privateVar = "Ben Cherry";
var publicVar = "Hey there!";
function privateFunction() {
console.log( "Name:" + privateVar );
}
function publicSetName( strName ) {
privateVar = strName;
}
function publicGetName() {
privateFunction();
}
module.exposts = {
setName: publicSetName,
greeting: publicVar,
getName: publicGetName
}
// index.js
const myModule = require('my-module');
myModule.setName( "Paul Kinlan" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment