-
-
Save aguilarcarlos/22060edef679dafae2275f30771f500c to your computer and use it in GitHub Desktop.
Revisions
-
CrocoDillon revised this gist
Apr 15, 2014 . 3 changed files with 59 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ /* * Inspiration from: * https://github.com/jquery/jquery/blob/master/src/intro.js * * Thanks jQuery! * * This is another way to handle dependencies (in this case, a window with a document) */ (function( global, factory ) { if ( typeof module === "object" && typeof module.exports === "object" ) { // For CommonJS and CommonJS-like environments where a proper window is present, // execute the factory and get jQuery // For environments that do not inherently posses a window with a document // (such as Node.js), expose a jQuery-making factory as module.exports module.exports = global.document ? factory( global, true ) : function( w ) { if ( !w.document ) { throw new Error( "jQuery requires a window with a document" ); } return factory( w ); }; } else { factory( global ); } // Pass this if window is not defined yet }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) { // Awesome module gets created here })); This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ /* * Inspiration from: * https://github.com/addyosmani/memoize.js/blob/master/memoize.js * * Thanks Addy! */ (function (root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define([], factory); } else if (typeof exports === 'object') { // Node. Does not work with strict CommonJS, but // only CommonJS-like environments that support module.exports, // like Node. module.exports = factory(); } else { // Browser globals (root is window) root.memoize = factory(); } }(this, function() { "use strict"; var memoize = function(func) { /* Your awesome module logic here */ }; return memoize; })); -
CrocoDillon created this gist
Apr 5, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ /* * Inspiration (well… copy pasting more or less) from: * https://github.com/ScottHamper/Cookies/blob/0.3.1/src/cookies.js#L127-L140 * * Thanks Scott! */ (function (global) { 'use strict'; var MyModule = function () { /* Your awesome module logic here… */ }; /* …and here */ MyModule.foo = 'bar'; // AMD support if (typeof define === 'function' && define.amd) { define(function () { return MyModule; }); // CommonJS and Node.js module support. } else if (typeof exports !== 'undefined') { // Support Node.js specific `module.exports` (which can be a function) if (typeof module !== 'undefined' && module.exports) { exports = module.exports = MyModule; } // But always support CommonJS module 1.1.1 spec (`exports` cannot be a function) exports.MyModule = MyModule; } else { global.MyModule = MyModule; } })(this);