Open millermedeiros opened 13 years ago
avoid generating globals if not needed and help to easily share code between environments.
here is a sample of a wrapper that would run "everywhere":
(function(def){ def('jlink', function(){ //jlinq code should go here return jlinq; }); }( // wrapper to run code everywhere // based on http://bit.ly/c7U4h5 typeof require === 'undefined'? //Browser (regular script tag) function(name, factory){ this[name] = factory(); } : ((typeof exports === 'undefined')? //AMD function(name, factory){ define(name, [], factory); } : //CommonJS function(name, factory){ module.exports = factory(); } ) ));
wrapping the code like this would make it work on node.js, and to be loaded properly by AMD loaders like RequireJS, Dojo (v1.6+), curl.js, etc..
avoid generating globals if not needed and help to easily share code between environments.
here is a sample of a wrapper that would run "everywhere":
wrapping the code like this would make it work on node.js, and to be loaded properly by AMD loaders like RequireJS, Dojo (v1.6+), curl.js, etc..