simple-update-in
Advanced tools
Comparing version 1.3.1-master.023101b to 1.3.1-master.f84f35c
@@ -8,2 +8,6 @@ # Changelog | ||
## [Unreleased] | ||
### Fixed | ||
- Using a predicate on a non-existing key/index should not throw error and return the original value as-is | ||
- `updateIn({}, ['Hello', () => true], () => 'World!'])` will return `{}` | ||
- `updateIn([], [0, () => true], () => 'Aloha'])` will return `[]` | ||
@@ -10,0 +14,0 @@ ## [1.3.0] - 2018-08-17 |
@@ -37,3 +37,3 @@ 'use strict'; | ||
}); | ||
} else { | ||
} else if (obj) { | ||
Object.keys(obj).forEach(function (key) { | ||
@@ -40,0 +40,0 @@ if (accessor.call(obj, obj[key], key)) { |
{ | ||
"name": "simple-update-in", | ||
"version": "1.3.1-master.023101b", | ||
"version": "1.3.1-master.f84f35c", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -184,2 +184,20 @@ # simple-update-in | ||
### Non-existing key/index with predicate | ||
Since it is impossible to guess if the predicate is performing on an array or map. [automatic expansion](#automatic-expansion) will not be performed if the key/index does not exists. Nevertheless, even we expand it into an empty array or map, it will not be enumerated thru the predicate since the new item is empty. Thus, nothing will change. | ||
```js | ||
const from = {}; | ||
const actual = updateIn(from, ['Hello', () => true], () => 'World!']); | ||
expect(actual).toBe(from); | ||
``` | ||
```js | ||
const from = []; | ||
const actual = updateIn(from, [0, () => true], () => 'Aloha']); | ||
expect(actual).toBe(from); | ||
``` | ||
# Contributions | ||
@@ -186,0 +204,0 @@ |
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
13305
209