Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

deap

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deap - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

LICENSE

1

index.js

@@ -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,

28

lib/deap.js

@@ -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);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc