Created
March 17, 2019 18:55
-
-
Save bgaze/119ac958d16523c02c5711bc60258ea6 to your computer and use it in GitHub Desktop.
Javascript Universal Module Definition pattern
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 (root, factory) { | |
if (typeof define === "function" && define.amd) { | |
define(["jquery"], function (jQuery) { | |
return (root.myfn = factory(jQuery)); | |
}); | |
} else if (typeof module === "object" && module.exports) { | |
module.exports = (root.myfn = factory(require("jquery"))); | |
} else { | |
root.myfn = factory(root.jQuery); | |
} | |
}(this, function ($) { | |
function myfn() { | |
// ... | |
} | |
return myfn; | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment