File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ // This UMD allows extend an existing module or library in the browser,
2+ // instead of overwriting it. It is useful for libraries that serves
3+ // as a shared namespace.
4+
5+ ( function umd ( root , factory ) {
6+ if ( typeof exports === 'object' && typeof module === 'object' )
7+ // Node. CommonJs2 environments that support module.exports.
8+ module . exports = factory ( ) ;
9+ else if ( typeof define === 'function' && define . amd )
10+ // AMD. Register as an anonymous module.
11+ define ( [ ] , factory ) ;
12+ else if ( typeof exports === 'object' )
13+ // CommonJs
14+ exports . myLib = factory ( ) ;
15+ else {
16+ // Browser. Allow Module Augmentation (root is window)
17+ var ts = Object . prototype . toString ,
18+ obj = '[object Object]' ,
19+ myLib = factory ( ) ;
20+ if ( ts . call ( root . myLib ) === obj && ts . call ( myLib ) === obj ) {
21+ for ( var p in myLib ) root . myLib [ p ] = myLib [ p ] ;
22+ // not used Object.assign(a,b) for compatibility
23+ } else root . myLib = myLib ;
24+ }
25+ } ( this , function ( ) {
26+
27+ // Just return a value to define the module export.
28+ // This example returns an object, but the module
29+ // can return a function as the exported value.
30+ return { } ;
31+ } ) ) ;
You can’t perform that action at this time.
0 commit comments