core-extensions
Advanced tools
Comparing version 0.1.0 to 0.1.1
30
index.js
@@ -12,3 +12,2 @@ "use strict"; | ||
var target = null; | ||
var type = typeof this; | ||
@@ -18,5 +17,26 @@ if ( this instanceof Date ) { | ||
} | ||
else if ( Object.isObject( this ) || Array.isArray( this ) ) { | ||
target = JSON.parse( JSON.stringify( this ) ); // probably a slightly more efficient way to do this, but this is ok for now | ||
else if ( Array.isArray( this ) ) { | ||
target = []; | ||
for ( var i = 0; i < this.length; i++ ) { | ||
if ( Array.isArray( this[i] ) || Object.isObject( this[i] ) ) { | ||
target[i] = this[i].clone(); | ||
} | ||
else { | ||
target[i] = this[i]; | ||
} | ||
} | ||
} | ||
else if ( Object.isObject( this ) ) { | ||
target = {}; | ||
for ( var field in this ) { | ||
if ( this.hasOwnProperty( field ) ) { | ||
if ( Array.isArray( this[field] ) || Object.isObject( this[field] ) ) { | ||
target[field] = this[field].clone(); | ||
} | ||
else { | ||
target[field] = this[field]; | ||
} | ||
} | ||
} | ||
} | ||
else { // functions, etc. not clonable yet, just pass through | ||
@@ -85,6 +105,2 @@ target = this; | ||
if ( typeof target === 'function' || typeof source === 'function' ) { | ||
throw new Error( 'mixin does not support function values' ); | ||
} | ||
// if target exists and is an array... | ||
@@ -91,0 +107,0 @@ if ( Array.isArray( target ) ) { |
@@ -5,3 +5,3 @@ { | ||
"author": "Anthony Hildoer <anthony@bluerival.com>", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
@@ -162,2 +162,4 @@ 'use strict'; | ||
} | ||
}, | ||
func: function () { | ||
} | ||
@@ -185,2 +187,4 @@ }; | ||
'one', | ||
function () { | ||
}, | ||
1, | ||
@@ -187,0 +191,0 @@ 'onepointone', |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
15265
434
0