Comparing version 0.1.13 to 0.1.14
22
clone.js
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
var util = require("util"); | ||
var util = require('util'); | ||
@@ -38,3 +38,2 @@ function objectToString(o) { | ||
function clone(parent, circular, depth) { | ||
// maintain two arrays for circular references, where corresponding parents | ||
@@ -55,2 +54,5 @@ // and children have the same index | ||
function _clone(parent, depth) { | ||
// cloning null always returns null | ||
if (parent === null) | ||
return null; | ||
@@ -64,11 +66,11 @@ if (depth == 0) | ||
} | ||
if (util.isArray(parent)) | ||
if (util.isArray(parent)) { | ||
child = []; | ||
else if (util.isRegExp(parent)) { | ||
} else if (util.isRegExp(parent)) { | ||
child = new RegExp(parent.source, getRegExpFlags(parent)); | ||
if (parent.lastIndex) child.lastIndex = parent.lastIndex; | ||
} | ||
else if (util.isDate(parent)) | ||
} else if (util.isDate(parent)) { | ||
child = new Date(parent.getTime()); | ||
else if (useBuffer && Buffer.isBuffer(parent)) { | ||
} else if (useBuffer && Buffer.isBuffer(parent)) { | ||
child = new Buffer(parent.length); | ||
@@ -79,2 +81,3 @@ parent.copy(child); | ||
} | ||
if (circular) { | ||
@@ -89,7 +92,10 @@ var index = allParents.indexOf(parent); | ||
} | ||
for (var i in parent) { | ||
child[i] = _clone(parent[i], depth - 1); | ||
} | ||
return child; | ||
} | ||
return _clone(parent, depth); | ||
@@ -96,0 +102,0 @@ } |
@@ -11,3 +11,3 @@ { | ||
], | ||
"version": "0.1.13", | ||
"version": "0.1.14", | ||
"repository": { | ||
@@ -14,0 +14,0 @@ "type": "git", |
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
13644
275