Skip to content

Instantly share code, notes, and snippets.

@juanbrujo
Last active February 11, 2024 23:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanbrujo/5949f55ae4593d1ba334 to your computer and use it in GitHub Desktop.
Save juanbrujo/5949f55ae4593d1ba334 to your computer and use it in GitHub Desktop.
Starter for a basic NPM module
// moduleName = name of your npm module
var moduleName = (function moduleName() {
"use strict";
// YOUR PRETTY JS CODE THAT WILL CHANGE THE WORLD
// return whatever;
})( this );
if ( typeof module !== "undefined" && module.exports ) {
// export for use in Node
module.exports.moduleName = function ( @params ) {
return moduleName( @params );
};
} else if ( typeof define !== "undefined" && define.amd ) {
// export for use in AMD
define([], function ( @params ) {
return moduleName( @params );
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment