immutable-ops
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -290,3 +290,3 @@ 'use strict'; | ||
if ((0, _lodashIsArrayLike2['default'])(obj)) return immutableArrSet(opts, key, value, obj); | ||
if (canMutate(obj)) return mutableSet(opts, key, obj); | ||
if (canMutate(obj)) return mutableSet(opts, key, value, obj); | ||
@@ -293,0 +293,0 @@ if (obj[key] === value) return obj; |
@@ -141,2 +141,23 @@ 'use strict'; | ||
it('sets a value', function () { | ||
var obj = (0, _deepFreeze2['default'])({ | ||
one: 1, | ||
two: 500, | ||
three: 3 | ||
}); | ||
var result = undefined; | ||
ops.batched(function () { | ||
result = ops.set('two', 5, obj); | ||
expect((0, _index.canMutate)(result)).to.be['true']; | ||
result = ops.set('two', 2, result); | ||
}); | ||
expect(result).to.deep.equal({ | ||
one: 1, | ||
two: 2, | ||
three: 3 | ||
}); | ||
}); | ||
it('sets a value in path', function () { | ||
@@ -143,0 +164,0 @@ var obj = (0, _deepFreeze2['default'])({ |
{ | ||
"name": "immutable-ops", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "A collection of functions to perform immutable operations on plain JavaScript objects", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -266,3 +266,3 @@ import forOwn from 'lodash/forOwn'; | ||
if (isArrayLike(obj)) return immutableArrSet(opts, key, value, obj); | ||
if (canMutate(obj)) return mutableSet(opts, key, obj); | ||
if (canMutate(obj)) return mutableSet(opts, key, value, obj); | ||
@@ -269,0 +269,0 @@ if (obj[key] === value) return obj; |
@@ -123,2 +123,23 @@ import chai from 'chai'; | ||
it('sets a value', () => { | ||
const obj = freeze({ | ||
one: 1, | ||
two: 500, | ||
three: 3, | ||
}); | ||
let result; | ||
ops.batched(() => { | ||
result = ops.set('two', 5, obj); | ||
expect(canMutate(result)).to.be.true; | ||
result = ops.set('two', 2, result); | ||
}); | ||
expect(result).to.deep.equal({ | ||
one: 1, | ||
two: 2, | ||
three: 3, | ||
}); | ||
}); | ||
it('sets a value in path', () => { | ||
@@ -125,0 +146,0 @@ const obj = 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
72211
1576