@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/path.js
CHANGED
|
@@ -1,684 +1,495 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const l = b(t);
|
|
17
|
-
s.push(m(l) && l >= 0 ? l : t);
|
|
18
|
-
}
|
|
19
|
-
return s;
|
|
1
|
+
import { InvalidArgumentException as e, arrayKeyExistsError as t, arrayValueMessage as n, castableToArray as r, defineKey as i, deleteMapKey as a, isArray as o, isFloat as s, isFunction as c, isIllegalOffset as l, isInteger as u, isIntegerLikeKey as d, isMap as f, isNull as p, isNumber as m, isObject as h, isObjectAny as g, isPlainObject as _, isPrototypeObject as v, isString as y, isUndefined as b, isUnsafeKey as x, keyedEntries as S, nextIntegerKey as C, phpArrayKey as w, readMapKey as T, toPhpKeyString as ee, writeMapKey as E } from "@tolki/utils";
|
|
2
|
+
// src/path.ts
|
|
3
|
+
function D(e) {
|
|
4
|
+
if (p(e) || b(e)) return [];
|
|
5
|
+
if (!m(e) && Number.isNaN(e)) return null;
|
|
6
|
+
if (m(e)) return u(e) && e >= 0 ? [e] : null;
|
|
7
|
+
let t = String(e);
|
|
8
|
+
if (t.length === 0) return [];
|
|
9
|
+
let n = t.split("."), r = [];
|
|
10
|
+
for (let e of n) {
|
|
11
|
+
if (e.length === 0) return null;
|
|
12
|
+
let t = w(e);
|
|
13
|
+
r.push(m(t) && t >= 0 ? t : e);
|
|
14
|
+
}
|
|
15
|
+
return r;
|
|
20
16
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (!l.found)
|
|
38
|
-
return !1;
|
|
39
|
-
s = l.value;
|
|
40
|
-
} else if (x(s) && Object.hasOwn(s, String(t)))
|
|
41
|
-
s = s[String(t)];
|
|
42
|
-
else
|
|
43
|
-
return !1;
|
|
44
|
-
return !0;
|
|
17
|
+
function O(e, t) {
|
|
18
|
+
if (p(t)) return !1;
|
|
19
|
+
if (m(t)) return o(e) ? u(t) && t >= 0 && t < e.length : !p(e) && h(e) && $(e, String(t)).found;
|
|
20
|
+
let n = D(t);
|
|
21
|
+
if (!n || n.length === 0) return !1;
|
|
22
|
+
let r = e;
|
|
23
|
+
for (let e of n) if (o(r)) {
|
|
24
|
+
if (!m(e) || e >= r.length) return !1;
|
|
25
|
+
r = r[e];
|
|
26
|
+
} else if (f(r)) {
|
|
27
|
+
let t = T(r, e);
|
|
28
|
+
if (!t.found) return !1;
|
|
29
|
+
r = t.value;
|
|
30
|
+
} else if (h(r) && Object.hasOwn(r, String(e))) r = r[String(e)];
|
|
31
|
+
else return !1;
|
|
32
|
+
return !0;
|
|
45
33
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
34
|
+
function k(e, t) {
|
|
35
|
+
if (p(t) || b(t)) return {
|
|
36
|
+
found: !0,
|
|
37
|
+
value: e
|
|
38
|
+
};
|
|
39
|
+
if (m(t)) return o(e) ? !u(t) || t < 0 || t >= e.length ? { found: !1 } : {
|
|
40
|
+
found: !0,
|
|
41
|
+
value: e[t]
|
|
42
|
+
} : !p(e) && h(e) ? $(e, String(t)) : { found: !1 };
|
|
43
|
+
let n = D(t);
|
|
44
|
+
if (!n || n.length === 0) return { found: !1 };
|
|
45
|
+
let r = e;
|
|
46
|
+
for (let e of n) if (o(r)) {
|
|
47
|
+
if (!m(e) || e >= r.length) return { found: !1 };
|
|
48
|
+
r = r[e];
|
|
49
|
+
} else if (f(r)) {
|
|
50
|
+
let t = T(r, e);
|
|
51
|
+
if (!t.found) return { found: !1 };
|
|
52
|
+
r = t.value;
|
|
53
|
+
} else if (h(r) && Object.hasOwn(r, String(e))) r = r[String(e)];
|
|
54
|
+
else return { found: !1 };
|
|
55
|
+
return {
|
|
56
|
+
found: !0,
|
|
57
|
+
value: r
|
|
58
|
+
};
|
|
70
59
|
}
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return x(n) ? k(n, e) : nn(n, e);
|
|
60
|
+
function A(e, n) {
|
|
61
|
+
if ((o(n) ? n : [n]).some(l)) throw t();
|
|
62
|
+
return h(e) ? j(e, n) : M(e, n);
|
|
75
63
|
}
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const d = t(g, r);
|
|
127
|
-
p(d) || r.splice(d, 1);
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
if (O(r)) {
|
|
131
|
-
_(r, g);
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
delete r[g];
|
|
135
|
-
};
|
|
136
|
-
for (const f of u) {
|
|
137
|
-
const o = z(f);
|
|
138
|
-
c(o, X(f) ? String(b(f)) : o);
|
|
139
|
-
}
|
|
140
|
-
return s;
|
|
64
|
+
function j(e, t) {
|
|
65
|
+
let n = p(t) || b(t) ? [] : o(t) ? t : [t], r = { ...e }, i = (e, t) => {
|
|
66
|
+
let n = w(e);
|
|
67
|
+
return !u(n) || n < 0 || n >= t.length ? null : n;
|
|
68
|
+
}, c = (e) => {
|
|
69
|
+
if (o(e)) return e.slice();
|
|
70
|
+
if (f(e)) return new Map(e);
|
|
71
|
+
if (h(e)) {
|
|
72
|
+
let t = Object.getPrototypeOf(e);
|
|
73
|
+
if (t === Object.prototype || p(t)) return { ...e };
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}, l = (e, t) => {
|
|
77
|
+
if (Object.hasOwn(r, e)) {
|
|
78
|
+
delete r[t];
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
let n = e.split("."), s = r;
|
|
82
|
+
for (; n.length > 1;) {
|
|
83
|
+
let e = n.shift();
|
|
84
|
+
if (o(s)) {
|
|
85
|
+
let t = i(e, s);
|
|
86
|
+
if (p(t)) return;
|
|
87
|
+
let n = c(s[t]);
|
|
88
|
+
if (p(n)) return;
|
|
89
|
+
s[t] = n, s = n;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (f(s)) {
|
|
93
|
+
let t = T(s, e), n = t.found ? c(t.value) : null;
|
|
94
|
+
if (p(n)) return;
|
|
95
|
+
E(s, e, n), s = n;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (!Object.hasOwn(s, e)) return;
|
|
99
|
+
let t = c(s[e]);
|
|
100
|
+
if (p(t)) return;
|
|
101
|
+
s[e] = t, s = t;
|
|
102
|
+
}
|
|
103
|
+
let l = n.shift();
|
|
104
|
+
if (o(s)) {
|
|
105
|
+
let e = i(l, s);
|
|
106
|
+
p(e) || s.splice(e, 1);
|
|
107
|
+
} else f(s) ? a(s, l) : delete s[l];
|
|
108
|
+
};
|
|
109
|
+
for (let e of n) {
|
|
110
|
+
let t = Q(e);
|
|
111
|
+
l(t, s(e) ? String(w(e)) : t);
|
|
112
|
+
}
|
|
113
|
+
return r;
|
|
141
114
|
}
|
|
142
|
-
function
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const i = [...f].filter((r) => m(r) && r >= 0).sort((r, g) => g - r);
|
|
178
|
-
for (const r of i)
|
|
179
|
-
o.splice(r, 1);
|
|
180
|
-
} else if (O(o))
|
|
181
|
-
for (const i of f)
|
|
182
|
-
_(o, i);
|
|
183
|
-
else if (!p(o))
|
|
184
|
-
for (const i of f)
|
|
185
|
-
delete o[i];
|
|
186
|
-
}
|
|
187
|
-
return u;
|
|
115
|
+
function M(e, t) {
|
|
116
|
+
let n = e.slice();
|
|
117
|
+
if (p(t)) return n;
|
|
118
|
+
let r = (e) => {
|
|
119
|
+
let t = n;
|
|
120
|
+
for (let n of e) {
|
|
121
|
+
let e;
|
|
122
|
+
if (o(t)) e = m(n) && n >= 0 ? t[n] : void 0;
|
|
123
|
+
else if (f(t)) {
|
|
124
|
+
let r = T(t, n);
|
|
125
|
+
e = r.found ? r.value : void 0;
|
|
126
|
+
} else Object.hasOwn(t, n) && (e = t[n]);
|
|
127
|
+
if (!o(e) && !_(e) && !f(e) || v(e)) return null;
|
|
128
|
+
let r = o(e) ? e.slice() : f(e) ? new Map(e) : { ...e };
|
|
129
|
+
f(t) ? E(t, n, r) : i(t, n, r), t = r;
|
|
130
|
+
}
|
|
131
|
+
return t;
|
|
132
|
+
}, s = /* @__PURE__ */ new Map();
|
|
133
|
+
for (let e of o(t) ? t : [t]) {
|
|
134
|
+
let t = u(e) ? [e] : Q(e).split(".").map(w), n = t.slice(0, -1), r = JSON.stringify(n), i = s.get(r) ?? {
|
|
135
|
+
parent: n,
|
|
136
|
+
leaves: /* @__PURE__ */ new Set()
|
|
137
|
+
};
|
|
138
|
+
i.leaves.add(t[n.length]), s.set(r, i);
|
|
139
|
+
}
|
|
140
|
+
let c = [...s.values()].sort((e, t) => t.parent.length - e.parent.length);
|
|
141
|
+
for (let { parent: e, leaves: t } of c) {
|
|
142
|
+
let n = r(e);
|
|
143
|
+
if (o(n)) {
|
|
144
|
+
let e = [...t].filter((e) => m(e) && e >= 0).sort((e, t) => t - e);
|
|
145
|
+
for (let t of e) n.splice(t, 1);
|
|
146
|
+
} else if (f(n)) for (let e of t) a(n, e);
|
|
147
|
+
else if (!p(n)) for (let e of t) delete n[e];
|
|
148
|
+
}
|
|
149
|
+
return n;
|
|
188
150
|
}
|
|
189
|
-
function
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
if (h(S)) {
|
|
229
|
-
const w = S.slice();
|
|
230
|
-
o[d] = w, o = w;
|
|
231
|
-
continue;
|
|
232
|
-
}
|
|
233
|
-
return s;
|
|
234
|
-
}
|
|
235
|
-
return f;
|
|
151
|
+
function N(e, t, n) {
|
|
152
|
+
if (p(t)) return n;
|
|
153
|
+
if (!o(e)) return [];
|
|
154
|
+
let r = e.slice(), i = (e, t) => e > t ? t : e;
|
|
155
|
+
if (m(t) || y(t) && t.indexOf(".") === -1) {
|
|
156
|
+
let e = m(t) ? t : w(t);
|
|
157
|
+
if (!u(e) || e < 0) return r;
|
|
158
|
+
let a = i(e, r.length), o = r.slice();
|
|
159
|
+
return a === o.length ? o.push(n) : o[a] = n, o;
|
|
160
|
+
}
|
|
161
|
+
let a = String(t).split("."), s = [];
|
|
162
|
+
for (let e of a) {
|
|
163
|
+
let t = w(e);
|
|
164
|
+
if (!u(t) || t < 0) return r;
|
|
165
|
+
s.push(t);
|
|
166
|
+
}
|
|
167
|
+
let c = r.slice(), l = c;
|
|
168
|
+
for (let e = 0; e < s.length; e++) {
|
|
169
|
+
let t = s[e], a = e === s.length - 1, c = i(t, l.length);
|
|
170
|
+
if (a) {
|
|
171
|
+
c === l.length ? l.push(n) : l[c] = n;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
if (c === l.length) {
|
|
175
|
+
let e = [];
|
|
176
|
+
l.push(e), l = e;
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
let u = l[c];
|
|
180
|
+
if (p(u)) {
|
|
181
|
+
let e = [];
|
|
182
|
+
l[c] = e, l = e;
|
|
183
|
+
} else if (o(u)) {
|
|
184
|
+
let e = u.slice();
|
|
185
|
+
l[c] = e, l = e;
|
|
186
|
+
} else return r;
|
|
187
|
+
}
|
|
188
|
+
return c;
|
|
236
189
|
}
|
|
237
|
-
function
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
190
|
+
function P(t, r, ...a) {
|
|
191
|
+
let s = o(t) && !v(t) ? t : [];
|
|
192
|
+
if (p(r) || b(r)) return s.push(...a), s;
|
|
193
|
+
let c = D(r);
|
|
194
|
+
if (!c || c.length === 0) return s;
|
|
195
|
+
let l = (e, t) => {
|
|
196
|
+
if (o(e)) {
|
|
197
|
+
if (!m(t)) return null;
|
|
198
|
+
let n = Math.min(t, e.length);
|
|
199
|
+
return n < e.length ? {
|
|
200
|
+
slot: n,
|
|
201
|
+
found: !0,
|
|
202
|
+
value: e[n]
|
|
203
|
+
} : {
|
|
204
|
+
slot: n,
|
|
205
|
+
found: !1
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
if (f(e)) return {
|
|
209
|
+
slot: t,
|
|
210
|
+
...T(e, t)
|
|
211
|
+
};
|
|
212
|
+
let n = String(t);
|
|
213
|
+
return Object.hasOwn(e, n) ? {
|
|
214
|
+
slot: n,
|
|
215
|
+
found: !0,
|
|
216
|
+
value: e[n]
|
|
217
|
+
} : {
|
|
218
|
+
slot: n,
|
|
219
|
+
found: !1
|
|
220
|
+
};
|
|
221
|
+
}, u = (e, t, n) => {
|
|
222
|
+
f(e) ? E(e, t, n) : i(e, t, n);
|
|
223
|
+
}, d = s;
|
|
224
|
+
for (let [e, t] of c.slice(0, -1).entries()) {
|
|
225
|
+
let n = l(d, t);
|
|
226
|
+
if (p(n)) return s;
|
|
227
|
+
let r = n.value;
|
|
228
|
+
if (v(r)) return s;
|
|
229
|
+
if (o(r) || _(r) || f(r)) {
|
|
230
|
+
d = r;
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
let i = m(c[e + 1]) ? [] : {};
|
|
234
|
+
u(d, n.slot, i), d = i;
|
|
235
|
+
}
|
|
236
|
+
let h = l(d, c[c.length - 1]);
|
|
237
|
+
if (p(h)) return s;
|
|
238
|
+
let g = h.found ? h.value : [];
|
|
239
|
+
if (h.found || u(d, h.slot, g), o(g)) return v(g) || g.push(...a), s;
|
|
240
|
+
if (f(g) || _(g) && !v(g)) {
|
|
241
|
+
let e = C(g);
|
|
242
|
+
for (let t of a) f(g) ? g.set(e++, t) : i(g, String(e++), t);
|
|
243
|
+
return s;
|
|
244
|
+
}
|
|
245
|
+
throw new e(n(g, r));
|
|
290
246
|
}
|
|
291
|
-
function
|
|
292
|
-
|
|
293
|
-
p(n) ? [] : [n],
|
|
294
|
-
e,
|
|
295
|
-
u
|
|
296
|
-
);
|
|
247
|
+
function F(e, t = "", n = Infinity) {
|
|
248
|
+
return h(e) ? I(e, t, n) : o(e) ? L(e, t, n) : L(p(e) ? [] : [e], t, n);
|
|
297
249
|
}
|
|
298
|
-
function
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
f + 1
|
|
308
|
-
) : f < u && (N(i) && Object.keys(i).length > 0 || O(i) && P(i).length > 0) ? t(
|
|
309
|
-
i,
|
|
310
|
-
`${r}.`,
|
|
311
|
-
f + 1
|
|
312
|
-
) : v(s, r, i);
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
return t(n, e, 0), s;
|
|
250
|
+
function I(e, t = "", n = Infinity) {
|
|
251
|
+
if (!h(e)) return {};
|
|
252
|
+
let r = {}, a = (e, t, s) => {
|
|
253
|
+
for (let [c, l] of S(e)) {
|
|
254
|
+
let e = `${t}${String(c)}`;
|
|
255
|
+
s < n && o(l) && l.length > 0 || s < n && (_(l) && Object.keys(l).length > 0 || f(l) && S(l).length > 0) ? a(l, `${e}.`, s + 1) : i(r, e, l);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
return a(e, t, 0), r;
|
|
316
259
|
}
|
|
317
|
-
function
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
r,
|
|
329
|
-
`${g}.`,
|
|
330
|
-
u - o - 1
|
|
331
|
-
)
|
|
332
|
-
))
|
|
333
|
-
v(
|
|
334
|
-
t,
|
|
335
|
-
d,
|
|
336
|
-
S
|
|
337
|
-
);
|
|
338
|
-
else
|
|
339
|
-
v(
|
|
340
|
-
t,
|
|
341
|
-
g,
|
|
342
|
-
r
|
|
343
|
-
);
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
return l(s, e, 0), t;
|
|
260
|
+
function L(e, t = "", n = Infinity) {
|
|
261
|
+
if (!o(e)) return {};
|
|
262
|
+
let r = e, a = {}, s = (e, t, r) => {
|
|
263
|
+
for (let c = 0; c < e.length; c++) {
|
|
264
|
+
let l = e[c], u = `${t}${c}`;
|
|
265
|
+
if (r < n && o(l) && l.length > 0) s(l, `${u}.`, r + 1);
|
|
266
|
+
else if (r < n && (_(l) && Object.keys(l).length > 0 || f(l) && S(l).length > 0)) for (let [e, t] of Object.entries(I(l, `${u}.`, n - r - 1))) i(a, e, t);
|
|
267
|
+
else i(a, u, l);
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
return s(r, t, 0), a;
|
|
347
271
|
}
|
|
348
|
-
function
|
|
349
|
-
|
|
272
|
+
function R(e) {
|
|
273
|
+
return h(e) ? B(e) : U(e);
|
|
350
274
|
}
|
|
351
|
-
function
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
continue;
|
|
362
|
-
const i = Object.keys(o);
|
|
363
|
-
i.length > 0 && i.every((g, d) => g === String(d)) && v(
|
|
364
|
-
f,
|
|
365
|
-
l,
|
|
366
|
-
i.map((g) => o[g])
|
|
367
|
-
);
|
|
368
|
-
}
|
|
275
|
+
function z(e, t) {
|
|
276
|
+
let n = [...t].sort((e, t) => t.split(".").length - e.split(".").length);
|
|
277
|
+
for (let t of n) {
|
|
278
|
+
let n = t.split("."), r = n[n.length - 1], a = n.slice(0, -1), o = a.length === 0 ? e : W(e, a.join("."));
|
|
279
|
+
if (!h(o)) continue;
|
|
280
|
+
let s = o[r];
|
|
281
|
+
if (!h(s)) continue;
|
|
282
|
+
let c = Object.keys(s);
|
|
283
|
+
c.length > 0 && c.every((e, t) => e === String(t)) && i(o, r, c.map((e) => s[e]));
|
|
284
|
+
}
|
|
369
285
|
}
|
|
370
|
-
function
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
return tn(
|
|
381
|
-
e,
|
|
382
|
-
u
|
|
383
|
-
), e;
|
|
286
|
+
function B(e) {
|
|
287
|
+
let t = {}, n = /* @__PURE__ */ new Set();
|
|
288
|
+
for (let [r, a] of S(e)) {
|
|
289
|
+
let e = Z(t, r, a);
|
|
290
|
+
for (let [n, r] of Object.entries(e)) i(t, n, r);
|
|
291
|
+
let o = r.split(".");
|
|
292
|
+
for (let e = 1; e < o.length; e++) n.add(o.slice(0, e).join("."));
|
|
293
|
+
}
|
|
294
|
+
return z(t, n), t;
|
|
384
295
|
}
|
|
385
|
-
|
|
386
|
-
function
|
|
387
|
-
|
|
296
|
+
var V = 2 ** 24 - 2;
|
|
297
|
+
function H(e) {
|
|
298
|
+
return d(e) && Number(e) <= V;
|
|
388
299
|
}
|
|
389
|
-
function
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
break;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
return e;
|
|
300
|
+
function U(e) {
|
|
301
|
+
let t = [];
|
|
302
|
+
for (let [n, r] of S(e ?? {})) {
|
|
303
|
+
if (n.length === 0) continue;
|
|
304
|
+
let e = n.split(".");
|
|
305
|
+
if (e.some((e) => !H(e))) continue;
|
|
306
|
+
let i = t;
|
|
307
|
+
for (let t = 0; t < e.length; t++) {
|
|
308
|
+
let n = Number(e[t]);
|
|
309
|
+
if (t === e.length - 1) i[n] = r;
|
|
310
|
+
else {
|
|
311
|
+
let e = i[n];
|
|
312
|
+
if (p(e) || b(e)) {
|
|
313
|
+
let e = [];
|
|
314
|
+
i[n] = e, i = e;
|
|
315
|
+
} else if (o(e)) i = e;
|
|
316
|
+
else break;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return t;
|
|
415
321
|
}
|
|
416
|
-
function
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
if (!Object.hasOwn(t, l))
|
|
436
|
-
return;
|
|
437
|
-
t = t[l];
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
return t;
|
|
322
|
+
function W(e, t) {
|
|
323
|
+
if (p(e) || b(e) || !g(e)) return;
|
|
324
|
+
let n = String(t).split("."), r = e;
|
|
325
|
+
for (let e of n) {
|
|
326
|
+
if (p(r) || b(r) || !g(r)) return;
|
|
327
|
+
if (o(r)) {
|
|
328
|
+
let t = w(e);
|
|
329
|
+
if (!m(t) || !Object.hasOwn(r, t)) return;
|
|
330
|
+
r = r[t];
|
|
331
|
+
} else if (f(r)) {
|
|
332
|
+
let t = T(r, e);
|
|
333
|
+
if (!t.found) return;
|
|
334
|
+
r = t.value;
|
|
335
|
+
} else {
|
|
336
|
+
if (!Object.hasOwn(r, e)) return;
|
|
337
|
+
r = r[e];
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return r;
|
|
441
341
|
}
|
|
442
|
-
function
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
return m(i) && i >= 0;
|
|
462
|
-
})) {
|
|
463
|
-
if (!h(n))
|
|
464
|
-
return s();
|
|
465
|
-
const o = F(n), { found: i, value: r } = U(o, e);
|
|
466
|
-
return i ? r : s();
|
|
467
|
-
}
|
|
468
|
-
const f = C(n, t);
|
|
469
|
-
return a(f) ? s() : f;
|
|
342
|
+
function G(e, t, n = null) {
|
|
343
|
+
let i = () => c(n) ? n() : n;
|
|
344
|
+
if (p(t)) return e;
|
|
345
|
+
if (m(t)) {
|
|
346
|
+
if (!o(e)) return i();
|
|
347
|
+
let { found: n, value: a } = k(r(e), t);
|
|
348
|
+
return n ? a : i();
|
|
349
|
+
}
|
|
350
|
+
let a = String(t);
|
|
351
|
+
if (!a.includes(".") || a.split(".").every((e) => {
|
|
352
|
+
let t = w(e);
|
|
353
|
+
return m(t) && t >= 0;
|
|
354
|
+
})) {
|
|
355
|
+
if (!o(e)) return i();
|
|
356
|
+
let { found: n, value: a } = k(r(e), t);
|
|
357
|
+
return n ? a : i();
|
|
358
|
+
}
|
|
359
|
+
let s = W(e, a);
|
|
360
|
+
return b(s) ? i() : s;
|
|
470
361
|
}
|
|
471
|
-
function
|
|
472
|
-
|
|
362
|
+
function K(e) {
|
|
363
|
+
return o(e) || _(e) || f(e);
|
|
473
364
|
}
|
|
474
|
-
function q(
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
h(S) ? [...S] : O(S) ? new Map(S) : {
|
|
508
|
-
...S
|
|
509
|
-
}
|
|
510
|
-
) : v(
|
|
511
|
-
r,
|
|
512
|
-
g,
|
|
513
|
-
m(i) ? [] : {}
|
|
514
|
-
), t = r[g];
|
|
515
|
-
}
|
|
516
|
-
if (M(t))
|
|
517
|
-
return n;
|
|
518
|
-
}
|
|
519
|
-
const c = s[s.length - 1];
|
|
520
|
-
if (m(c) && c >= 0 && h(t)) {
|
|
521
|
-
for (; t.length <= c; )
|
|
522
|
-
t.push(void 0);
|
|
523
|
-
t[c] = u;
|
|
524
|
-
} else O(t) ? A(t, String(c), u) : !p(t) && L(t) && v(
|
|
525
|
-
t,
|
|
526
|
-
String(c),
|
|
527
|
-
u
|
|
528
|
-
);
|
|
529
|
-
return n;
|
|
365
|
+
function q(e, t, n) {
|
|
366
|
+
if (v(e)) return e;
|
|
367
|
+
if (p(t) || b(t)) return e.length = 0, o(n) ? e.push(...n) : e.push(n), e;
|
|
368
|
+
if (m(t)) {
|
|
369
|
+
if (u(t) && t >= 0) {
|
|
370
|
+
for (; e.length <= t;) e.push(void 0);
|
|
371
|
+
e[t] = n;
|
|
372
|
+
}
|
|
373
|
+
return e;
|
|
374
|
+
}
|
|
375
|
+
let r = t.toString().split(".").map(w), a = e, s = r[0];
|
|
376
|
+
!(m(s) && s >= 0) && a.length === 0 && (a.push({}), a = a[0]);
|
|
377
|
+
for (let t = 0; t < r.length - 1; t++) {
|
|
378
|
+
let n = r[t], s = r[t + 1];
|
|
379
|
+
if (m(n) && n >= 0 && o(a)) {
|
|
380
|
+
for (; a.length <= n;) a.push(void 0);
|
|
381
|
+
let e = a[n];
|
|
382
|
+
K(e) || (a[n] = m(s) ? [] : {}), a = a[n];
|
|
383
|
+
} else if (f(a)) {
|
|
384
|
+
let e = String(n), t = T(a, e).value;
|
|
385
|
+
K(t) || (t = m(s) ? [] : {}, E(a, e, t)), a = t;
|
|
386
|
+
} else {
|
|
387
|
+
let e = a, t = String(n), r = x(t), c = r && !Object.hasOwn(e, t) ? void 0 : e[t];
|
|
388
|
+
K(c) ? r && i(e, t, o(c) ? [...c] : f(c) ? new Map(c) : { ...c }) : i(e, t, m(s) ? [] : {}), a = e[t];
|
|
389
|
+
}
|
|
390
|
+
if (v(a)) return e;
|
|
391
|
+
}
|
|
392
|
+
let c = r[r.length - 1];
|
|
393
|
+
if (m(c) && c >= 0 && o(a)) {
|
|
394
|
+
for (; a.length <= c;) a.push(void 0);
|
|
395
|
+
a[c] = n;
|
|
396
|
+
} else f(a) ? E(a, String(c), n) : !p(a) && g(a) && i(a, String(c), n);
|
|
397
|
+
return e;
|
|
530
398
|
}
|
|
531
|
-
function
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
...r
|
|
558
|
-
}), t = o[c];
|
|
559
|
-
} else
|
|
560
|
-
return n;
|
|
561
|
-
}
|
|
562
|
-
return h(t) && t.push(...u), n;
|
|
399
|
+
function J(e, t, ...n) {
|
|
400
|
+
if (v(e)) return e;
|
|
401
|
+
if (p(t) || b(t)) return o(e) ? (e.push(...n), e) : [...n];
|
|
402
|
+
if (!o(e)) {
|
|
403
|
+
let e = [];
|
|
404
|
+
return q(e, t, n.length === 1 ? n[0] : n), e;
|
|
405
|
+
}
|
|
406
|
+
let r = t.toString().split(".");
|
|
407
|
+
if (r.length === 1) {
|
|
408
|
+
let t = w(r[0]);
|
|
409
|
+
return m(t) && t >= 0 && e.push(...n), e;
|
|
410
|
+
}
|
|
411
|
+
let a = e;
|
|
412
|
+
for (let t = 0; t < r.length - 1; t++) {
|
|
413
|
+
let n = r[t];
|
|
414
|
+
if (!n) continue;
|
|
415
|
+
let s = w(n);
|
|
416
|
+
if (m(s) && s >= 0 && o(a)) {
|
|
417
|
+
for (; a.length <= s;) a.push(void 0);
|
|
418
|
+
(p(a[s]) || !h(a[s])) && (a[s] = []), a = a[s];
|
|
419
|
+
} else if (!p(a) && h(a)) {
|
|
420
|
+
let e = a, t = x(n), r = t && !Object.hasOwn(e, n) ? void 0 : e[n];
|
|
421
|
+
p(r) || !h(r) ? i(e, n, []) : t && i(e, n, { ...r }), a = e[n];
|
|
422
|
+
} else return e;
|
|
423
|
+
}
|
|
424
|
+
return o(a) && a.push(...n), e;
|
|
563
425
|
}
|
|
564
|
-
function
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
f,
|
|
578
|
-
s(o)
|
|
579
|
-
])
|
|
580
|
-
);
|
|
581
|
-
if (!N(l))
|
|
582
|
-
return l;
|
|
583
|
-
const c = {};
|
|
584
|
-
for (const [f, o] of Object.entries(l))
|
|
585
|
-
v(c, f, s(o));
|
|
586
|
-
return c;
|
|
587
|
-
}, t = s(n);
|
|
588
|
-
return q(t, e, u);
|
|
426
|
+
function Y(e, t, n) {
|
|
427
|
+
if (p(t) || b(t)) return n;
|
|
428
|
+
if (!o(e)) return [];
|
|
429
|
+
let r = (e) => {
|
|
430
|
+
if (p(e) || b(e) || !g(e)) return e;
|
|
431
|
+
if (o(e)) return e.map(r);
|
|
432
|
+
if (f(e)) return new Map([...e].map(([e, t]) => [e, r(t)]));
|
|
433
|
+
if (!_(e)) return e;
|
|
434
|
+
let t = {};
|
|
435
|
+
for (let [n, a] of Object.entries(e)) i(t, n, r(a));
|
|
436
|
+
return t;
|
|
437
|
+
};
|
|
438
|
+
return q(r(e), t, n);
|
|
589
439
|
}
|
|
590
|
-
function
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
if (!u.includes("."))
|
|
602
|
-
return !1;
|
|
603
|
-
}
|
|
604
|
-
const s = C(n, u);
|
|
605
|
-
return !a(s);
|
|
440
|
+
function X(e, t) {
|
|
441
|
+
if (p(t) || b(t)) return p(e) || b(e) ? !1 : o(e) ? e.length > 0 : !h(e) || Object.keys(e).length > 0;
|
|
442
|
+
if (m(t)) return o(e) ? t >= 0 && t < e.length : h(e) && $(e, String(t)).found;
|
|
443
|
+
if (!o(e) && !h(e)) return !1;
|
|
444
|
+
let n = t.toString();
|
|
445
|
+
if (h(e)) {
|
|
446
|
+
if ($(e, n).found) return !0;
|
|
447
|
+
if (!n.includes(".")) return !1;
|
|
448
|
+
}
|
|
449
|
+
let r = W(e, n);
|
|
450
|
+
return !b(r);
|
|
606
451
|
}
|
|
607
|
-
function
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
if (!t.includes("."))
|
|
617
|
-
return s();
|
|
618
|
-
const c = C(n, t);
|
|
619
|
-
return a(c) ? s() : c;
|
|
452
|
+
function te(e, t, n = null) {
|
|
453
|
+
let r = () => c(n) ? n() : n;
|
|
454
|
+
if (p(t)) return e;
|
|
455
|
+
if (!h(e)) return r();
|
|
456
|
+
let i = String(t), a = $(e, i);
|
|
457
|
+
if (a.found) return b(a.value) ? r() : a.value;
|
|
458
|
+
if (!i.includes(".")) return r();
|
|
459
|
+
let o = W(e, i);
|
|
460
|
+
return b(o) ? r() : o;
|
|
620
461
|
}
|
|
621
|
-
function
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
const r = O(c) ? K(c, i).value : T(i) && !Object.hasOwn(c, i) ? void 0 : c[i], g = $(r) ? h(r) ? [...r] : O(r) ? new Map(r) : { ...r } : {};
|
|
637
|
-
O(c) ? A(c, i, g) : v(c, i, g), c = g;
|
|
638
|
-
}
|
|
639
|
-
return s;
|
|
462
|
+
function Z(e, t, n) {
|
|
463
|
+
if (p(t)) return n;
|
|
464
|
+
h(e) || (e = {});
|
|
465
|
+
let r = { ...e }, a = String(t);
|
|
466
|
+
if (!a.includes(".")) return i(r, a, n), r;
|
|
467
|
+
let s = a.split("."), c = r, l = s.length - 1;
|
|
468
|
+
for (let [e, t] of s.entries()) {
|
|
469
|
+
if (e === l) {
|
|
470
|
+
f(c) ? E(c, t, n) : i(c, t, n);
|
|
471
|
+
break;
|
|
472
|
+
}
|
|
473
|
+
let r = f(c) ? T(c, t).value : x(t) && !Object.hasOwn(c, t) ? void 0 : c[t], a = K(r) ? o(r) ? [...r] : f(r) ? new Map(r) : { ...r } : {};
|
|
474
|
+
f(c) ? E(c, t, a) : i(c, t, a), c = a;
|
|
475
|
+
}
|
|
476
|
+
return r;
|
|
640
477
|
}
|
|
641
|
-
function
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
return !1;
|
|
649
|
-
const s = C(n, u);
|
|
650
|
-
return !a(s);
|
|
478
|
+
function ne(e, t) {
|
|
479
|
+
if (!h(e) || p(t)) return !1;
|
|
480
|
+
let n = String(t);
|
|
481
|
+
if ($(e, n).found) return !0;
|
|
482
|
+
if (!n.includes(".")) return !1;
|
|
483
|
+
let r = W(e, n);
|
|
484
|
+
return !b(r);
|
|
651
485
|
}
|
|
652
|
-
function
|
|
653
|
-
|
|
486
|
+
function Q(e) {
|
|
487
|
+
return p(e) || b(e) || s(e) ? ee(e) : String(e);
|
|
654
488
|
}
|
|
655
|
-
function
|
|
656
|
-
|
|
489
|
+
function $(e, t) {
|
|
490
|
+
return f(e) ? T(e, t) : Object.hasOwn(e, t) ? {
|
|
491
|
+
found: !0,
|
|
492
|
+
value: e[t]
|
|
493
|
+
} : { found: !1 };
|
|
657
494
|
}
|
|
658
|
-
export {
|
|
659
|
-
rn as MAX_UNDOT_INDEX,
|
|
660
|
-
pn as dotFlatten,
|
|
661
|
-
W as dotFlattenArray,
|
|
662
|
-
R as dotFlattenObject,
|
|
663
|
-
ln as forgetKeys,
|
|
664
|
-
nn as forgetKeysArray,
|
|
665
|
-
k as forgetKeysObject,
|
|
666
|
-
On as getMixedValue,
|
|
667
|
-
C as getNestedValue,
|
|
668
|
-
an as getObjectValue,
|
|
669
|
-
U as getRaw,
|
|
670
|
-
xn as hasMixed,
|
|
671
|
-
wn as hasObjectKey,
|
|
672
|
-
cn as hasPath,
|
|
673
|
-
sn as isCanonicalUndotIndex,
|
|
674
|
-
V as parseSegments,
|
|
675
|
-
Sn as pushMixed,
|
|
676
|
-
hn as pushWithPath,
|
|
677
|
-
gn as setImmutable,
|
|
678
|
-
q as setMixed,
|
|
679
|
-
mn as setMixedImmutable,
|
|
680
|
-
fn as setObjectValue,
|
|
681
|
-
dn as undotExpand,
|
|
682
|
-
on as undotExpandArray,
|
|
683
|
-
en as undotExpandObject
|
|
684
|
-
};
|
|
495
|
+
export { V as MAX_UNDOT_INDEX, F as dotFlatten, L as dotFlattenArray, I as dotFlattenObject, A as forgetKeys, M as forgetKeysArray, j as forgetKeysObject, G as getMixedValue, W as getNestedValue, te as getObjectValue, k as getRaw, X as hasMixed, ne as hasObjectKey, O as hasPath, H as isCanonicalUndotIndex, D as parseSegments, J as pushMixed, P as pushWithPath, N as setImmutable, q as setMixed, Y as setMixedImmutable, Z as setObjectValue, R as undotExpand, U as undotExpandArray, B as undotExpandObject };
|