Created
May 24, 2023 22:42
-
-
Save ben-ekw/82a117294ece4b55b49766be31927018 to your computer and use it in GitHub Desktop.
Ultimate UMD boilerplate template -- combines returnExports and fid-umd (replace "changeme" with your module name)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (name, root, factory) { | |
if (typeof define === "function" && define.amd) { | |
// AMD | |
define([], factory); | |
} else if (typeof module === "object" && module.exports) { | |
// Node | |
module.exports = factory(); | |
} else if (typeof exports === "object") { | |
// CommonJS | |
exports[name] = factory(); | |
} else if (typeof modulejs === "object") { | |
// modulejs | |
modulejs.define(name, factory); | |
} else if (typeof YUI === "object") { | |
// YUI | |
YUI.add(name, function (Y) { | |
Y[name] = factory(); | |
}); | |
} else { | |
// browser globals | |
root[name] = factory(); | |
} | |
})("changeme", typeof self !== "undefined" ? self : this, function () { | |
"use strict"; | |
// Methods | |
function notHelloOrGoodbye() { | |
return "private"; | |
} | |
function hello() { | |
return "hello"; | |
} | |
function goodbye() { | |
return "goodbye"; | |
} | |
// Expose public methods | |
return { | |
hello: hello, | |
goodbye: goodbye, | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment