Intro-code of Js library for Web and Node.js
write introduction to avail javascript library with both Browser and Node.js
;(funciton(root) {
var myLib = {}, oldMyLib = root.myLib, deps;
if (typeof module !== 'object' &&
typeof require === 'function') { // on node.js
module.exports = myLib;
deps = require('deps');
} else { // on browser
root.myLib = myLib;
deps = root.dep;
}
// for avoid conflicts with same name object
myLib.noConflict = function() {
root.myLib = oldMyLib;
return myLib;
};
// ... write your library API definition ...
})(this); // "this" is global object
Written by VoQn
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Nodejs
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#