Last Updated: February 25, 2016
·
655
· voqn

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