Created
February 10, 2014 19:29
-
-
Save weotch/8922504 to your computer and use it in GitHub Desktop.
Example of implementing UMD spec
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 characters
// Based on https://github.com/umdjs/umd/blob/master/returnExports.js | |
(function (root, factory) { | |
// AMD | |
if (typeof define === 'function' && define.amd) { | |
define([ | |
'jquery' | |
, 'lodash' | |
], factory); | |
// CJS | |
} else if (typeof exports === 'object') { | |
module.exports = factory( | |
require('jquery') | |
, require('lodash') | |
); | |
// Window global | |
} else { | |
root.share = factory( | |
root.jquery | |
, root.lodash | |
); | |
} | |
}(this, function ($, _) { | |
// Return public API | |
return {}; | |
})); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment