immutable-object-methods
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -13,8 +13,8 @@ 'use strict'; | ||
exports.default = function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
exports.default = function (first) { | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
return _objectAssign2.default.apply(undefined, [{}].concat(args)); | ||
return Array.isArray(first) ? _objectAssign2.default.apply(undefined, [[], first].concat(args)) : _objectAssign2.default.apply(undefined, [{}, first].concat(args)); | ||
}; |
import assign from 'object-assign'; | ||
export default (...args) => assign({}, ...args); | ||
export default (first, ...args) => | ||
Array.isArray(first) | ||
? assign([], first, ...args) | ||
: assign({}, first, ...args); |
{ | ||
"name": "immutable-object-methods", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Update normal plain javascript object, immutable style. Simlar to how immutable.js, seamless-immutable etc does it but a lot smaller and simpler.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
17
test.js
@@ -31,2 +31,11 @@ import test from 'ava'; | ||
test('set with array', t => { | ||
const input = Object.freeze([0, 1]); | ||
const actual = set(input, 0, -1); | ||
const expected = [-1, 1]; | ||
t.deepEqual(actual, expected); | ||
t.true(Array.isArray(actual)); | ||
}); | ||
test('setIn', t => { | ||
@@ -109,2 +118,10 @@ const input = Object.freeze({}); | ||
test('assign w array', t => { | ||
const input = [0]; | ||
const actual = assign(input, [1, 2, 3]); | ||
const expected = [1, 2, 3]; | ||
t.deepEqual(actual, expected); | ||
t.true(Array.isArray(actual)); | ||
}); | ||
test('mergeDeep', t => { | ||
@@ -111,0 +128,0 @@ const input = Object.freeze({}); |
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
17780
469