xtend
Advanced tools
Comparing version 4.0.0 to 4.0.1
module.exports = extend | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
function extend() { | ||
@@ -10,3 +12,3 @@ var target = {} | ||
for (var key in source) { | ||
if (source.hasOwnProperty(key)) { | ||
if (hasOwnProperty.call(source, key)) { | ||
target[key] = source[key] | ||
@@ -13,0 +15,0 @@ } |
module.exports = extend | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
function extend(target) { | ||
@@ -8,3 +10,3 @@ for (var i = 1; i < arguments.length; i++) { | ||
for (var key in source) { | ||
if (source.hasOwnProperty(key)) { | ||
if (hasOwnProperty.call(source, key)) { | ||
target[key] = source[key] | ||
@@ -11,0 +13,0 @@ } |
{ | ||
"name": "xtend", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "extend like a boss", | ||
@@ -36,8 +36,3 @@ "keywords": [ | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "http://github.com/raynos/xtend/raw/master/LICENSE" | ||
} | ||
], | ||
"license": "MIT", | ||
"testling": { | ||
@@ -44,0 +39,0 @@ "files": "test.js", |
20
test.js
@@ -64,1 +64,21 @@ var test = require("tape") | ||
}) | ||
test("null prototype", function(assert) { | ||
var a = { a: "foo" } | ||
var b = Object.create(null) | ||
b.b = "bar"; | ||
assert.deepEqual(extend(a, b), { a: "foo", b: "bar" }) | ||
assert.end() | ||
}) | ||
test("null prototype mutable", function (assert) { | ||
var a = { foo: "bar" } | ||
var b = Object.create(null) | ||
b.bar = "baz"; | ||
mutableExtend(a, b) | ||
assert.equal(a.bar, "baz") | ||
assert.end() | ||
}) |
5957
90