just-extend
Advanced tools
Comparing version 1.1.26 to 1.1.27
15
index.js
@@ -25,5 +25,6 @@ module.exports = extend; | ||
extend({a: 4, b: 5}); // {a: 4, b: 5} | ||
extend({a: 4, b: 5}, 3); {a: 4, b: 5} | ||
extend({a: 4, b: 5}, true); {a: 4, b: 5} | ||
extend('hello', {a: 4, b: 5}); // throws | ||
extend(3, {a: 4, b: 5}); // throws | ||
extend({a: 4, b: 5}, 3); // throws | ||
extend({a: 4, b: 5}, true); // throws | ||
*/ | ||
@@ -37,10 +38,6 @@ | ||
} | ||
var arg; | ||
var i = args.length; | ||
while (((arg = args[i - 1]), i--)) { | ||
if (!arg || (typeof arg != 'object' && typeof arg != 'function')) { | ||
throw new Error('expected object, got ' + arg); | ||
} | ||
var result = args[0]; | ||
if (!result || (typeof result != 'object' && typeof result != 'function')) { | ||
throw new Error('extendee must be an object'); | ||
} | ||
var result = args[0]; | ||
var extenders = args.slice(1); | ||
@@ -47,0 +44,0 @@ var len = extenders.length; |
{ | ||
"name": "just-extend", | ||
"version": "1.1.26", | ||
"version": "1.1.27", | ||
"description": "extend an object", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -11,26 +11,27 @@ ## just-extend | ||
let obj = {a: 3, b: 5}; | ||
var obj = {a: 3, b: 5}; | ||
extend(obj, {a: 4, c: 8}); // {a: 4, b: 5, c: 8} | ||
obj; // {a: 4, b: 5, c: 8} | ||
let obj = {a: 3, b: 5}; | ||
var obj = {a: 3, b: 5}; | ||
extend({}, obj, {a: 4, c: 8}); // {a: 4, b: 5, c: 8} | ||
obj; // {a: 3, b: 5} | ||
let arr = [1, 2, 3]; | ||
let obj = {a: 3, b: 5}; | ||
var arr = [1, 2, 3]; | ||
var obj = {a: 3, b: 5}; | ||
extend(obj, {c: arr}); // {a: 3, b: 5, c: [1, 2, 3]} | ||
arr.push[4]; | ||
arr.push(4); | ||
obj; // {a: 3, b: 5, c: [1, 2, 3, 4]} | ||
let arr = [1, 2, 3]; | ||
let obj = {a: 3, b: 5}; | ||
var arr = [1, 2, 3]; | ||
var obj = {a: 3, b: 5}; | ||
extend(true, obj, {c: arr}); // {a: 3, b: 5, c: [1, 2, 3]} | ||
arr.push[4]; | ||
arr.push(4); | ||
obj; // {a: 3, b: 5, c: [1, 2, 3]} | ||
extend({a: 4, b: 5}); // {a: 4, b: 5} | ||
extend({a: 4, b: 5}, 3); {a: 4, b: 5} | ||
extend({a: 4, b: 5}, true); {a: 4, b: 5} | ||
extend('hello', {a: 4, b: 5}); // throws | ||
extend(3, {a: 4, b: 5}); // throws | ||
extend({a: 4, b: 5}, 3); // throws | ||
extend({a: 4, b: 5}, {b: 4, c: 5}, 'c'); // throws | ||
``` |
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
3076
37
51