Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@thi.ng/paths

Package Overview
Dependencies
Maintainers
1
Versions
199
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/paths - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

## [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)

@@ -8,0 +16,0 @@

118

index.js

@@ -5,5 +5,5 @@ import { isString } from "@thi.ng/checks";

const iss = isString;
const _copy = (s) => isa(s) ? s.slice() : Object.assign({}, s);
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 _copy = (s) => (isa(s) ? s.slice() : Object.assign({}, s));
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);
/**

@@ -25,11 +25,11 @@ * Converts the given key path to canonical form (array).

*/
export const toPath = (path) => isa(path) ?
path :
iss(path) ?
path.length > 0 ?
path.split(".") :
[] :
path != null ?
[path] :
[];
export const toPath = (path) => isa(path)
? path
: iss(path)
? path.length > 0
? path.split(".")
: []
: path != null
? [path]
: [];
/**

@@ -98,12 +98,26 @@ * Takes an arbitrary object and lookup path. Descends into object along

case 1:
return (s) => s ? s[a] : undefined;
return (s) => (s ? s[a] : undefined);
case 2:
return (s) => s ? (s = s[a]) ? s[b] : undefined : undefined;
return (s) => (s ? ((s = s[a]) ? s[b] : undefined) : undefined);
case 3:
return (s) => s ? (s = s[a]) ? (s = s[b]) ? s[c] : undefined : undefined : undefined;
return (s) => s
? (s = s[a])
? (s = s[b])
? s[c]
: undefined
: undefined
: undefined;
case 4:
return (s) => s ? (s = s[a]) ? (s = s[b]) ? (s = s[c]) ? s[d] : undefined : undefined : undefined : undefined;
return (s) => s
? (s = s[a])
? (s = s[b])
? (s = s[c])
? s[d]
: undefined
: undefined
: undefined
: undefined;
default:
const kl = ks[ks.length - 1];
let f = (s) => s ? s[kl] : undefined;
let f = (s) => (s ? s[kl] : undefined);
for (let i = ks.length - 1; --i >= 0;) {

@@ -175,9 +189,30 @@ f = compG(ks[i], f);

case 1:
return (s, v) => (s = _copy(s), s[a] = v, s);
return (s, v) => ((s = _copy(s)), (s[a] = v), s);
case 2:
return (s, v) => { let x; s = _copy(s); s[a] = x = _copy(s[a]); x[b] = v; return s; };
return (s, v) => {
let x;
s = _copy(s);
s[a] = x = _copy(s[a]);
x[b] = v;
return s;
};
case 3:
return (s, v) => { let x, y; s = _copy(s); s[a] = x = _copy(s[a]); x[b] = y = _copy(x[b]); y[c] = v; return s; };
return (s, v) => {
let x, y;
s = _copy(s);
s[a] = x = _copy(s[a]);
x[b] = y = _copy(x[b]);
y[c] = v;
return s;
};
case 4:
return (s, v) => { let x, y, z; s = _copy(s); s[a] = x = _copy(s[a]); x[b] = y = _copy(x[b]); y[c] = z = _copy(y[c]); z[d] = v; return s; };
return (s, v) => {
let x, y, z;
s = _copy(s);
s[a] = x = _copy(s[a]);
x[b] = y = _copy(x[b]);
y[c] = z = _copy(y[c]);
z[d] = v;
return s;
};
default:

@@ -231,3 +266,3 @@ let f;

const n = pairs.length;
(n & 1) && illegalArgs(`require even number of args (got ${pairs.length})`);
n & 1 && illegalArgs(`require even number of args (got ${pairs.length})`);
for (let i = 0; i < n; i += 2) {

@@ -295,3 +330,3 @@ state = setIn(state, pairs[i], pairs[i + 1]);

const k = ks.pop();
return updateIn(state, ks, (x) => (x = Object.assign({}, x), delete x[k], x));
return updateIn(state, ks, (x) => ((x = Object.assign({}, x)), delete x[k], x));
}

@@ -317,9 +352,36 @@ };

case 1:
return (s, x) => s ? (s[a] = x, s) : undefined;
return (s, x) => (s ? ((s[a] = x), s) : undefined);
case 2:
return (s, x) => { let t; return s ? (t = s[a]) ? (t[b] = x, s) : undefined : undefined; };
return (s, x) => {
let t;
return s
? (t = s[a])
? ((t[b] = x), s)
: undefined
: undefined;
};
case 3:
return (s, x) => { let t; return s ? (t = s[a]) ? (t = t[b]) ? (t[c] = x, s) : undefined : undefined : undefined; };
return (s, x) => {
let t;
return s
? (t = s[a])
? (t = t[b])
? ((t[c] = x), s)
: undefined
: undefined
: undefined;
};
case 4:
return (s, x) => { let t; return s ? (t = s[a]) ? (t = t[b]) ? (t = t[c]) ? (t[d] = x, s) : undefined : undefined : undefined : undefined; };
return (s, x) => {
let t;
return s
? (t = s[a])
? (t = t[b])
? (t = t[c])
? ((t[d] = x), s)
: undefined
: undefined
: undefined
: undefined;
};
default:

@@ -370,3 +432,3 @@ return (s, x) => {

const n = pairs.length;
(n & 1) && illegalArgs(`require even number of args (got ${pairs.length})`);
n & 1 && illegalArgs(`require even number of args (got ${pairs.length})`);
for (let i = 0; i < n && state; i += 2) {

@@ -373,0 +435,0 @@ state = mutIn(state, pairs[i], pairs[i + 1]);

@@ -10,14 +10,14 @@ 'use strict';

const iss = checks.isString;
const _copy = (s) => isa(s) ? s.slice() : Object.assign({}, s);
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) ?
path :
iss(path) ?
path.length > 0 ?
path.split(".") :
[] :
path != null ?
[path] :
[];
const _copy = (s) => (isa(s) ? s.slice() : Object.assign({}, s));
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)
? path
: iss(path)
? path.length > 0
? path.split(".")
: []
: path != null
? [path]
: [];
const exists = (obj, path) => {

@@ -47,12 +47,26 @@ if (obj == null) {

case 1:
return (s) => s ? s[a] : undefined;
return (s) => (s ? s[a] : undefined);
case 2:
return (s) => s ? (s = s[a]) ? s[b] : undefined : undefined;
return (s) => (s ? ((s = s[a]) ? s[b] : undefined) : undefined);
case 3:
return (s) => s ? (s = s[a]) ? (s = s[b]) ? s[c] : undefined : undefined : undefined;
return (s) => s
? (s = s[a])
? (s = s[b])
? s[c]
: undefined
: undefined
: undefined;
case 4:
return (s) => s ? (s = s[a]) ? (s = s[b]) ? (s = s[c]) ? s[d] : undefined : undefined : undefined : undefined;
return (s) => s
? (s = s[a])
? (s = s[b])
? (s = s[c])
? s[d]
: undefined
: undefined
: undefined
: undefined;
default:
const kl = ks[ks.length - 1];
let f = (s) => s ? s[kl] : undefined;
let f = (s) => (s ? s[kl] : undefined);
for (let i = ks.length - 1; --i >= 0;) {

@@ -71,9 +85,30 @@ f = compG(ks[i], f);

case 1:
return (s, v) => (s = _copy(s), s[a] = v, s);
return (s, v) => ((s = _copy(s)), (s[a] = v), s);
case 2:
return (s, v) => { let x; s = _copy(s); s[a] = x = _copy(s[a]); x[b] = v; return s; };
return (s, v) => {
let x;
s = _copy(s);
s[a] = x = _copy(s[a]);
x[b] = v;
return s;
};
case 3:
return (s, v) => { let x, y; s = _copy(s); s[a] = x = _copy(s[a]); x[b] = y = _copy(x[b]); y[c] = v; return s; };
return (s, v) => {
let x, y;
s = _copy(s);
s[a] = x = _copy(s[a]);
x[b] = y = _copy(x[b]);
y[c] = v;
return s;
};
case 4:
return (s, v) => { let x, y, z; s = _copy(s); s[a] = x = _copy(s[a]); x[b] = y = _copy(x[b]); y[c] = z = _copy(y[c]); z[d] = v; return s; };
return (s, v) => {
let x, y, z;
s = _copy(s);
s[a] = x = _copy(s[a]);
x[b] = y = _copy(x[b]);
y[c] = z = _copy(y[c]);
z[d] = v;
return s;
};
default:

@@ -91,3 +126,3 @@ let f;

const n = pairs.length;
(n & 1) && errors.illegalArgs(`require even number of args (got ${pairs.length})`);
n & 1 && errors.illegalArgs(`require even number of args (got ${pairs.length})`);
for (let i = 0; i < n; i += 2) {

@@ -108,3 +143,3 @@ state = setIn(state, pairs[i], pairs[i + 1]);

const k = ks.pop();
return updateIn(state, ks, (x) => (x = Object.assign({}, x), delete x[k], x));
return updateIn(state, ks, (x) => ((x = Object.assign({}, x)), delete x[k], x));
}

@@ -119,9 +154,36 @@ };

case 1:
return (s, x) => s ? (s[a] = x, s) : undefined;
return (s, x) => (s ? ((s[a] = x), s) : undefined);
case 2:
return (s, x) => { let t; return s ? (t = s[a]) ? (t[b] = x, s) : undefined : undefined; };
return (s, x) => {
let t;
return s
? (t = s[a])
? ((t[b] = x), s)
: undefined
: undefined;
};
case 3:
return (s, x) => { let t; return s ? (t = s[a]) ? (t = t[b]) ? (t[c] = x, s) : undefined : undefined : undefined; };
return (s, x) => {
let t;
return s
? (t = s[a])
? (t = t[b])
? ((t[c] = x), s)
: undefined
: undefined
: undefined;
};
case 4:
return (s, x) => { let t; return s ? (t = s[a]) ? (t = t[b]) ? (t = t[c]) ? (t[d] = x, s) : undefined : undefined : undefined : undefined; };
return (s, x) => {
let t;
return s
? (t = s[a])
? (t = t[b])
? (t = t[c])
? ((t[d] = x), s)
: undefined
: undefined
: undefined
: undefined;
};
default:

@@ -143,3 +205,3 @@ return (s, x) => {

const n = pairs.length;
(n & 1) && errors.illegalArgs(`require even number of args (got ${pairs.length})`);
n & 1 && errors.illegalArgs(`require even number of args (got ${pairs.length})`);
for (let i = 0; i < n && state; i += 2) {

@@ -146,0 +208,0 @@ state = mutIn(state, pairs[i], pairs[i + 1]);

@@ -9,14 +9,14 @@ (function (global, factory) {

const iss = checks.isString;
const _copy = (s) => isa(s) ? s.slice() : Object.assign({}, s);
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) ?
path :
iss(path) ?
path.length > 0 ?
path.split(".") :
[] :
path != null ?
[path] :
[];
const _copy = (s) => (isa(s) ? s.slice() : Object.assign({}, s));
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)
? path
: iss(path)
? path.length > 0
? path.split(".")
: []
: path != null
? [path]
: [];
const exists = (obj, path) => {

@@ -46,12 +46,26 @@ if (obj == null) {

case 1:
return (s) => s ? s[a] : undefined;
return (s) => (s ? s[a] : undefined);
case 2:
return (s) => s ? (s = s[a]) ? s[b] : undefined : undefined;
return (s) => (s ? ((s = s[a]) ? s[b] : undefined) : undefined);
case 3:
return (s) => s ? (s = s[a]) ? (s = s[b]) ? s[c] : undefined : undefined : undefined;
return (s) => s
? (s = s[a])
? (s = s[b])
? s[c]
: undefined
: undefined
: undefined;
case 4:
return (s) => s ? (s = s[a]) ? (s = s[b]) ? (s = s[c]) ? s[d] : undefined : undefined : undefined : undefined;
return (s) => s
? (s = s[a])
? (s = s[b])
? (s = s[c])
? s[d]
: undefined
: undefined
: undefined
: undefined;
default:
const kl = ks[ks.length - 1];
let f = (s) => s ? s[kl] : undefined;
let f = (s) => (s ? s[kl] : undefined);
for (let i = ks.length - 1; --i >= 0;) {

@@ -70,9 +84,30 @@ f = compG(ks[i], f);

case 1:
return (s, v) => (s = _copy(s), s[a] = v, s);
return (s, v) => ((s = _copy(s)), (s[a] = v), s);
case 2:
return (s, v) => { let x; s = _copy(s); s[a] = x = _copy(s[a]); x[b] = v; return s; };
return (s, v) => {
let x;
s = _copy(s);
s[a] = x = _copy(s[a]);
x[b] = v;
return s;
};
case 3:
return (s, v) => { let x, y; s = _copy(s); s[a] = x = _copy(s[a]); x[b] = y = _copy(x[b]); y[c] = v; return s; };
return (s, v) => {
let x, y;
s = _copy(s);
s[a] = x = _copy(s[a]);
x[b] = y = _copy(x[b]);
y[c] = v;
return s;
};
case 4:
return (s, v) => { let x, y, z; s = _copy(s); s[a] = x = _copy(s[a]); x[b] = y = _copy(x[b]); y[c] = z = _copy(y[c]); z[d] = v; return s; };
return (s, v) => {
let x, y, z;
s = _copy(s);
s[a] = x = _copy(s[a]);
x[b] = y = _copy(x[b]);
y[c] = z = _copy(y[c]);
z[d] = v;
return s;
};
default:

@@ -90,3 +125,3 @@ let f;

const n = pairs.length;
(n & 1) && errors.illegalArgs(`require even number of args (got ${pairs.length})`);
n & 1 && errors.illegalArgs(`require even number of args (got ${pairs.length})`);
for (let i = 0; i < n; i += 2) {

@@ -107,3 +142,3 @@ state = setIn(state, pairs[i], pairs[i + 1]);

const k = ks.pop();
return updateIn(state, ks, (x) => (x = Object.assign({}, x), delete x[k], x));
return updateIn(state, ks, (x) => ((x = Object.assign({}, x)), delete x[k], x));
}

@@ -118,9 +153,36 @@ };

case 1:
return (s, x) => s ? (s[a] = x, s) : undefined;
return (s, x) => (s ? ((s[a] = x), s) : undefined);
case 2:
return (s, x) => { let t; return s ? (t = s[a]) ? (t[b] = x, s) : undefined : undefined; };
return (s, x) => {
let t;
return s
? (t = s[a])
? ((t[b] = x), s)
: undefined
: undefined;
};
case 3:
return (s, x) => { let t; return s ? (t = s[a]) ? (t = t[b]) ? (t[c] = x, s) : undefined : undefined : undefined; };
return (s, x) => {
let t;
return s
? (t = s[a])
? (t = t[b])
? ((t[c] = x), s)
: undefined
: undefined
: undefined;
};
case 4:
return (s, x) => { let t; return s ? (t = s[a]) ? (t = t[b]) ? (t = t[c]) ? (t[d] = x, s) : undefined : undefined : undefined : undefined; };
return (s, x) => {
let t;
return s
? (t = s[a])
? (t = t[b])
? (t = t[c])
? ((t[d] = x), s)
: undefined
: undefined
: undefined
: undefined;
};
default:

@@ -142,3 +204,3 @@ return (s, x) => {

const n = pairs.length;
(n & 1) && errors.illegalArgs(`require even number of args (got ${pairs.length})`);
n & 1 && errors.illegalArgs(`require even number of args (got ${pairs.length})`);
for (let i = 0; i < n && state; i += 2) {

@@ -145,0 +207,0 @@ state = mutIn(state, pairs[i], pairs[i + 1]);

{
"name": "@thi.ng/paths",
"version": "2.0.3",
"version": "2.0.4",
"description": "immutable, optimized path-based object property / array accessors",

@@ -35,4 +35,4 @@ "module": "./index.js",

"dependencies": {
"@thi.ng/checks": "^2.1.0",
"@thi.ng/errors": "^1.0.2"
"@thi.ng/checks": "^2.1.1",
"@thi.ng/errors": "^1.0.3"
},

@@ -65,3 +65,3 @@ "keywords": [

"sideEffects": false,
"gitHead": "7e875d4a030b08c183c43ad1ab54a8dd9843f358"
"gitHead": "e43f57c7554fd78380bba58d37ae62ca01221eeb"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc