@thi.ng/paths
Advanced tools
Comparing version 2.0.6 to 2.0.7
@@ -6,50 +6,15 @@ # Change Log | ||
## [2.0.6](https://github.com/thi-ng/umbrella/compare/@thi.ng/paths@2.0.5...@thi.ng/paths@2.0.6) (2019-03-18) | ||
## [2.0.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/paths@2.0.6...@thi.ng/paths@2.0.7) (2019-03-28) | ||
**Note:** Version bump only for package @thi.ng/paths | ||
### Bug Fixes | ||
* **paths:** fix getIn for empty leaves, add tests ([49952fd](https://github.com/thi-ng/umbrella/commit/49952fd)) | ||
## [2.0.5](https://github.com/thi-ng/umbrella/compare/@thi.ng/paths@2.0.4...@thi.ng/paths@2.0.5) (2019-03-12) | ||
**Note:** Version bump only for package @thi.ng/paths | ||
## [2.0.4](https://github.com/thi-ng/umbrella/compare/@thi.ng/paths@2.0.3...@thi.ng/paths@2.0.4) (2019-03-01) | ||
**Note:** Version bump only for package @thi.ng/paths | ||
## [2.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/paths@2.0.2...@thi.ng/paths@2.0.3) (2019-02-10) | ||
**Note:** Version bump only for package @thi.ng/paths | ||
## [2.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/paths@2.0.1...@thi.ng/paths@2.0.2) (2019-02-05) | ||
**Note:** Version bump only for package @thi.ng/paths | ||
## [2.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/paths@2.0.0...@thi.ng/paths@2.0.1) (2019-01-21) | ||
**Note:** Version bump only for package @thi.ng/paths | ||
# [2.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/paths@1.6.6...@thi.ng/paths@2.0.0) (2019-01-21) | ||
@@ -56,0 +21,0 @@ |
33
index.js
@@ -7,3 +7,2 @@ import { isString } from "@thi.ng/checks"; | ||
const compS = (k, f) => (s, v) => ((s = _copy(s)), (s[k] = f ? f(s[k], v) : v), s); | ||
const compG = (k, f) => (s) => (s ? f(s[k]) : undefined); | ||
/** | ||
@@ -97,9 +96,9 @@ * Converts the given key path to canonical form (array). | ||
case 1: | ||
return (s) => (s ? s[a] : undefined); | ||
return (s) => (s != null ? s[a] : undefined); | ||
case 2: | ||
return (s) => (s ? ((s = s[a]) ? s[b] : undefined) : undefined); | ||
return (s) => s != null ? ((s = s[a]) != null ? s[b] : undefined) : undefined; | ||
case 3: | ||
return (s) => s | ||
? (s = s[a]) | ||
? (s = s[b]) | ||
return (s) => s != null | ||
? (s = s[a]) != null | ||
? (s = s[b]) != null | ||
? s[c] | ||
@@ -110,6 +109,6 @@ : undefined | ||
case 4: | ||
return (s) => s | ||
? (s = s[a]) | ||
? (s = s[b]) | ||
? (s = s[c]) | ||
return (s) => s != null | ||
? (s = s[a]) != null | ||
? (s = s[b]) != null | ||
? (s = s[c]) != null | ||
? s[d] | ||
@@ -121,8 +120,10 @@ : undefined | ||
default: | ||
const kl = ks[ks.length - 1]; | ||
let f = (s) => (s ? s[kl] : undefined); | ||
for (let i = ks.length - 1; --i >= 0;) { | ||
f = compG(ks[i], f); | ||
} | ||
return f; | ||
return (s) => { | ||
const n = ks.length - 1; | ||
let res = s; | ||
for (let i = 0; res != null && i <= n; i++) { | ||
res = res[ks[i]]; | ||
} | ||
return res; | ||
}; | ||
} | ||
@@ -129,0 +130,0 @@ }; |
@@ -12,3 +12,2 @@ 'use strict'; | ||
const compS = (k, f) => (s, v) => ((s = _copy(s)), (s[k] = f ? f(s[k], v) : v), s); | ||
const compG = (k, f) => (s) => (s ? f(s[k]) : undefined); | ||
const toPath = (path) => isa(path) | ||
@@ -47,9 +46,9 @@ ? path | ||
case 1: | ||
return (s) => (s ? s[a] : undefined); | ||
return (s) => (s != null ? s[a] : undefined); | ||
case 2: | ||
return (s) => (s ? ((s = s[a]) ? s[b] : undefined) : undefined); | ||
return (s) => s != null ? ((s = s[a]) != null ? s[b] : undefined) : undefined; | ||
case 3: | ||
return (s) => s | ||
? (s = s[a]) | ||
? (s = s[b]) | ||
return (s) => s != null | ||
? (s = s[a]) != null | ||
? (s = s[b]) != null | ||
? s[c] | ||
@@ -60,6 +59,6 @@ : undefined | ||
case 4: | ||
return (s) => s | ||
? (s = s[a]) | ||
? (s = s[b]) | ||
? (s = s[c]) | ||
return (s) => s != null | ||
? (s = s[a]) != null | ||
? (s = s[b]) != null | ||
? (s = s[c]) != null | ||
? s[d] | ||
@@ -71,8 +70,10 @@ : undefined | ||
default: | ||
const kl = ks[ks.length - 1]; | ||
let f = (s) => (s ? s[kl] : undefined); | ||
for (let i = ks.length - 1; --i >= 0;) { | ||
f = compG(ks[i], f); | ||
} | ||
return f; | ||
return (s) => { | ||
const n = ks.length - 1; | ||
let res = s; | ||
for (let i = 0; res != null && i <= n; i++) { | ||
res = res[ks[i]]; | ||
} | ||
return res; | ||
}; | ||
} | ||
@@ -210,14 +211,14 @@ }; | ||
exports.toPath = toPath; | ||
exports.deleteIn = deleteIn; | ||
exports.exists = exists; | ||
exports.getIn = getIn; | ||
exports.getter = getter; | ||
exports.setter = setter; | ||
exports.getIn = getIn; | ||
exports.mutIn = mutIn; | ||
exports.mutInMany = mutInMany; | ||
exports.mutator = mutator; | ||
exports.setIn = setIn; | ||
exports.setInMany = setInMany; | ||
exports.setter = setter; | ||
exports.toPath = toPath; | ||
exports.updateIn = updateIn; | ||
exports.updater = updater; | ||
exports.updateIn = updateIn; | ||
exports.deleteIn = deleteIn; | ||
exports.mutator = mutator; | ||
exports.mutIn = mutIn; | ||
exports.mutInMany = mutInMany; |
@@ -11,3 +11,2 @@ (function (global, factory) { | ||
const compS = (k, f) => (s, v) => ((s = _copy(s)), (s[k] = f ? f(s[k], v) : v), s); | ||
const compG = (k, f) => (s) => (s ? f(s[k]) : undefined); | ||
const toPath = (path) => isa(path) | ||
@@ -46,9 +45,9 @@ ? path | ||
case 1: | ||
return (s) => (s ? s[a] : undefined); | ||
return (s) => (s != null ? s[a] : undefined); | ||
case 2: | ||
return (s) => (s ? ((s = s[a]) ? s[b] : undefined) : undefined); | ||
return (s) => s != null ? ((s = s[a]) != null ? s[b] : undefined) : undefined; | ||
case 3: | ||
return (s) => s | ||
? (s = s[a]) | ||
? (s = s[b]) | ||
return (s) => s != null | ||
? (s = s[a]) != null | ||
? (s = s[b]) != null | ||
? s[c] | ||
@@ -59,6 +58,6 @@ : undefined | ||
case 4: | ||
return (s) => s | ||
? (s = s[a]) | ||
? (s = s[b]) | ||
? (s = s[c]) | ||
return (s) => s != null | ||
? (s = s[a]) != null | ||
? (s = s[b]) != null | ||
? (s = s[c]) != null | ||
? s[d] | ||
@@ -70,8 +69,10 @@ : undefined | ||
default: | ||
const kl = ks[ks.length - 1]; | ||
let f = (s) => (s ? s[kl] : undefined); | ||
for (let i = ks.length - 1; --i >= 0;) { | ||
f = compG(ks[i], f); | ||
} | ||
return f; | ||
return (s) => { | ||
const n = ks.length - 1; | ||
let res = s; | ||
for (let i = 0; res != null && i <= n; i++) { | ||
res = res[ks[i]]; | ||
} | ||
return res; | ||
}; | ||
} | ||
@@ -209,15 +210,15 @@ }; | ||
exports.toPath = toPath; | ||
exports.deleteIn = deleteIn; | ||
exports.exists = exists; | ||
exports.getIn = getIn; | ||
exports.getter = getter; | ||
exports.setter = setter; | ||
exports.getIn = getIn; | ||
exports.mutIn = mutIn; | ||
exports.mutInMany = mutInMany; | ||
exports.mutator = mutator; | ||
exports.setIn = setIn; | ||
exports.setInMany = setInMany; | ||
exports.setter = setter; | ||
exports.toPath = toPath; | ||
exports.updateIn = updateIn; | ||
exports.updater = updater; | ||
exports.updateIn = updateIn; | ||
exports.deleteIn = deleteIn; | ||
exports.mutator = mutator; | ||
exports.mutIn = mutIn; | ||
exports.mutInMany = mutInMany; | ||
@@ -224,0 +225,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
{ | ||
"name": "@thi.ng/paths", | ||
"version": "2.0.6", | ||
"version": "2.0.7", | ||
"description": "immutable, optimized path-based object property / array accessors", | ||
@@ -35,4 +35,4 @@ "module": "./index.js", | ||
"dependencies": { | ||
"@thi.ng/checks": "^2.1.3", | ||
"@thi.ng/errors": "^1.0.3" | ||
"@thi.ng/checks": "^2.1.4", | ||
"@thi.ng/errors": "^1.0.4" | ||
}, | ||
@@ -65,3 +65,3 @@ "keywords": [ | ||
"sideEffects": false, | ||
"gitHead": "b032167da28b83e93d3cbc54a47b053092ad7c4f" | ||
"gitHead": "1936d357f46f46d0435e3c7597b845898a91b80d" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1110
71665
Updated@thi.ng/checks@^2.1.4
Updated@thi.ng/errors@^1.0.4