Comparing version 0.2.4 to 0.2.5
@@ -1,2 +0,2 @@ | ||
!function(n){"use strict";function o(o,l,a){function c(c){function d(d,p,s){function y(n,e){return"function"!=typeof s?s:t(n,p,o,s,a,e)}if(s||(s=p,p=null),e()){f("AMD loading",d,c);var g=[s];p&&g.unshift(p),c.annonymous||g.unshift(c.amd_id||d),define.apply(o,g),c.global&&(n.require||n.curl||u("AMD require() not found"))([d],function(n){i(d,n,c)})}else{if("object"==typeof exports)return f("Node loading",d),y(l,function(n){n&&(o.exports=n)});f("Standalone loading",d,c),y(r,function(n){i(d,n,c)})}}return c=c||{},d}return c}function e(){return"function"==typeof define&&define.amd}function t(n,o,e,t,r,i){function u(o){return l[o]||n(o)}var l={require:n,exports:r||{},module:e};o=(o||["require","exports","module"]).map(u);var f=t.apply(e,o);i&&i(f)}function r(o){var e="require_global()",t=o.split("/").pop();f(e,"name:",t);var r=a[t]||n[t];return r||f(e,"module not yet available name:",t),r}function i(o,e,t){var r="register()",i=t.global;if(f(r,o,e,t),a[o]&&u(r+" allready loaded: "+o),a[o]=e||{},e&&i){if(o="string"==typeof i?i:o,t.no_conflict){var l=n[o];e.no_conflict=function(){return n[o]=l,e}}n[o]=e}}function u(n){throw new Error(l+", "+n)}var l="undefine",f="object"==typeof console&&console.log&&console.log.bind(console,l+":")||function(){},a={};if(e())f("Cooperating with AMD loader, define.amd:",e());else{if("object"==typeof exports)return f("Loaded by node"),module.exports=o;f("Standalone globally"),n.require=function(o,e){e||(e=o,o=null),t(r,o,n,e)}}n[l]=o(n)}(this); | ||
!function(n){"use strict";function o(o,l,c){function d(d){function p(p,s,g){function y(n,e){return"function"!=typeof g?g:t(n,s,o,g,c,e)}if(g||(g=s,s=null),e()){a("AMD loading",p,d);var m=[g];s&&m.unshift(s.map(r)),d.annonymous||m.unshift(d.amd_id||p),define.apply(o,m),d.global&&(n.require||n.curl||f("AMD require() not found"))([p],function(n){u(p,n,d)})}else{if("object"==typeof exports)return a("Node loading",p),y(function(n){return l(r(n))},function(n){n&&(o.exports=n)});a("Standalone loading",p,d),y(i,function(n){u(p,n,d)})}}return d=d||{},p}return d}function e(){return"function"==typeof define&&define.amd}function t(n,o,e,t,r,i){function u(o){return f[o]||n(o)}var f={require:n,exports:r||{},module:e};o=(o||["require","exports","module"]).map(u);var l=t.apply(e,o);i&&i(l)}function r(n){return n.pop?n[d]:n}function i(o){var e="require_global()",t=r(o).split("/").pop();a(e,"name:",t);var i=c[t]||n[t];return i||f(e+" not found: "+t),i}function u(o,e,t){var r="register()",i=t.global;if(a(r,o,e,t),c[o]&&f(r+" allready loaded: "+o),c[o]=e||{},e&&i){if(o="string"==typeof i?i:o,t.no_conflict){var u=n[o];e.no_conflict=function(){return n[o]=u,e}}n[o]=e}}function f(n){throw new Error(l+", "+n)}var l="undefine",a="object"==typeof console&&console.log&&console.log.bind(console,l+":")||function(){},c={},d=0;if(e())a("Cooperating with AMD loader, define.amd:",e());else{if("object"==typeof exports)return a("Loaded by node"),d=1,module.exports=o;a("Standalone globally"),n.require=function(o,e){e||(e=o,o=null),t(i,o,n,e)}}n[l]=o(n)}(this); | ||
//# sourceMappingURL=undefine-min.map |
{ | ||
"name": "undefine", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "Universal Module Loader, for node.js, browser scripts, bundles, and AMD define loaders", | ||
@@ -21,4 +21,6 @@ "main": "undefine.js", | ||
"scripts": { | ||
"build": "cd dist && node ../node_modules/uglify-js/bin/uglifyjs --compress --mangle --output undefine-min.js --source-map undefine-min.map -- ../undefine.js", | ||
"stats": "cd dist && cat undefine-min.js | gzip > undefine-min.js.gz && cat ../undefine.js | gzip > undefine.js.gz && cat undefine-min.map | gzip > undefine-min.map.gz && wc ../undefine.js * | grep -v total && rm *.gz" | ||
"postinstall": "ln -s ../. node_modules/undefine || true", | ||
"test" : "node test/for_node", | ||
"build" : "cd dist && node ../node_modules/uglify-js/bin/uglifyjs --compress --mangle --output undefine-min.js --source-map undefine-min.map -- ../undefine.js", | ||
"stats" : "cd dist && cat undefine-min.js | gzip > undefine-min.js.gz && cat ../undefine.js | gzip > undefine.js.gz && cat undefine-min.map | gzip > undefine-min.map.gz && wc ../undefine.js * | grep -v total && rm *.gz" | ||
}, | ||
@@ -25,0 +27,0 @@ "repository": { |
@@ -131,3 +131,19 @@ # Undefine | ||
``` | ||
### Dependencies specification | ||
As an extension to AMD dependencies specification, a dependency may be specified with | ||
an Array of two strings where the first string is the exported name and the second | ||
string is the Node.js module name. | ||
Example: the following module **loggable** has two dependencies, the first is | ||
**./extend.js**, while the second is the **uuid** which is available in the window | ||
global 'uuid' or as the Node.js module **'node-uuid'**: | ||
```javascript | ||
( this.undefine || require( 'undefine' )( module, require ) )() | ||
( 'loggable', [ './extend', [ 'uuid', 'node-uuid' ] ], function( extend, uuid ) { | ||
// loggable implementation here | ||
} ) | ||
``` | ||
## Licence | ||
@@ -134,0 +150,0 @@ |
@@ -31,2 +31,3 @@ /* undefine.js | ||
, modules = {} | ||
, node = 0; | ||
; | ||
@@ -44,2 +45,4 @@ | ||
node = 1; | ||
// Requires to first set node module and require, that of the module being defined, not this global object | ||
@@ -89,3 +92,3 @@ return module.exports = set_module; | ||
dependencies && parameters.unshift( dependencies ); | ||
dependencies && parameters.unshift( dependencies.map( disambiguate ) ); | ||
@@ -112,5 +115,11 @@ options.annonymous || parameters.unshift( options.amd_id || name ); | ||
return call_factory( node_require, function( result ) { | ||
if ( result ) module.exports = result; | ||
} ); | ||
return call_factory( | ||
function( dependency ) { | ||
return node_require( disambiguate( dependency ) ) | ||
}, | ||
function( result ) { | ||
if ( result ) module.exports = result; | ||
} | ||
); | ||
} | ||
@@ -161,5 +170,9 @@ | ||
function disambiguate( dependency ) { | ||
return dependency.pop ? dependency[ node ] : dependency | ||
} // disambiguate() | ||
function require_global( dependency ) { | ||
var f = 'require_global()' | ||
, name = dependency.split( '/' ).pop() | ||
var f = 'require_global()' | ||
, name = disambiguate( dependency ).split( '/' ).pop() | ||
; | ||
@@ -173,3 +186,3 @@ | ||
exports || log( f, 'module not yet available name:', name ); | ||
exports || fatal( f + ' not found: ' + name ); | ||
@@ -176,0 +189,0 @@ return exports; |
Sorry, the diff of this file is not supported yet
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
21538
180
171
1