Comparing version 1.7.5 to 1.8.0
@@ -59,2 +59,22 @@ 'use strict' | ||
assigner.cloneObject = function ( source, object ) { | ||
var self = this | ||
object = object || { } | ||
var index = -1, props = Object.keys( source ), | ||
length = props.length | ||
while (++index < length) { | ||
var key = props[index] | ||
console.log('>>>>>>>>>>>>', key, _.isPlainObject( source[key] ), _.isArray( source[key] )) | ||
if (_.isPlainObject( source[key] ) ) | ||
object[key] = self.cloneObject( source[key], Object.keys(source[key]), object[key] ) | ||
else if (_.isArray( source[key] ) ) | ||
object[key] = source[key].slice() | ||
else | ||
object[key] = source[key] | ||
} | ||
return object | ||
} | ||
assigner.pick = function (object, properties) { | ||
@@ -61,0 +81,0 @@ var obj = { } |
{ | ||
"name": "assign.js", | ||
"version": "1.7.5", | ||
"version": "1.8.0", | ||
"description": "Tiny libary to assign objects", | ||
@@ -29,3 +29,3 @@ "keywords": [ | ||
"gulp-eslint": "^2.0.0", | ||
"gulp-load-plugins": "^1.2.0", | ||
"gulp-load-plugins": "^1.2.4", | ||
"gulp-mocha": "^2.2.0" | ||
@@ -32,0 +32,0 @@ }, |
@@ -17,2 +17,7 @@ 'use strict' | ||
karl: false | ||
}, | ||
extra: { | ||
_type: 'String', | ||
validation: function () { return 'ok' }, | ||
spectrum: [ 1, 2, 3, 4, 5 ] | ||
} | ||
@@ -25,2 +30,9 @@ } | ||
describe('Test Assign services', function () { | ||
it('Clone object', function (done) { | ||
var cloned = assigner.cloneObject( person ) | ||
cloned.extra.spectrum[1] = 200 | ||
expect( cloned.extra.spectrum ).to.eql( [ 1, 200, 3, 4, 5 ] ) | ||
expect( person.extra.spectrum ).to.eql( [ 1, 2, 3, 4, 5 ] ) | ||
done() | ||
}) | ||
it('Non recursive assign', function (done) { | ||
@@ -27,0 +39,0 @@ assigner.respect( true ).recursive(false) |
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
11266
290