Comparing version 0.2.0 to 0.2.1
@@ -10,2 +10,3 @@ var lib = require('./lib/deap'); | ||
merge: lib.merge, | ||
cloneShallow: lib.cloneShallow, | ||
extendShallow: lib.extendShallow, | ||
@@ -12,0 +13,0 @@ updateShallow: lib.updateShallow, |
@@ -5,3 +5,4 @@ var typeOf = require('./typeof'), | ||
module.exports = { | ||
clone: clone, | ||
clone: deepClone, | ||
cloneShallow: clone, | ||
extend: deepExtend, | ||
@@ -18,5 +19,20 @@ extendShallow: extend, | ||
case 'object': | ||
return extend({}, val); | ||
case 'array': | ||
return [].concat(val); | ||
case 'date': | ||
return new Date(val.getTime()); | ||
case 'regexp': | ||
return new RegExp(val); | ||
default: | ||
return val; | ||
} | ||
} | ||
function deepClone(val) { | ||
switch(typeOf(val)) { | ||
case 'object': | ||
return deepExtend({}, val); | ||
case 'array': | ||
return val.map(clone); | ||
return val.map(deepClone); | ||
case 'date': | ||
@@ -46,3 +62,3 @@ return new Date(val.getTime()); | ||
else | ||
a[p] = clone(b[p]); | ||
a[p] = deepClone(b[p]); | ||
}); | ||
@@ -75,5 +91,5 @@ }); | ||
ap.length = 0; | ||
ap.push.apply(ap, bp.map(clone)); | ||
ap.push.apply(ap, bp.map(deepClone)); | ||
} else | ||
a[p] = clone(bp); | ||
a[p] = deepClone(bp); | ||
} | ||
@@ -105,3 +121,3 @@ }); | ||
else if(!a.hasOwnProperty(p)) | ||
a[p] = clone(bp); | ||
a[p] = deepClone(bp); | ||
}); | ||
@@ -108,0 +124,0 @@ }); |
{ | ||
"name": "deap", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "extend and merge objects, deep or shallow", | ||
@@ -33,3 +33,3 @@ "main": "index.js", | ||
], | ||
"license": "BSD", | ||
"license": "MIT", | ||
"readmeFilename": "README.md", | ||
@@ -45,5 +45,4 @@ "devDependencies": { | ||
"chrome/25..latest", | ||
"safari/latest", | ||
"iphone/6", | ||
"ipad/6", | ||
"iphone/latest", | ||
"ipad/latest", | ||
"android-browser/latest" | ||
@@ -50,0 +49,0 @@ ], |
@@ -6,3 +6,3 @@ var lib = require('./lib/deap'); | ||
deap(deap, { | ||
clone: lib.clone, | ||
clone: lib.cloneShallow, | ||
extend: lib.extendShallow, | ||
@@ -9,0 +9,0 @@ update: lib.updateShallow, |
@@ -12,2 +12,7 @@ var assert = require('chai').assert, | ||
it('should have cloneShallow defined', function() { | ||
assert.isFunction(deap.cloneShallow); | ||
assert.deepEqual(deap.cloneShallow, lib.cloneShallow); | ||
}); | ||
it('should have extend exposed as a top level function', function() { | ||
@@ -14,0 +19,0 @@ assert.isFunction(deap); |
@@ -21,5 +21,5 @@ var assert = require('chai').assert, | ||
assert.equal(shallow.merge, lib.mergeShallow); | ||
assert.equal(shallow.clone, lib.clone); | ||
assert.equal(shallow.clone, lib.cloneShallow); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
26699
15
0
0
666