@tolki/path 0.0.0-stage → 1.0.0
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/LICENSE +21 -0
- package/README.md +4 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/path.d.ts +448 -0
- package/dist/path.d.ts.map +1 -0
- package/dist/path.js +684 -0
- package/dist/pluck.d.ts +68 -0
- package/dist/pluck.d.ts.map +1 -0
- package/dist/pluck.js +62 -0
- package/package.json +48 -3
package/dist/path.js
ADDED
|
@@ -0,0 +1,684 @@
|
|
|
1
|
+
import { isNull as p, isUndefined as a, isNumber as m, isInteger as I, phpArrayKey as b, isArray as h, isObject as x, isMap as O, readMapKey as K, isIllegalOffset as B, arrayKeyExistsError as G, isFloat as X, deleteMapKey as _, isString as H, isPrototypeObject as M, isPlainObject as N, nextIntegerKey as Q, defineKey as v, InvalidArgumentException as Y, arrayValueMessage as Z, keyedEntries as P, isIntegerLikeKey as D, isObjectAny as L, castableToArray as F, writeMapKey as A, isUnsafeKey as T, toPhpKeyString as y, isFunction as J } from "@tolki/utils";
|
|
2
|
+
function V(n) {
|
|
3
|
+
if (p(n) || a(n))
|
|
4
|
+
return [];
|
|
5
|
+
if (!m(n) && Number.isNaN(n))
|
|
6
|
+
return null;
|
|
7
|
+
if (m(n))
|
|
8
|
+
return I(n) && n >= 0 ? [n] : null;
|
|
9
|
+
const e = String(n);
|
|
10
|
+
if (e.length === 0)
|
|
11
|
+
return [];
|
|
12
|
+
const u = e.split("."), s = [];
|
|
13
|
+
for (const t of u) {
|
|
14
|
+
if (t.length === 0)
|
|
15
|
+
return null;
|
|
16
|
+
const l = b(t);
|
|
17
|
+
s.push(m(l) && l >= 0 ? l : t);
|
|
18
|
+
}
|
|
19
|
+
return s;
|
|
20
|
+
}
|
|
21
|
+
function cn(n, e) {
|
|
22
|
+
if (p(e))
|
|
23
|
+
return !1;
|
|
24
|
+
if (m(e))
|
|
25
|
+
return h(n) ? I(e) && e >= 0 && e < n.length : !p(n) && x(n) && E(n, String(e)).found;
|
|
26
|
+
const u = V(e);
|
|
27
|
+
if (!u || u.length === 0)
|
|
28
|
+
return !1;
|
|
29
|
+
let s = n;
|
|
30
|
+
for (const t of u)
|
|
31
|
+
if (h(s)) {
|
|
32
|
+
if (!m(t) || t >= s.length)
|
|
33
|
+
return !1;
|
|
34
|
+
s = s[t];
|
|
35
|
+
} else if (O(s)) {
|
|
36
|
+
const l = K(s, t);
|
|
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;
|
|
45
|
+
}
|
|
46
|
+
function U(n, e) {
|
|
47
|
+
if (p(e) || a(e))
|
|
48
|
+
return { found: !0, value: n };
|
|
49
|
+
if (m(e))
|
|
50
|
+
return h(n) ? !I(e) || e < 0 || e >= n.length ? { found: !1 } : { found: !0, value: n[e] } : !p(n) && x(n) ? E(n, String(e)) : { found: !1 };
|
|
51
|
+
const u = V(e);
|
|
52
|
+
if (!u || u.length === 0)
|
|
53
|
+
return { found: !1 };
|
|
54
|
+
let s = n;
|
|
55
|
+
for (const t of u)
|
|
56
|
+
if (h(s)) {
|
|
57
|
+
if (!m(t) || t >= s.length)
|
|
58
|
+
return { found: !1 };
|
|
59
|
+
s = s[t];
|
|
60
|
+
} else if (O(s)) {
|
|
61
|
+
const l = K(s, t);
|
|
62
|
+
if (!l.found)
|
|
63
|
+
return { found: !1 };
|
|
64
|
+
s = l.value;
|
|
65
|
+
} else if (x(s) && Object.hasOwn(s, String(t)))
|
|
66
|
+
s = s[String(t)];
|
|
67
|
+
else
|
|
68
|
+
return { found: !1 };
|
|
69
|
+
return { found: !0, value: s };
|
|
70
|
+
}
|
|
71
|
+
function ln(n, e) {
|
|
72
|
+
if ((h(e) ? e : [e]).some(B))
|
|
73
|
+
throw G();
|
|
74
|
+
return x(n) ? k(n, e) : nn(n, e);
|
|
75
|
+
}
|
|
76
|
+
function k(n, e) {
|
|
77
|
+
const u = p(e) || a(e) ? [] : h(e) ? e : [e], s = { ...n }, t = (f, o) => {
|
|
78
|
+
const i = b(f);
|
|
79
|
+
return !I(i) || i < 0 || i >= o.length ? null : i;
|
|
80
|
+
}, l = (f) => {
|
|
81
|
+
if (h(f))
|
|
82
|
+
return f.slice();
|
|
83
|
+
if (O(f))
|
|
84
|
+
return new Map(f);
|
|
85
|
+
if (x(f)) {
|
|
86
|
+
const o = Object.getPrototypeOf(f);
|
|
87
|
+
if (o === Object.prototype || p(o))
|
|
88
|
+
return { ...f };
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}, c = (f, o) => {
|
|
92
|
+
if (Object.hasOwn(s, f)) {
|
|
93
|
+
delete s[o];
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const i = f.split(".");
|
|
97
|
+
let r = s;
|
|
98
|
+
for (; i.length > 1; ) {
|
|
99
|
+
const d = i.shift();
|
|
100
|
+
if (h(r)) {
|
|
101
|
+
const w = t(d, r);
|
|
102
|
+
if (p(w))
|
|
103
|
+
return;
|
|
104
|
+
const j = l(r[w]);
|
|
105
|
+
if (p(j))
|
|
106
|
+
return;
|
|
107
|
+
r[w] = j, r = j;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (O(r)) {
|
|
111
|
+
const w = K(r, d), j = w.found ? l(w.value) : null;
|
|
112
|
+
if (p(j))
|
|
113
|
+
return;
|
|
114
|
+
A(r, d, j), r = j;
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (!Object.hasOwn(r, d))
|
|
118
|
+
return;
|
|
119
|
+
const S = l(r[d]);
|
|
120
|
+
if (p(S))
|
|
121
|
+
return;
|
|
122
|
+
r[d] = S, r = S;
|
|
123
|
+
}
|
|
124
|
+
const g = i.shift();
|
|
125
|
+
if (h(r)) {
|
|
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;
|
|
141
|
+
}
|
|
142
|
+
function nn(n, e) {
|
|
143
|
+
const u = n.slice();
|
|
144
|
+
if (p(e))
|
|
145
|
+
return u;
|
|
146
|
+
const s = (c) => {
|
|
147
|
+
let f = u;
|
|
148
|
+
for (const o of c) {
|
|
149
|
+
let i;
|
|
150
|
+
if (h(f))
|
|
151
|
+
i = m(o) && o >= 0 ? f[o] : void 0;
|
|
152
|
+
else if (O(f)) {
|
|
153
|
+
const g = K(f, o);
|
|
154
|
+
i = g.found ? g.value : void 0;
|
|
155
|
+
} else Object.hasOwn(f, o) && (i = f[o]);
|
|
156
|
+
if (!h(i) && !N(i) && !O(i) || M(i))
|
|
157
|
+
return null;
|
|
158
|
+
const r = h(i) ? i.slice() : O(i) ? new Map(i) : { ...i };
|
|
159
|
+
O(f) ? A(f, o, r) : v(
|
|
160
|
+
f,
|
|
161
|
+
o,
|
|
162
|
+
r
|
|
163
|
+
), f = r;
|
|
164
|
+
}
|
|
165
|
+
return f;
|
|
166
|
+
}, t = /* @__PURE__ */ new Map();
|
|
167
|
+
for (const c of h(e) ? e : [e]) {
|
|
168
|
+
const f = I(c) ? [c] : z(c).split(".").map(b), o = f.slice(0, -1), i = JSON.stringify(o), r = t.get(i) ?? { parent: o, leaves: /* @__PURE__ */ new Set() };
|
|
169
|
+
r.leaves.add(f[o.length]), t.set(i, r);
|
|
170
|
+
}
|
|
171
|
+
const l = [...t.values()].sort(
|
|
172
|
+
(c, f) => f.parent.length - c.parent.length
|
|
173
|
+
);
|
|
174
|
+
for (const { parent: c, leaves: f } of l) {
|
|
175
|
+
const o = s(c);
|
|
176
|
+
if (h(o)) {
|
|
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;
|
|
188
|
+
}
|
|
189
|
+
function gn(n, e, u) {
|
|
190
|
+
if (p(e))
|
|
191
|
+
return u;
|
|
192
|
+
if (!h(n))
|
|
193
|
+
return [];
|
|
194
|
+
const s = n.slice(), t = (i, r) => i > r ? r : i;
|
|
195
|
+
if (m(e) || H(e) && e.indexOf(".") === -1) {
|
|
196
|
+
const i = m(e) ? e : b(e);
|
|
197
|
+
if (!I(i) || i < 0)
|
|
198
|
+
return s;
|
|
199
|
+
const r = t(i, s.length), g = s.slice();
|
|
200
|
+
return r === g.length ? g.push(u) : g[r] = u, g;
|
|
201
|
+
}
|
|
202
|
+
const l = String(e).split("."), c = [];
|
|
203
|
+
for (const i of l) {
|
|
204
|
+
const r = b(i);
|
|
205
|
+
if (!I(r) || r < 0)
|
|
206
|
+
return s;
|
|
207
|
+
c.push(r);
|
|
208
|
+
}
|
|
209
|
+
const f = s.slice();
|
|
210
|
+
let o = f;
|
|
211
|
+
for (let i = 0; i < c.length; i++) {
|
|
212
|
+
const r = c[i], g = i === c.length - 1, d = t(r, o.length);
|
|
213
|
+
if (g) {
|
|
214
|
+
d === o.length ? o.push(u) : o[d] = u;
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
if (d === o.length) {
|
|
218
|
+
const w = [];
|
|
219
|
+
o.push(w), o = w;
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
const S = o[d];
|
|
223
|
+
if (p(S)) {
|
|
224
|
+
const w = [];
|
|
225
|
+
o[d] = w, o = w;
|
|
226
|
+
continue;
|
|
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;
|
|
236
|
+
}
|
|
237
|
+
function hn(n, e, ...u) {
|
|
238
|
+
const s = h(n) && !M(n) ? n : [];
|
|
239
|
+
if (p(e) || a(e))
|
|
240
|
+
return s.push(...u), s;
|
|
241
|
+
const t = V(e);
|
|
242
|
+
if (!t || t.length === 0)
|
|
243
|
+
return s;
|
|
244
|
+
const l = (r, g) => {
|
|
245
|
+
if (h(r)) {
|
|
246
|
+
if (!m(g))
|
|
247
|
+
return null;
|
|
248
|
+
const S = Math.min(g, r.length);
|
|
249
|
+
return S < r.length ? { slot: S, found: !0, value: r[S] } : { slot: S, found: !1 };
|
|
250
|
+
}
|
|
251
|
+
if (O(r))
|
|
252
|
+
return { slot: g, ...K(r, g) };
|
|
253
|
+
const d = String(g);
|
|
254
|
+
return Object.hasOwn(r, d) ? { slot: d, found: !0, value: r[d] } : { slot: d, found: !1 };
|
|
255
|
+
}, c = (r, g, d) => {
|
|
256
|
+
if (O(r)) {
|
|
257
|
+
A(r, g, d);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
v(r, g, d);
|
|
261
|
+
};
|
|
262
|
+
let f = s;
|
|
263
|
+
for (const [r, g] of t.slice(0, -1).entries()) {
|
|
264
|
+
const d = l(f, g);
|
|
265
|
+
if (p(d))
|
|
266
|
+
return s;
|
|
267
|
+
const S = d.value;
|
|
268
|
+
if (M(S))
|
|
269
|
+
return s;
|
|
270
|
+
if (h(S) || N(S) || O(S)) {
|
|
271
|
+
f = S;
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
const w = m(t[r + 1]) ? [] : {};
|
|
275
|
+
c(f, d.slot, w), f = w;
|
|
276
|
+
}
|
|
277
|
+
const o = l(f, t[t.length - 1]);
|
|
278
|
+
if (p(o))
|
|
279
|
+
return s;
|
|
280
|
+
const i = o.found ? o.value : [];
|
|
281
|
+
if (o.found || c(f, o.slot, i), h(i))
|
|
282
|
+
return M(i) || i.push(...u), s;
|
|
283
|
+
if (O(i) || N(i) && !M(i)) {
|
|
284
|
+
let r = Q(i);
|
|
285
|
+
for (const g of u)
|
|
286
|
+
O(i) ? i.set(r++, g) : v(i, String(r++), g);
|
|
287
|
+
return s;
|
|
288
|
+
}
|
|
289
|
+
throw new Y(Z(i, e));
|
|
290
|
+
}
|
|
291
|
+
function pn(n, e = "", u = 1 / 0) {
|
|
292
|
+
return x(n) ? R(n, e, u) : h(n) ? W(n, e, u) : W(
|
|
293
|
+
p(n) ? [] : [n],
|
|
294
|
+
e,
|
|
295
|
+
u
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
function R(n, e = "", u = 1 / 0) {
|
|
299
|
+
if (!x(n))
|
|
300
|
+
return {};
|
|
301
|
+
const s = {}, t = (l, c, f) => {
|
|
302
|
+
for (const [o, i] of P(l)) {
|
|
303
|
+
const r = `${c}${String(o)}`;
|
|
304
|
+
f < u && h(i) && i.length > 0 ? t(
|
|
305
|
+
i,
|
|
306
|
+
`${r}.`,
|
|
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;
|
|
316
|
+
}
|
|
317
|
+
function W(n, e = "", u = 1 / 0) {
|
|
318
|
+
if (!h(n))
|
|
319
|
+
return {};
|
|
320
|
+
const s = n, t = {}, l = (c, f, o) => {
|
|
321
|
+
for (let i = 0; i < c.length; i++) {
|
|
322
|
+
const r = c[i], g = `${f}${i}`;
|
|
323
|
+
if (o < u && h(r) && r.length > 0)
|
|
324
|
+
l(r, `${g}.`, o + 1);
|
|
325
|
+
else if (o < u && (N(r) && Object.keys(r).length > 0 || O(r) && P(r).length > 0))
|
|
326
|
+
for (const [d, S] of Object.entries(
|
|
327
|
+
R(
|
|
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;
|
|
347
|
+
}
|
|
348
|
+
function dn(n) {
|
|
349
|
+
return x(n) ? en(n) : on(n);
|
|
350
|
+
}
|
|
351
|
+
function tn(n, e) {
|
|
352
|
+
const u = [...e].sort(
|
|
353
|
+
(s, t) => t.split(".").length - s.split(".").length
|
|
354
|
+
);
|
|
355
|
+
for (const s of u) {
|
|
356
|
+
const t = s.split("."), l = t[t.length - 1], c = t.slice(0, -1), f = c.length === 0 ? n : C(n, c.join("."));
|
|
357
|
+
if (!x(f))
|
|
358
|
+
continue;
|
|
359
|
+
const o = f[l];
|
|
360
|
+
if (!x(o))
|
|
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
|
+
}
|
|
369
|
+
}
|
|
370
|
+
function en(n) {
|
|
371
|
+
const e = {}, u = /* @__PURE__ */ new Set();
|
|
372
|
+
for (const [s, t] of P(n)) {
|
|
373
|
+
const l = fn(e, s, t);
|
|
374
|
+
for (const [f, o] of Object.entries(l))
|
|
375
|
+
v(e, f, o);
|
|
376
|
+
const c = s.split(".");
|
|
377
|
+
for (let f = 1; f < c.length; f++)
|
|
378
|
+
u.add(c.slice(0, f).join("."));
|
|
379
|
+
}
|
|
380
|
+
return tn(
|
|
381
|
+
e,
|
|
382
|
+
u
|
|
383
|
+
), e;
|
|
384
|
+
}
|
|
385
|
+
const rn = 2 ** 24 - 2;
|
|
386
|
+
function sn(n) {
|
|
387
|
+
return D(n) && Number(n) <= rn;
|
|
388
|
+
}
|
|
389
|
+
function on(n) {
|
|
390
|
+
const e = [];
|
|
391
|
+
for (const [u, s] of P(n ?? {})) {
|
|
392
|
+
if (u.length === 0)
|
|
393
|
+
continue;
|
|
394
|
+
const t = u.split(".");
|
|
395
|
+
if (t.some((c) => !sn(c)))
|
|
396
|
+
continue;
|
|
397
|
+
let l = e;
|
|
398
|
+
for (let c = 0; c < t.length; c++) {
|
|
399
|
+
const f = Number(t[c]);
|
|
400
|
+
if (c === t.length - 1)
|
|
401
|
+
l[f] = s;
|
|
402
|
+
else {
|
|
403
|
+
const i = l[f];
|
|
404
|
+
if (p(i) || a(i)) {
|
|
405
|
+
const r = [];
|
|
406
|
+
l[f] = r, l = r;
|
|
407
|
+
} else if (h(i))
|
|
408
|
+
l = i;
|
|
409
|
+
else
|
|
410
|
+
break;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
return e;
|
|
415
|
+
}
|
|
416
|
+
function C(n, e) {
|
|
417
|
+
if (p(n) || a(n) || !L(n))
|
|
418
|
+
return;
|
|
419
|
+
const s = String(e).split(".");
|
|
420
|
+
let t = n;
|
|
421
|
+
for (const l of s) {
|
|
422
|
+
if (p(t) || a(t) || !L(t))
|
|
423
|
+
return;
|
|
424
|
+
if (h(t)) {
|
|
425
|
+
const c = b(l);
|
|
426
|
+
if (!m(c) || !Object.hasOwn(t, c))
|
|
427
|
+
return;
|
|
428
|
+
t = t[c];
|
|
429
|
+
} else if (O(t)) {
|
|
430
|
+
const c = K(t, l);
|
|
431
|
+
if (!c.found)
|
|
432
|
+
return;
|
|
433
|
+
t = c.value;
|
|
434
|
+
} else {
|
|
435
|
+
if (!Object.hasOwn(t, l))
|
|
436
|
+
return;
|
|
437
|
+
t = t[l];
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return t;
|
|
441
|
+
}
|
|
442
|
+
function On(n, e, u = null) {
|
|
443
|
+
const s = () => J(u) ? u() : u;
|
|
444
|
+
if (p(e))
|
|
445
|
+
return n;
|
|
446
|
+
if (m(e)) {
|
|
447
|
+
if (!h(n))
|
|
448
|
+
return s();
|
|
449
|
+
const o = F(n), { found: i, value: r } = U(o, e);
|
|
450
|
+
return i ? r : s();
|
|
451
|
+
}
|
|
452
|
+
const t = String(e);
|
|
453
|
+
if (!t.includes(".")) {
|
|
454
|
+
if (!h(n))
|
|
455
|
+
return s();
|
|
456
|
+
const o = F(n), { found: i, value: r } = U(o, e);
|
|
457
|
+
return i ? r : s();
|
|
458
|
+
}
|
|
459
|
+
if (t.split(".").every((o) => {
|
|
460
|
+
const i = b(o);
|
|
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;
|
|
470
|
+
}
|
|
471
|
+
function $(n) {
|
|
472
|
+
return h(n) || N(n) || O(n);
|
|
473
|
+
}
|
|
474
|
+
function q(n, e, u) {
|
|
475
|
+
if (M(n))
|
|
476
|
+
return n;
|
|
477
|
+
if (p(e) || a(e))
|
|
478
|
+
return n.length = 0, h(u) ? n.push(...u) : n.push(u), n;
|
|
479
|
+
if (m(e)) {
|
|
480
|
+
if (I(e) && e >= 0) {
|
|
481
|
+
for (; n.length <= e; )
|
|
482
|
+
n.push(void 0);
|
|
483
|
+
n[e] = u;
|
|
484
|
+
}
|
|
485
|
+
return n;
|
|
486
|
+
}
|
|
487
|
+
const s = e.toString().split(".").map(b);
|
|
488
|
+
let t = n;
|
|
489
|
+
const l = s[0];
|
|
490
|
+
!(m(l) && l >= 0) && t.length === 0 && (t.push({}), t = t[0]);
|
|
491
|
+
for (let f = 0; f < s.length - 1; f++) {
|
|
492
|
+
const o = s[f], i = s[f + 1];
|
|
493
|
+
if (m(o) && o >= 0 && h(t)) {
|
|
494
|
+
for (; t.length <= o; )
|
|
495
|
+
t.push(void 0);
|
|
496
|
+
const r = t[o];
|
|
497
|
+
$(r) || (t[o] = m(i) ? [] : {}), t = t[o];
|
|
498
|
+
} else if (O(t)) {
|
|
499
|
+
const r = String(o);
|
|
500
|
+
let g = K(t, r).value;
|
|
501
|
+
$(g) || (g = m(i) ? [] : {}, A(t, r, g)), t = g;
|
|
502
|
+
} else {
|
|
503
|
+
const r = t, g = String(o), d = T(g), S = d && !Object.hasOwn(r, g) ? void 0 : r[g];
|
|
504
|
+
$(S) ? d && v(
|
|
505
|
+
r,
|
|
506
|
+
g,
|
|
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;
|
|
530
|
+
}
|
|
531
|
+
function Sn(n, e, ...u) {
|
|
532
|
+
if (M(n))
|
|
533
|
+
return n;
|
|
534
|
+
if (p(e) || a(e))
|
|
535
|
+
return h(n) ? (n.push(...u), n) : [...u];
|
|
536
|
+
if (!h(n)) {
|
|
537
|
+
const l = [];
|
|
538
|
+
return q(l, e, u.length === 1 ? u[0] : u), l;
|
|
539
|
+
}
|
|
540
|
+
const s = e.toString().split(".");
|
|
541
|
+
if (s.length === 1) {
|
|
542
|
+
const l = b(s[0]);
|
|
543
|
+
return m(l) && l >= 0 && n.push(...u), n;
|
|
544
|
+
}
|
|
545
|
+
let t = n;
|
|
546
|
+
for (let l = 0; l < s.length - 1; l++) {
|
|
547
|
+
const c = s[l];
|
|
548
|
+
if (!c) continue;
|
|
549
|
+
const f = b(c);
|
|
550
|
+
if (m(f) && f >= 0 && h(t)) {
|
|
551
|
+
for (; t.length <= f; )
|
|
552
|
+
t.push(void 0);
|
|
553
|
+
(p(t[f]) || !x(t[f])) && (t[f] = []), t = t[f];
|
|
554
|
+
} else if (!p(t) && x(t)) {
|
|
555
|
+
const o = t, i = T(c), r = i && !Object.hasOwn(o, c) ? void 0 : o[c];
|
|
556
|
+
p(r) || !x(r) ? v(o, c, []) : i && v(o, c, {
|
|
557
|
+
...r
|
|
558
|
+
}), t = o[c];
|
|
559
|
+
} else
|
|
560
|
+
return n;
|
|
561
|
+
}
|
|
562
|
+
return h(t) && t.push(...u), n;
|
|
563
|
+
}
|
|
564
|
+
function mn(n, e, u) {
|
|
565
|
+
if (p(e) || a(e))
|
|
566
|
+
return u;
|
|
567
|
+
if (!h(n))
|
|
568
|
+
return [];
|
|
569
|
+
const s = (l) => {
|
|
570
|
+
if (p(l) || a(l) || !L(l))
|
|
571
|
+
return l;
|
|
572
|
+
if (h(l))
|
|
573
|
+
return l.map(s);
|
|
574
|
+
if (O(l))
|
|
575
|
+
return new Map(
|
|
576
|
+
[...l].map(([f, o]) => [
|
|
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);
|
|
589
|
+
}
|
|
590
|
+
function xn(n, e) {
|
|
591
|
+
if (p(e) || a(e))
|
|
592
|
+
return p(n) || a(n) ? !1 : h(n) ? n.length > 0 : x(n) ? Object.keys(n).length > 0 : !0;
|
|
593
|
+
if (m(e))
|
|
594
|
+
return h(n) ? e >= 0 && e < n.length : x(n) && E(n, String(e)).found;
|
|
595
|
+
if (!h(n) && !x(n))
|
|
596
|
+
return !1;
|
|
597
|
+
const u = e.toString();
|
|
598
|
+
if (x(n)) {
|
|
599
|
+
if (E(n, u).found)
|
|
600
|
+
return !0;
|
|
601
|
+
if (!u.includes("."))
|
|
602
|
+
return !1;
|
|
603
|
+
}
|
|
604
|
+
const s = C(n, u);
|
|
605
|
+
return !a(s);
|
|
606
|
+
}
|
|
607
|
+
function an(n, e, u = null) {
|
|
608
|
+
const s = () => J(u) ? u() : u;
|
|
609
|
+
if (p(e))
|
|
610
|
+
return n;
|
|
611
|
+
if (!x(n))
|
|
612
|
+
return s();
|
|
613
|
+
const t = String(e), l = E(n, t);
|
|
614
|
+
if (l.found)
|
|
615
|
+
return a(l.value) ? s() : l.value;
|
|
616
|
+
if (!t.includes("."))
|
|
617
|
+
return s();
|
|
618
|
+
const c = C(n, t);
|
|
619
|
+
return a(c) ? s() : c;
|
|
620
|
+
}
|
|
621
|
+
function fn(n, e, u) {
|
|
622
|
+
if (p(e))
|
|
623
|
+
return u;
|
|
624
|
+
x(n) || (n = {});
|
|
625
|
+
const s = { ...n }, t = String(e);
|
|
626
|
+
if (!t.includes("."))
|
|
627
|
+
return v(s, t, u), s;
|
|
628
|
+
const l = t.split(".");
|
|
629
|
+
let c = s;
|
|
630
|
+
const f = l.length - 1;
|
|
631
|
+
for (const [o, i] of l.entries()) {
|
|
632
|
+
if (o === f) {
|
|
633
|
+
O(c) ? A(c, i, u) : v(c, i, u);
|
|
634
|
+
break;
|
|
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;
|
|
640
|
+
}
|
|
641
|
+
function wn(n, e) {
|
|
642
|
+
if (!x(n) || p(e))
|
|
643
|
+
return !1;
|
|
644
|
+
const u = String(e);
|
|
645
|
+
if (E(n, u).found)
|
|
646
|
+
return !0;
|
|
647
|
+
if (!u.includes("."))
|
|
648
|
+
return !1;
|
|
649
|
+
const s = C(n, u);
|
|
650
|
+
return !a(s);
|
|
651
|
+
}
|
|
652
|
+
function z(n) {
|
|
653
|
+
return p(n) || a(n) || X(n) ? y(n) : String(n);
|
|
654
|
+
}
|
|
655
|
+
function E(n, e) {
|
|
656
|
+
return O(n) ? K(n, e) : Object.hasOwn(n, e) ? { found: !0, value: n[e] } : { found: !1 };
|
|
657
|
+
}
|
|
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
|
+
};
|