Skip to content

Instantly share code, notes, and snippets.

@jywarren
Last active Nov 13, 2020
Embed
What would you like to do?
Template for simple JS library
module.exports = myLibrary = function constructor(o) {
let privateMethod = require('./privateMethod.js')({}); // we can pass in an object full of options
let publicMethod = o.publicMethod || require('./publicMethod.js'); // allow methods to be overridden via options object
let publicApi = {
element: el, // the HTML element into which the library is inserted, if any
publicMethod: o.publicMethod, // here we expose any public methods we want
options: o // options can be exposed too
};
return publicApi;
}
module.exports = function privateMethod(options) {
}
module.exports = function publicMethod(options) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment