@tolki/path 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3 -36
- package/dist/path.js +467 -656
- package/dist/pluck.js +48 -62
- package/package.json +7 -5
package/dist/pluck.js
CHANGED
|
@@ -1,62 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return f(n) && !b(n) && l(n.offsetExists) && l(n.offsetGet);
|
|
50
|
-
}
|
|
51
|
-
function y(n) {
|
|
52
|
-
return f(n) && !b(n) && l(n.all);
|
|
53
|
-
}
|
|
54
|
-
export {
|
|
55
|
-
G as explodePluckPath,
|
|
56
|
-
E as getPluckWildcardValues,
|
|
57
|
-
w as hasPluckPath,
|
|
58
|
-
K as isArrayAccess,
|
|
59
|
-
y as isEnumerable,
|
|
60
|
-
F as readPluckKey,
|
|
61
|
-
d as resolvePluckPath
|
|
62
|
-
};
|
|
1
|
+
import { isArray as e, isFunction as t, isMap as n, isNull as r, isNumber as i, isObject as a, isPhpFalsy as o, isPlainObject as s, isUndefined as c, keyedEntries as l, phpArrayKey as u, readMapKey as d } from "@tolki/utils";
|
|
2
|
+
// src/pluck.ts
|
|
3
|
+
var f = Symbol("absent");
|
|
4
|
+
function p(t) {
|
|
5
|
+
return e(t) ? t : n(t) ? l(t).map(([, e]) => e) : Object.values(t);
|
|
6
|
+
}
|
|
7
|
+
function m(t, n) {
|
|
8
|
+
if (n.length === 0) return t;
|
|
9
|
+
let [r, ...i] = n;
|
|
10
|
+
if (r === "*") {
|
|
11
|
+
let n = b(t) ? t.all() : t;
|
|
12
|
+
return !e(n) && !a(n) ? null : p(n).map((e) => m(e, i));
|
|
13
|
+
}
|
|
14
|
+
let o = v(t, r);
|
|
15
|
+
return o === f || c(o) ? null : m(o, i);
|
|
16
|
+
}
|
|
17
|
+
function h(e, t) {
|
|
18
|
+
if (t.length === 0) return !1;
|
|
19
|
+
let n = e;
|
|
20
|
+
for (let e of t) if (n = v(n, e), n === f) return !1;
|
|
21
|
+
return !0;
|
|
22
|
+
}
|
|
23
|
+
function g(e, t) {
|
|
24
|
+
let n = v(e, t);
|
|
25
|
+
return n === f ? [!1, void 0] : [!0, n];
|
|
26
|
+
}
|
|
27
|
+
function _(t) {
|
|
28
|
+
return r(t) ? [] : e(t) ? [...t] : String(t).split(".");
|
|
29
|
+
}
|
|
30
|
+
function v(t, r) {
|
|
31
|
+
if (e(t)) {
|
|
32
|
+
let e = u(r);
|
|
33
|
+
return i(e) && Object.hasOwn(t, e) ? t[e] : f;
|
|
34
|
+
}
|
|
35
|
+
if (!a(t)) return f;
|
|
36
|
+
if (n(t)) {
|
|
37
|
+
let e = d(t, r);
|
|
38
|
+
return e.found ? e.value : f;
|
|
39
|
+
}
|
|
40
|
+
return y(t) ? (b(t) ? v(t.all(), r) !== f : !o(t.offsetExists(r))) ? t.offsetGet(r) : f : Object.hasOwn(t, r) ? t[r] : f;
|
|
41
|
+
}
|
|
42
|
+
function y(e) {
|
|
43
|
+
return a(e) && !s(e) && t(e.offsetExists) && t(e.offsetGet);
|
|
44
|
+
}
|
|
45
|
+
function b(e) {
|
|
46
|
+
return a(e) && !s(e) && t(e.all);
|
|
47
|
+
}
|
|
48
|
+
export { _ as explodePluckPath, p as getPluckWildcardValues, h as hasPluckPath, y as isArrayAccess, b as isEnumerable, g as readPluckKey, m as resolvePluckPath };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tolki/path",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Utilities for working with path-based operations across arrays/objects.",
|
|
5
5
|
"author": "Abraham Arango <https://github.com/abetwothree>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"dot-notation"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@tolki/utils": "^1.6.
|
|
26
|
-
"@tolki/types": "^1.
|
|
25
|
+
"@tolki/utils": "^1.6.3",
|
|
26
|
+
"@tolki/types": "^1.11.0"
|
|
27
27
|
},
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"files": [
|
|
@@ -40,12 +40,14 @@
|
|
|
40
40
|
"types": "./dist/index.d.ts"
|
|
41
41
|
},
|
|
42
42
|
"./path": {
|
|
43
|
+
"types": "./dist/path.d.ts",
|
|
43
44
|
"import": "./dist/path.js",
|
|
44
|
-
"
|
|
45
|
+
"default": "./dist/path.js"
|
|
45
46
|
},
|
|
46
47
|
"./pluck": {
|
|
48
|
+
"types": "./dist/pluck.d.ts",
|
|
47
49
|
"import": "./dist/pluck.js",
|
|
48
|
-
"
|
|
50
|
+
"default": "./dist/pluck.js"
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
}
|