Comparing version 1.0.0 to 1.0.1
@@ -29,4 +29,15 @@ // Load modules | ||
var newObj = (obj instanceof Array) ? [] : {}; | ||
if (obj instanceof Buffer) { | ||
return new Buffer(obj); | ||
} | ||
else if (obj instanceof Date) { | ||
return new Date(obj.getTime()); | ||
} | ||
else if (obj instanceof RegExp) { | ||
var flags = '' + (obj.global ? 'g' : '') + (obj.ignoreCase ? 'i' : '') + (obj.multiline ? 'm' : ''); | ||
return new RegExp(obj.source, flags); | ||
} | ||
var newObj = (obj instanceof Array ? [] : {}); | ||
seen.orig.push(obj); | ||
@@ -37,15 +48,3 @@ seen.copy.push(newObj); | ||
if (obj.hasOwnProperty(i)) { | ||
if (obj[i] instanceof Buffer) { | ||
newObj[i] = new Buffer(obj[i]); | ||
} | ||
else if (obj[i] instanceof Date) { | ||
newObj[i] = new Date(obj[i].getTime()); | ||
} | ||
else if (obj[i] instanceof RegExp) { | ||
var flags = '' + (obj[i].global ? 'g' : '') + (obj[i].ignoreCase ? 'i' : '') + (obj[i].multiline ? 'm' : ''); | ||
newObj[i] = new RegExp(obj[i].source, flags); | ||
} | ||
else { | ||
newObj[i] = exports.clone(obj[i], seen); | ||
} | ||
newObj[i] = exports.clone(obj[i], seen); | ||
} | ||
@@ -90,3 +89,6 @@ } | ||
if (!target[key] || | ||
typeof target[key] !== 'object') { | ||
typeof target[key] !== 'object' || | ||
value instanceof Date || | ||
value instanceof Buffer || | ||
value instanceof RegExp) { | ||
@@ -93,0 +95,0 @@ target[key] = exports.clone(value); |
{ | ||
"name": "hoek", | ||
"description": "General purpose node utilities", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"repository": "git://github.com/spumko/hoek", | ||
@@ -6,0 +6,0 @@ "main": "index", |
@@ -0,0 +0,0 @@ <a href="https://github.com/spumko"><img src="https://raw.github.com/spumko/spumko/master/images/from.png" align="right" /></a> |
@@ -25,3 +25,3 @@ // Load modules | ||
var nestedObj = { | ||
v: [7,8,9], | ||
v: [7, 8, 9], | ||
w: /^something$/igm, | ||
@@ -36,3 +36,3 @@ x: { | ||
y: 'y', | ||
z: new Date() | ||
z: new Date(1378775452757) | ||
}; | ||
@@ -126,3 +126,3 @@ | ||
var a = [1,2,3]; | ||
var a = [1, 2, 3]; | ||
@@ -191,6 +191,6 @@ var b = Hoek.clone(a); | ||
it('should copy a buffer', function(done){ | ||
it('should copy a buffer', function (done) { | ||
var tls = { | ||
key: new Buffer([1,2,3,4,5]), | ||
cert: new Buffer([1,2,3,4,5,6,10]) | ||
key: new Buffer([1, 2, 3, 4, 5]), | ||
cert: new Buffer([1, 2, 3, 4, 5, 6, 10]) | ||
} | ||
@@ -324,2 +324,20 @@ | ||
}); | ||
it('retains Date properties', function (done) { | ||
var a = { x: new Date(1378776452757) }; | ||
var b = Hoek.merge({}, a); | ||
expect(a.x.getTime()).to.equal(b.x.getTime()); | ||
done(); | ||
}); | ||
it('retains Date properties when merging keys', function (done) { | ||
var a = { x: new Date(1378776452757) }; | ||
var b = Hoek.merge({ x: {} }, a); | ||
expect(a.x.getTime()).to.equal(b.x.getTime()); | ||
done(); | ||
}); | ||
}); | ||
@@ -326,0 +344,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
103946
1370
0