Comparing version 1.8.1 to 1.8.2
@@ -59,19 +59,27 @@ 'use strict' | ||
assigner.cloneObject = function ( source, object ) { | ||
assigner.cloneObject = function ( source ) { | ||
var self = this | ||
object = object || { } | ||
var index = -1, props = Object.keys( source ), | ||
length = props.length | ||
if (!source) return source | ||
while (++index < length) { | ||
var key = props[index] | ||
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] | ||
if (_.isPlainObject( source ) ) { | ||
var object = { } | ||
var index = -1, props = Object.keys( source ), length = props.length | ||
while (++index < length) { | ||
var key = props[index] | ||
object[ key ] = self.cloneObject( source[key] ) | ||
} | ||
return object | ||
} | ||
return object | ||
else if (_.isArray( source ) ) { | ||
var array = [] | ||
source.forEach( function ( element ) { | ||
array.push( self.cloneObject( element ) ) | ||
} ) | ||
return array | ||
} | ||
return source | ||
} | ||
@@ -78,0 +86,0 @@ |
{ | ||
"name": "assign.js", | ||
"version": "1.8.1", | ||
"version": "1.8.2", | ||
"description": "Tiny libary to assign objects", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
11221
294