Skip to content

Instantly share code, notes, and snippets.

@aguilarcarlos
Forked from CrocoDillon/cookies.js
Created August 14, 2017 20:12
Show Gist options
  • Select an option

  • Save aguilarcarlos/22060edef679dafae2275f30771f500c to your computer and use it in GitHub Desktop.

Select an option

Save aguilarcarlos/22060edef679dafae2275f30771f500c to your computer and use it in GitHub Desktop.

Revisions

  1. @CrocoDillon CrocoDillon revised this gist Apr 15, 2014. 3 changed files with 59 additions and 0 deletions.
    File renamed without changes.
    31 changes: 31 additions & 0 deletions jQuery.js
    Original 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
    }));
    28 changes: 28 additions & 0 deletions memoize.js
    Original 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;
    }));
  2. @CrocoDillon CrocoDillon created this gist Apr 5, 2014.
    31 changes: 31 additions & 0 deletions MyModule.js
    Original 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);