Comparing version 0.8.8 to 0.8.9
{ | ||
"name": "udefine", | ||
"version": "0.8.8", | ||
"version": "0.8.9", | ||
"homepage": "https://github.com/freezedev/udefine", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -0,0 +0,0 @@ (function() { |
@@ -7,5 +7,3 @@ (function() { | ||
(function() { | ||
var _ref; | ||
return (_ref = Array.isArray) != null ? _ref : Array.isArray = function(a) { | ||
return Array.isArray != null ? Array.isArray : Array.isArray = function(a) { | ||
return a.push === Array.prototype.push && (a.length != null); | ||
@@ -25,3 +23,2 @@ }; | ||
var loadModule, platform, platforms, resolveModule, udefine; | ||
platforms = ['commonjs', 'globals']; | ||
@@ -37,5 +34,12 @@ platform = hasModule ? 'commonjs' : 'globals'; | ||
loadModule = function(name, type) { | ||
var path, prePath; | ||
var packageModule, path, prePath; | ||
if (hasModule && typeof udefine.modules[type][name] === 'string') { | ||
packageModule = (function() { | ||
try { | ||
return require(udefine.modules[type][name]); | ||
} catch (_error) {} | ||
})(); | ||
if (packageModule != null) { | ||
return packageModule; | ||
} | ||
path = require('path'); | ||
@@ -56,3 +60,2 @@ prePath = (function() { | ||
var dep, depArr, ignoreName, injectName, injectObject, injectRoot, result, _ref; | ||
if (name == null) { | ||
@@ -74,3 +77,2 @@ throw new Error('A udefine module needs to have a name'); | ||
var _i, _len, _results; | ||
_results = []; | ||
@@ -96,2 +98,3 @@ for (_i = 0, _len = deps.length; _i < _len; _i++) { | ||
} | ||
/* | ||
@@ -103,4 +106,3 @@ if udefine.env.commonjs | ||
ignoreName: true | ||
*/ | ||
*/ | ||
} | ||
@@ -158,3 +160,2 @@ } | ||
var key, v, val, _i, _len; | ||
if (typeof name === 'object') { | ||
@@ -183,3 +184,2 @@ for (key in name) { | ||
var p, _i, _len; | ||
for (_i = 0, _len = platforms.length; _i < _len; _i++) { | ||
@@ -198,3 +198,2 @@ p = platforms[_i]; | ||
var k, v; | ||
if (typeof value === 'object') { | ||
@@ -212,3 +211,2 @@ for (k in value) { | ||
var p, _i, _len; | ||
for (_i = 0, _len = platforms.length; _i < _len; _i++) { | ||
@@ -223,3 +221,3 @@ p = platforms[_i]; | ||
amd: (function() { | ||
return (typeof define !== "undefined" && define !== null) && (define.amd || define.umd); | ||
return !!((typeof define !== "undefined" && define !== null) && (define.amd || define.umd)); | ||
})(), | ||
@@ -237,3 +235,2 @@ commonjs: hasModule, | ||
var n, reqDeps; | ||
if (!Array.isArray(name)) { | ||
@@ -244,3 +241,2 @@ name = [name]; | ||
var _i, _len, _results; | ||
_results = []; | ||
@@ -266,5 +262,3 @@ for (_i = 0, _len = name.length; _i < _len; _i++) { | ||
udefine.configure = function(configFunc) { | ||
var context, e, _ref, | ||
_this = this; | ||
var context, e, _ref; | ||
context = {}; | ||
@@ -274,7 +268,9 @@ _ref = udefine.env; | ||
if (!__hasProp.call(_ref, e)) continue; | ||
context[e] = function(platformDef) { | ||
if (udefine.env[e]) { | ||
return platformDef.call(_this); | ||
} | ||
}; | ||
context[e] = (function(_this) { | ||
return function(platformDef) { | ||
if (udefine.env[e]) { | ||
return platformDef.call(_this); | ||
} | ||
}; | ||
})(this); | ||
} | ||
@@ -281,0 +277,0 @@ return configFunc.apply(context, [root, udefine]); |
@@ -1,2 +0,2 @@ | ||
/*! udefine - v0.8.7 - 04-10-2013 */ | ||
(function(){"use strict";var e,n,o,t={}.hasOwnProperty;(function(){var e;return null!=(e=Array.isArray)?e:Array.isArray=function(e){return e.push===Array.prototype.push&&null!=e.length}})(),n=!("undefined"==typeof module||null===module||!module.exports),e={},o=function(e){return"object"==typeof e&&!Array.isArray(e)},function(e){var r,u,l,i,s;return l=["commonjs","globals"],u=n?"commonjs":"globals",i=function(e,n){return"function"==typeof e?e.apply(this,n):e},r=function(e,o){var t,r;return n&&"string"==typeof s.modules[o][e]?(t=require("path"),r=function(){return s.paths[o].base?s.paths[o].base:""}(),require(t.join(process.cwd(),r,s.modules[o][e]))):s.modules[o][e]},s=function(n,t,l){var a,d,c,f,m,h,p,y;if(null==n)throw Error("A udefine module needs to have a name");return n!==n.toLowerCase()&&console.warn("A module should be all lowercase"),("function"==typeof t||o(t))&&(y=[n,[],t],n=y[0],t=y[1],l=y[2]),"undefined"!=typeof define&&null!==define?(define.amd||define.umd)&&(p=define.apply(this,arguments)):(d=function(){var e,n,o;for(o=[],e=0,n=t.length;n>e;e++)a=t[e],o.push(r(a,u));return o}(),p=i(l,d),Object.hasOwnProperty.call(s.modules[u],n)||(s.modules[u][n]=p)),Object.hasOwnProperty.call(s.inject.modules,n)||s.autoInject&&s.env.globals&&s.inject.add(n,{root:e,name:n}),Object.hasOwnProperty.call(s.inject.modules,n)&&(m=s.inject.modules[n],h=m.root,f=m.name,c=m.ignoreName,s.inject(h,f,c)(p)),p},s.autoInject=!0,s.inject=function(e,n,o){return function(t){return null!=e&&null!=n?o?e||(e=t):e[n]||(e[n]=t):void 0}},s.inject.modules={},s.inject.add=function(n,o){return null!=n?(null==o&&(o={}),null==o.root&&(o.root=e),null==o.name&&(o.name=n),s.inject.modules[n]=o,this):void 0},s.inject.remove=function(e){return delete s.inject.modules[e],this},s.inject.clear=function(){return s.inject.modules={},this},s.modules={globals:{},commonjs:{},add:function(e,n){var o,t,r,l,i;if("object"==typeof e)for(o in e)r=e[o],this.add(o,r);else if(n)if(Array.isArray(n))for(l=0,i=n.length;i>l;l++)t=n[l],s.modules[t][e]=void 0;else s.modules.set(e,n);else s.modules[u][e]=void 0;return this},remove:function(e){var n,o,t;for(o=0,t=l.length;t>o;o++)n=l[o],Object.hasOwnProperty.call(s.modules[n],e)&&delete s.modules[n][e];return this},get:function(e){return s.modules[u][e]},set:function(e,n){var o,t;if("object"==typeof n)for(o in n)t=n[o],s.modules[o][e]=t;else s.modules[u][e]=n;return this},clear:function(){var e,n,o;for(n=0,o=l.length;o>n;n++)e=l[n],s.modules[e]={};return this}},s.env||(s.env={amd:function(){return"undefined"!=typeof define&&null!==define&&(define.amd||define.umd)}(),commonjs:n,browser:!n,globals:!n&&!s.amd}),s.paths={commonjs:{base:void 0}},s.require=function(e,n){var o,t;return Array.isArray(e)||(e=[e]),t=function(){var n,t,r;for(r=[],n=0,t=e.length;t>n;n++)o=e[n],r.push(s.modules.get(o));return r}(),n.apply(this,t)},s.defaultConfig=function(){return s.modules.commonjs.root=e,s.modules.globals.root=e,null!=e.define?define("root",function(){return e}):void 0},s.defaultConfig(),s.configure=function(n){var o,r,u,l=this;o={},u=s.env;for(r in u)t.call(u,r)&&(o[r]=function(e){return s.env[r]?e.call(l):void 0});return n.apply(o,[e,s])},n?module.exports=s:e.udefine=s}(n?{}:this)}).call(this); | ||
/*! udefine - v0.8.9 - 16-06-2014 */ | ||
(function(){"use strict";var a,b,c,d={}.hasOwnProperty;!function(){return null!=Array.isArray?Array.isArray:Array.isArray=function(a){return a.push===Array.prototype.push&&null!=a.length}}(),b=!("undefined"==typeof module||null===module||!module.exports),a={},c=function(a){return"object"==typeof a&&!Array.isArray(a)},function(a){var e,f,g,h,i;return g=["commonjs","globals"],f=b?"commonjs":"globals",h=function(a,b){return"function"==typeof a?a.apply(this,b):a},e=function(a,c){var d,e,f;return b&&"string"==typeof i.modules[c][a]?(d=function(){try{return require(i.modules[c][a])}catch(b){}}(),null!=d?d:(e=require("path"),f=function(){return i.paths[c].base?i.paths[c].base:""}(),require(e.join(process.cwd(),f,i.modules[c][a])))):i.modules[c][a]},i=function(b,d,g){var j,k,l,m,n,o,p,q;if(null==b)throw new Error("A udefine module needs to have a name");return b!==b.toLowerCase()&&console.warn("A module should be all lowercase"),("function"==typeof d||c(d))&&(q=[b,[],d],b=q[0],d=q[1],g=q[2]),"undefined"!=typeof define&&null!==define?(define.amd||define.umd)&&(p=define.apply(this,arguments)):(k=function(){var a,b,c;for(c=[],a=0,b=d.length;b>a;a++)j=d[a],c.push(e(j,f));return c}(),p=h(g,k),Object.hasOwnProperty.call(i.modules[f],b)||(i.modules[f][b]=p)),Object.hasOwnProperty.call(i.inject.modules,b)||i.autoInject&&i.env.globals&&i.inject.add(b,{root:a,name:b}),Object.hasOwnProperty.call(i.inject.modules,b)&&(n=i.inject.modules[b],o=n.root,m=n.name,l=n.ignoreName,i.inject(o,m,l)(p)),p},i.autoInject=!0,i.inject=function(a,b,c){return function(d){return null!=a&&null!=b?c?a||(a=d):a[b]||(a[b]=d):void 0}},i.inject.modules={},i.inject.add=function(b,c){return null!=b?(null==c&&(c={}),null==c.root&&(c.root=a),null==c.name&&(c.name=b),i.inject.modules[b]=c,this):void 0},i.inject.remove=function(a){return delete i.inject.modules[a],this},i.inject.clear=function(){return i.inject.modules={},this},i.modules={globals:{},commonjs:{},add:function(a,b){var c,d,e,g,h;if("object"==typeof a)for(c in a)e=a[c],this.add(c,e);else if(b)if(Array.isArray(b))for(g=0,h=b.length;h>g;g++)d=b[g],i.modules[d][a]=void 0;else i.modules.set(a,b);else i.modules[f][a]=void 0;return this},remove:function(a){var b,c,d;for(c=0,d=g.length;d>c;c++)b=g[c],Object.hasOwnProperty.call(i.modules[b],a)&&delete i.modules[b][a];return this},get:function(a){return i.modules[f][a]},set:function(a,b){var c,d;if("object"==typeof b)for(c in b)d=b[c],i.modules[c][a]=d;else i.modules[f][a]=b;return this},clear:function(){var a,b,c;for(b=0,c=g.length;c>b;b++)a=g[b],i.modules[a]={};return this}},i.env||(i.env={amd:function(){return!("undefined"==typeof define||null===define||!define.amd&&!define.umd)}(),commonjs:b,browser:!b,globals:!b&&!i.amd}),i.paths={commonjs:{base:void 0}},i.require=function(a,b){var c,d;return Array.isArray(a)||(a=[a]),d=function(){var b,d,e;for(e=[],b=0,d=a.length;d>b;b++)c=a[b],e.push(i.modules.get(c));return e}(),b.apply(this,d)},i.defaultConfig=function(){return i.modules.commonjs.root=a,i.modules.globals.root=a,null!=a.define?define("root",function(){return a}):void 0},i.defaultConfig(),i.configure=function(b){var c,e,f;c={},f=i.env;for(e in f)d.call(f,e)&&(c[e]=function(a){return function(b){return i.env[e]?b.call(a):void 0}}(this));return b.apply(c,[a,i])},b?module.exports=i:a.udefine=i}(b?{}:this)}).call(this); |
{ | ||
"name": "udefine", | ||
"description": "Define an UMD module like an AMD module and use it (almost) anywhere", | ||
"version": "0.8.8", | ||
"version": "0.8.9", | ||
"main": "dist/udefine.js", | ||
@@ -6,0 +6,0 @@ "devDependencies": { |
@@ -102,2 +102,5 @@ udefine | ||
**License** | ||
This is public domain. See *UNLICENSE.md* for more information. | ||
This is public domain. See *UNLICENSE.md* for more information. | ||
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/freezedev/udefine/trend.png)](https://bitdeli.com/free "Bitdeli Badge") | ||
@@ -17,3 +17,2 @@ (function() { | ||
var envProp; | ||
envProp = udefine.env; | ||
@@ -20,0 +19,0 @@ it('udefine.env has commonjs property', function() { |
@@ -26,3 +26,2 @@ (function() { | ||
var obj; | ||
obj = {}; | ||
@@ -34,3 +33,2 @@ udefine.inject(obj)(); | ||
var obj; | ||
obj = {}; | ||
@@ -43,3 +41,2 @@ udefine.inject(obj, '1')(); | ||
var obj; | ||
obj = {}; | ||
@@ -53,3 +50,2 @@ udefine.inject(obj, '2')(null); | ||
var obj; | ||
obj = {}; | ||
@@ -64,3 +60,2 @@ udefine.inject(obj, '3')('test'); | ||
var obj; | ||
obj = {}; | ||
@@ -75,3 +70,2 @@ udefine.inject(obj, '4')(4); | ||
var obj; | ||
obj = {}; | ||
@@ -85,3 +79,2 @@ udefine.inject(obj, '5')(true); | ||
var obj; | ||
obj = {}; | ||
@@ -96,3 +89,2 @@ udefine.inject(obj, '6')({}); | ||
var obj; | ||
obj = {}; | ||
@@ -107,3 +99,2 @@ udefine.inject(obj, '7')([]); | ||
var obj; | ||
obj = {}; | ||
@@ -110,0 +101,0 @@ udefine.inject(obj, '8')(function() {}); |
@@ -18,3 +18,2 @@ (function() { | ||
var resProp; | ||
udefine('abc', { | ||
@@ -36,3 +35,2 @@ a: 5, | ||
var resProp; | ||
udefine('def', function() { | ||
@@ -47,3 +45,2 @@ return 42; | ||
var injectObj; | ||
injectObj = {}; | ||
@@ -70,3 +67,2 @@ udefine.inject.add('ghi', { | ||
var injectObj; | ||
injectObj = {}; | ||
@@ -92,3 +88,2 @@ udefine.inject.add('jkl', { | ||
var injectObj; | ||
injectObj = {}; | ||
@@ -110,3 +105,2 @@ udefine.inject.add('mno', { | ||
var injectObj; | ||
injectObj = {}; | ||
@@ -113,0 +107,0 @@ udefine.inject.add('pqr', { |
@@ -21,3 +21,2 @@ (function() { | ||
var configProp; | ||
configProp = udefine.configure; | ||
@@ -29,3 +28,2 @@ expect(udefine).to.have.property('configure'); | ||
var envProp; | ||
envProp = udefine.env; | ||
@@ -71,3 +69,2 @@ expect(udefine).to.have.property('env'); | ||
var injectProp; | ||
injectProp = udefine.inject; | ||
@@ -91,3 +88,2 @@ expect(udefine).to.have.property('inject'); | ||
var defConProp; | ||
defConProp = udefine.defaultConfig; | ||
@@ -94,0 +90,0 @@ expect(udefine).to.have.property('defaultConfig'); |
@@ -0,0 +0,0 @@ (function() { |
@@ -0,0 +0,0 @@ (function() { |
@@ -0,0 +0,0 @@ (function() { |
@@ -0,0 +0,0 @@ (function() { |
@@ -0,0 +0,0 @@ (function() { |
@@ -17,3 +17,2 @@ (function() { | ||
var num; | ||
expect(dep1).to.be.a('object'); | ||
@@ -20,0 +19,0 @@ expect(dep1).to.have.property('number'); |
@@ -0,0 +0,0 @@ This is free and unencumbered software released into the public domain. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
66141
773
106
4