deep-extend
Advanced tools
Comparing version 0.2.11 to 0.3.0
@@ -71,2 +71,5 @@ /*! | ||
continue; | ||
} else if (val instanceof RegExp) { | ||
target[key] = new RegExp(val); | ||
continue; | ||
} | ||
@@ -73,0 +76,0 @@ |
{ | ||
"name": "deep-extend", | ||
"description": "Recursive object extending.", | ||
"license": "MIT", | ||
"version": "0.2.11", | ||
"homepage": "https://github.com/unclechu/node-deep-extend", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/unclechu/node-deep-extend.git" | ||
}, | ||
"author": { | ||
"name": "Viacheslav Lotsmanov (unclechu)", | ||
"email": "lotsmanov89@gmail.com" | ||
}, | ||
"contributors": [ | ||
{ | ||
"name": "Romain Prieto", | ||
"url": "https://github.com/rprieto" | ||
} | ||
], | ||
"main": "index", | ||
"engines": { | ||
"node": ">=0.4" | ||
}, | ||
"scripts": { | ||
"test": "./node_modules/.bin/mocha" | ||
}, | ||
"devDependencies": { | ||
"mocha": "~1.19.0", | ||
"should": "~3.3.2" | ||
}, | ||
"directories": { | ||
"test": "./test" | ||
} | ||
"name": "deep-extend", | ||
"description": "Recursive object extending.", | ||
"license": "MIT", | ||
"version": "0.3.0", | ||
"homepage": "https://github.com/unclechu/node-deep-extend", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/unclechu/node-deep-extend.git" | ||
}, | ||
"author": { | ||
"name": "Viacheslav Lotsmanov (unclechu)", | ||
"email": "lotsmanov89@gmail.com" | ||
}, | ||
"contributors": [ | ||
{ | ||
"name": "Romain Prieto", | ||
"url": "https://github.com/rprieto" | ||
}, | ||
{ | ||
"name": "Max Maximov", | ||
"url": "https://github.com/maxmaximov" | ||
} | ||
], | ||
"main": "index", | ||
"engines": { | ||
"node": ">=0.4" | ||
}, | ||
"scripts": { | ||
"test": "./node_modules/.bin/mocha" | ||
}, | ||
"devDependencies": { | ||
"mocha": "~1.19.0", | ||
"should": "~3.3.2" | ||
}, | ||
"directories": { | ||
"test": "./test" | ||
} | ||
} |
@@ -6,6 +6,9 @@ Node.JS module “Deep Extend” | ||
[![NPM](https://nodei.co/npm/deep-extend.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/deep-extend/) | ||
[![NPM](https://nodei.co/npm-dl/deep-extend.png?height=3)](https://nodei.co/npm/deep-extend/) | ||
Install | ||
----- | ||
npm install deep-extend | ||
npm install deep-extend | ||
@@ -15,40 +18,43 @@ Usage | ||
var deepExtend = require('deep-extend'); | ||
var obj1 = { | ||
a: 1, | ||
b: 2, | ||
d: { | ||
a: 1, | ||
b: [], | ||
c: { test1: 123, test2: 321 } | ||
}, | ||
f: 5, | ||
g: 123 | ||
}; | ||
var obj2 = { | ||
b: 3, | ||
c: 5, | ||
d: { | ||
b: { first: 'one', second: 'two' }, | ||
c: { test2: 222 } | ||
}, | ||
e: { one: 1, two: 2 }, | ||
f: [], | ||
g: (void 0) | ||
}; | ||
var deepExtend = require('deep-extend'); | ||
var obj1 = { | ||
a: 1, | ||
b: 2, | ||
d: { | ||
a: 1, | ||
b: [], | ||
c: { test1: 123, test2: 321 } | ||
}, | ||
f: 5, | ||
g: 123 | ||
}; | ||
var obj2 = { | ||
b: 3, | ||
c: 5, | ||
d: { | ||
b: { first: 'one', second: 'two' }, | ||
c: { test2: 222 } | ||
}, | ||
e: { one: 1, two: 2 }, | ||
f: [], | ||
g: (void 0), | ||
h: /abc/g, | ||
f: null | ||
}; | ||
deepExtend(obj1, obj2); | ||
deepExtend(obj1, obj2); | ||
console.log(obj1); | ||
/* | ||
{ a: 1, | ||
b: 3, | ||
d: | ||
{ a: 1, | ||
b: { first: 'one', second: 'two' }, | ||
c: { test1: 123, test2: 222 } }, | ||
f: [], | ||
c: 5, | ||
e: { one: 1, two: 2 }, | ||
g: undefined } | ||
*/ | ||
console.log(obj1); | ||
/* | ||
{ a: 1, | ||
b: 3, | ||
d: | ||
{ a: 1, | ||
b: { first: 'one', second: 'two' }, | ||
c: { test1: 123, test2: 222 } }, | ||
f: null, | ||
g: undefined, | ||
c: 5, | ||
e: { one: 1, two: 2 }, | ||
h: /abc/g } | ||
*/ |
@@ -57,2 +57,15 @@ var should = require('should'); | ||
it('RegExp objects', function () { | ||
var a = { d: new RegExp() }; | ||
var b = extend({}, a); | ||
b.d.should.instanceOf(RegExp); | ||
}); | ||
it('RegExp object is cloned', function () { | ||
var a = { d: new RegExp('b', 'g') }; | ||
var b = extend({}, a); | ||
b.d.test('abc'); | ||
b.d.lastIndex.should.not.eql( a.d.lastIndex ); | ||
}); | ||
}); |
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
7531
8
139
59