es-toolkit 1.10.1-dev.254 → 1.10.1-dev.255

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.
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-OSOLEQLZ.mjs.map
@@ -71,7 +71,6 @@ export { pick } from '../object/pick.mjs';
71
71
  export { pickBy } from '../object/pickBy.mjs';
72
72
  export { invert } from '../object/invert.mjs';
73
73
  export { clone } from '../object/clone.mjs';
74
- export { get } from '../object/get.mjs';
75
74
  export { isEqual } from '../predicate/isEqual.mjs';
76
75
  export { isNil } from '../predicate/isNil.mjs';
77
76
  export { isNotNil } from '../predicate/isNotNil.mjs';
@@ -147,6 +146,258 @@ declare function zipObjectDeep<P extends string | number | symbol, V>(keys: P[],
147
146
  [K in P]: V;
148
147
  };
149
148
 
149
+ /**
150
+ * See the definition of `@types/lodash`.
151
+ */
152
+ type GetIndexedField<T, K> = K extends keyof T ? T[K] : K extends `${number}` ? 'length' extends keyof T ? number extends T['length'] ? number extends keyof T ? T[number] : undefined : undefined : undefined : undefined;
153
+ type FieldWithPossiblyUndefined<T, Key> = Get<Exclude<T, undefined>, Key> | Extract<T, undefined>;
154
+ type IndexedFieldWithPossiblyUndefined<T, Key> = GetIndexedField<Exclude<T, undefined>, Key> | Extract<T, undefined>;
155
+ type Get<T, P> = P extends `${infer Left}.${infer Right}` ? Left extends keyof Exclude<T, undefined> ? FieldWithPossiblyUndefined<Exclude<T, undefined>[Left], Right> | Extract<T, undefined> : Left extends `${infer FieldKey}[${infer IndexKey}]` ? FieldKey extends keyof T ? FieldWithPossiblyUndefined<IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey>, Right> : undefined : undefined : P extends keyof T ? T[P] : P extends `${infer FieldKey}[${infer IndexKey}]` ? FieldKey extends keyof T ? IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey> : undefined : IndexedFieldWithPossiblyUndefined<T, P>;
156
+
157
+ /**
158
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
159
+ *
160
+ * @template T - The type of the object.
161
+ * @template K - The type of the key in the object.
162
+ * @template D - The type of the default value.
163
+ *
164
+ * @param {T} object - The object to query.
165
+ * @param {K | [K]} path - The path of the property to get.
166
+ * @returns {T[K]} - Returns the resolved value.
167
+ */
168
+ declare function get<T extends object, K extends keyof T>(object: T, path: K | [K]): T[K];
169
+ /**
170
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
171
+ *
172
+ * @template T - The type of the object.
173
+ * @template K - The type of the key in the object.
174
+ *
175
+ * @param {T | null | undefined} object - The object to query.
176
+ * @param {K | [K]} path - The path of the property to get.
177
+ * @returns {T[K] | undefined} - Returns the resolved value.
178
+ */
179
+ declare function get<T extends object, K extends keyof T>(object: T | null | undefined, path: K | [K]): T[K] | undefined;
180
+ /**
181
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
182
+ *
183
+ * @template T - The type of the object.
184
+ * @template K - The type of the key in the object.
185
+ * @template D - The type of the default value.
186
+ *
187
+ * @param {T | null | undefined} object - The object to query.
188
+ * @param {K | [K]} path - The path of the property to get.
189
+ * @param {D} defaultValue - The value returned if the resolved value is undefined.
190
+ * @returns {Exclude<T[K], undefined> | D} - Returns the resolved value.
191
+ */
192
+ declare function get<T extends object, K extends keyof T, D>(object: T | null | undefined, path: K | [K], defaultValue: D): Exclude<T[K], undefined> | D;
193
+ /**
194
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
195
+ *
196
+ * @template T - The type of the object.
197
+ * @template K1 - The type of the first key in the object.
198
+ * @template K2 - The type of the second key in the object.
199
+ *
200
+ * @param {T} object - The object to query.
201
+ * @param {[K1, K2]} path - The path of the property to get.
202
+ * @returns {T[K1][K2]} - Returns the resolved value.
203
+ */
204
+ declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1]>(object: T, path: [K1, K2]): T[K1][K2];
205
+ /**
206
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
207
+ *
208
+ * @template T - The type of the object.
209
+ * @template K1 - The type of the first key in the object.
210
+ * @template K2 - The type of the second key in the object.
211
+ *
212
+ * @param {T | null | undefined} object - The object to query.
213
+ * @param {[K1, K2]} path - The path of the property to get.
214
+ * @returns {T[K1][K2] | undefined} - Returns the resolved value.
215
+ */
216
+ declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1]>(object: T | null | undefined, path: [K1, K2]): T[K1][K2] | undefined;
217
+ /**
218
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
219
+ *
220
+ * @template T - The type of the object.
221
+ * @template K1 - The type of the first key in the object.
222
+ * @template K2 - The type of the second key in the object.
223
+ * @template D - The type of the default value.
224
+ *
225
+ * @param {T | null | undefined} object - The object to query.
226
+ * @param {[K1, K2]} path - The path of the property to get.
227
+ * @param {D} defaultValue - The value returned if the resolved value is undefined.
228
+ * @returns {Exclude<T[K1][K2], undefined> | D} - Returns the resolved value.
229
+ */
230
+ declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], D>(object: T | null | undefined, path: [K1, K2], defaultValue: D): Exclude<T[K1][K2], undefined> | D;
231
+ /**
232
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
233
+ *
234
+ * @template T - The type of the object.
235
+ * @template K1 - The type of the first key in the object.
236
+ * @template K2 - The type of the second key in the object.
237
+ * @template K3 - The type of the third key in the object.
238
+ *
239
+ * @param {T} object - The object to query.
240
+ * @param {[K1, K2, K3]} path - The path of the property to get.
241
+ * @returns {T[K1][K2][K3]} - Returns the resolved value.
242
+ */
243
+ declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(object: T, path: [K1, K2, K3]): T[K1][K2][K3];
244
+ /**
245
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
246
+ *
247
+ * @template T - The type of the object.
248
+ * @template K1 - The type of the first key in the object.
249
+ * @template K2 - The type of the second key in the object.
250
+ * @template K3 - The type of the third key in the object.
251
+ *
252
+ * @param {T | null | undefined} object - The object to query.
253
+ * @param {[K1, K2, K3]} path - The path of the property to get.
254
+ * @returns {T[K1][K2][K3] | undefined} - Returns the resolved value.
255
+ */
256
+ declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(object: T | null | undefined, path: [K1, K2, K3]): T[K1][K2][K3] | undefined;
257
+ /**
258
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
259
+ *
260
+ * @template T - The type of the object.
261
+ * @template K1 - The type of the first key in the object.
262
+ * @template K2 - The type of the second key in the object.
263
+ * @template K3 - The type of the third key in the object.
264
+ * @template D - The type of the default value.
265
+ *
266
+ * @param {T | null | undefined} object - The object to query.
267
+ * @param {[K1, K2, K3]} path - The path of the property to get.
268
+ * @param {D} defaultValue - The value returned if the resolved value is undefined.
269
+ * @returns {Exclude<T[K1][K2][K3], undefined> | D} - Returns the resolved value.
270
+ */
271
+ declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], D>(object: T | null | undefined, path: [K1, K2, K3], defaultValue: D): Exclude<T[K1][K2][K3], undefined> | D;
272
+ /**
273
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
274
+ *
275
+ * @template T - The type of the object.
276
+ * @template K1 - The type of the first key in the object.
277
+ * @template K2 - The type of the second key in the object.
278
+ * @template K3 - The type of the third key in the object.
279
+ * @template K4 - The type of the fourth key in the object.
280
+ *
281
+ * @param {T} object - The object to query.
282
+ * @param {[K1, K2, K3, K4]} path - The path of the property to get.
283
+ * @returns {T[K1][K2][K3][K4]} - Returns the resolved value.
284
+ */
285
+ declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(object: T, path: [K1, K2, K3, K4]): T[K1][K2][K3][K4];
286
+ /**
287
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
288
+ *
289
+ * @template T - The type of the object.
290
+ * @template K1 - The type of the first key in the object.
291
+ * @template K2 - The type of the second key in the object.
292
+ * @template K3 - The type of the third key in the object.
293
+ * @template K4 - The type of the fourth key in the object.
294
+ *
295
+ * @param {T | null | undefined} object - The object to query.
296
+ * @param {[K1, K2, K3, K4]} path - The path of the property to get.
297
+ * @returns {T[K1][K2][K3][K4] | undefined} - Returns the resolved value.
298
+ */
299
+ declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(object: T | null | undefined, path: [K1, K2, K3, K4]): T[K1][K2][K3][K4] | undefined;
300
+ /**
301
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
302
+ *
303
+ * @template T - The type of the object.
304
+ * @template K1 - The type of the first key in the object.
305
+ * @template K2 - The type of the second key in the object.
306
+ * @template K3 - The type of the third key in the object.
307
+ * @template K4 - The type of the fourth key in the object.
308
+ * @template D - The type of the default value.
309
+ *
310
+ * @param {T | null | undefined} object - The object to query.
311
+ * @param {[K1, K2, K3, K4]} path - The path of the property to get.
312
+ * @param {D} defaultValue - The value returned if the resolved value is undefined.
313
+ * @returns {Exclude<T[K1][K2][K3][K4], undefined> | D} - Returns the resolved value.
314
+ */
315
+ declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3], D>(object: T | null | undefined, path: [K1, K2, K3, K4], defaultValue: D): Exclude<T[K1][K2][K3][K4], undefined> | D;
316
+ /**
317
+ * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.
318
+ *
319
+ * @template T - The type of the value.
320
+ *
321
+ * @param {Record<number, T>} object - The object to query.
322
+ * @param {number} path - The path of the property to get.
323
+ * @returns {T} - Returns the resolved value.
324
+ */
325
+ declare function get<T>(object: Record<number, T>, path: number): T;
326
+ /**
327
+ * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.
328
+ *
329
+ * @template T - The type of the value.
330
+ *
331
+ * @param {Record<number, T> | null | undefined} object - The object to query.
332
+ * @param {number} path - The path of the property to get.
333
+ * @returns {T | undefined} - Returns the resolved value.
334
+ */
335
+ declare function get<T>(object: Record<number, T> | null | undefined, path: number): T | undefined;
336
+ /**
337
+ * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.
338
+ *
339
+ * @template T - The type of the value.
340
+ * @template D - The type of the default value.
341
+ *
342
+ * @param {Record<number, T> | null | undefined} object - The object to query.
343
+ * @param {number} path - The path of the property to get.
344
+ * @param {D} defaultValue - The value returned if the resolved value is undefined.
345
+ * @returns {T | D} - Returns the resolved value.
346
+ */
347
+ declare function get<T, D>(object: Record<number, T> | null | undefined, path: number, defaultValue: D): T | D;
348
+ /**
349
+ * Retrieves the value at a given path from a null or undefined object, returning the default value.
350
+ *
351
+ * @template D - The type of the default value.
352
+ *
353
+ * @param {null | undefined} object - The object to query.
354
+ * @param {PropertyKey} path - The path of the property to get.
355
+ * @param {D} defaultValue - The value returned if the resolved value is undefined.
356
+ * @returns {D} - Returns the default value.
357
+ */
358
+ declare function get<D>(object: null | undefined, path: PropertyKey, defaultValue: D): D;
359
+ /**
360
+ * Retrieves the value at a given path from a null or undefined object, returning undefined.
361
+ *
362
+ * @param {null | undefined} object - The object to query.
363
+ * @param {PropertyKey} path - The path of the property to get.
364
+ * @returns {undefined} - Returns undefined.
365
+ */
366
+ declare function get(object: null | undefined, path: PropertyKey): undefined;
367
+ /**
368
+ * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.
369
+ *
370
+ * @template T - The type of the object.
371
+ * @template P - The type of the path.
372
+ *
373
+ * @param {T} data - The object to query.
374
+ * @param {P} path - The path of the property to get.
375
+ * @returns {string extends P ? any : Get<T, P>} - Returns the resolved value.
376
+ */
377
+ declare function get<T, P extends string>(data: T, path: P): string extends P ? any : Get<T, P>;
378
+ /**
379
+ * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.
380
+ *
381
+ * @template T - The type of the object.
382
+ * @template P - The type of the path.
383
+ * @template D - The type of the default value.
384
+ *
385
+ * @param {T} data - The object to query.
386
+ * @param {P} path - The path of the property to get.
387
+ * @param {D} defaultValue - The value returned if the resolved value is undefined.
388
+ * @returns {Exclude<Get<T, P>, null | undefined> | D} - Returns the resolved value.
389
+ */
390
+ declare function get<T, P extends string, D = Get<T, P>>(data: T, path: P, defaultValue: D): Exclude<Get<T, P>, null | undefined> | D;
391
+ /**
392
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
393
+ *
394
+ * @param {unknown} object - The object to query.
395
+ * @param {PropertyKey | readonly PropertyKey[]} path - The path of the property to get.
396
+ * @param {unknown} [defaultValue] - The value returned if the resolved value is undefined.
397
+ * @returns {any} - Returns the resolved value.
398
+ */
399
+ declare function get(object: unknown, path: PropertyKey | readonly PropertyKey[], defaultValue?: unknown): any;
400
+
150
401
  /**
151
402
  * Sets the value at the specified path of the given object. If any part of the path does not exist, it will be created.
152
403
  *
@@ -214,4 +465,4 @@ declare const startsWith: (str: string, target: string, position?: number) => bo
214
465
  */
215
466
  declare const endsWith: (str: string, target: string, position?: number) => boolean;
216
467
 
217
- export { chunk, endsWith, set, startsWith, zipObjectDeep };
468
+ export { chunk, endsWith, get, set, startsWith, zipObjectDeep };
@@ -71,7 +71,6 @@ export { pick } from '../object/pick.js';
71
71
  export { pickBy } from '../object/pickBy.js';
72
72
  export { invert } from '../object/invert.js';
73
73
  export { clone } from '../object/clone.js';
74
- export { get } from '../object/get.js';
75
74
  export { isEqual } from '../predicate/isEqual.js';
76
75
  export { isNil } from '../predicate/isNil.js';
77
76
  export { isNotNil } from '../predicate/isNotNil.js';
@@ -147,6 +146,258 @@ declare function zipObjectDeep<P extends string | number | symbol, V>(keys: P[],
147
146
  [K in P]: V;
148
147
  };
149
148
 
149
+ /**
150
+ * See the definition of `@types/lodash`.
151
+ */
152
+ type GetIndexedField<T, K> = K extends keyof T ? T[K] : K extends `${number}` ? 'length' extends keyof T ? number extends T['length'] ? number extends keyof T ? T[number] : undefined : undefined : undefined : undefined;
153
+ type FieldWithPossiblyUndefined<T, Key> = Get<Exclude<T, undefined>, Key> | Extract<T, undefined>;
154
+ type IndexedFieldWithPossiblyUndefined<T, Key> = GetIndexedField<Exclude<T, undefined>, Key> | Extract<T, undefined>;
155
+ type Get<T, P> = P extends `${infer Left}.${infer Right}` ? Left extends keyof Exclude<T, undefined> ? FieldWithPossiblyUndefined<Exclude<T, undefined>[Left], Right> | Extract<T, undefined> : Left extends `${infer FieldKey}[${infer IndexKey}]` ? FieldKey extends keyof T ? FieldWithPossiblyUndefined<IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey>, Right> : undefined : undefined : P extends keyof T ? T[P] : P extends `${infer FieldKey}[${infer IndexKey}]` ? FieldKey extends keyof T ? IndexedFieldWithPossiblyUndefined<T[FieldKey], IndexKey> : undefined : IndexedFieldWithPossiblyUndefined<T, P>;
156
+
157
+ /**
158
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
159
+ *
160
+ * @template T - The type of the object.
161
+ * @template K - The type of the key in the object.
162
+ * @template D - The type of the default value.
163
+ *
164
+ * @param {T} object - The object to query.
165
+ * @param {K | [K]} path - The path of the property to get.
166
+ * @returns {T[K]} - Returns the resolved value.
167
+ */
168
+ declare function get<T extends object, K extends keyof T>(object: T, path: K | [K]): T[K];
169
+ /**
170
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
171
+ *
172
+ * @template T - The type of the object.
173
+ * @template K - The type of the key in the object.
174
+ *
175
+ * @param {T | null | undefined} object - The object to query.
176
+ * @param {K | [K]} path - The path of the property to get.
177
+ * @returns {T[K] | undefined} - Returns the resolved value.
178
+ */
179
+ declare function get<T extends object, K extends keyof T>(object: T | null | undefined, path: K | [K]): T[K] | undefined;
180
+ /**
181
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
182
+ *
183
+ * @template T - The type of the object.
184
+ * @template K - The type of the key in the object.
185
+ * @template D - The type of the default value.
186
+ *
187
+ * @param {T | null | undefined} object - The object to query.
188
+ * @param {K | [K]} path - The path of the property to get.
189
+ * @param {D} defaultValue - The value returned if the resolved value is undefined.
190
+ * @returns {Exclude<T[K], undefined> | D} - Returns the resolved value.
191
+ */
192
+ declare function get<T extends object, K extends keyof T, D>(object: T | null | undefined, path: K | [K], defaultValue: D): Exclude<T[K], undefined> | D;
193
+ /**
194
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
195
+ *
196
+ * @template T - The type of the object.
197
+ * @template K1 - The type of the first key in the object.
198
+ * @template K2 - The type of the second key in the object.
199
+ *
200
+ * @param {T} object - The object to query.
201
+ * @param {[K1, K2]} path - The path of the property to get.
202
+ * @returns {T[K1][K2]} - Returns the resolved value.
203
+ */
204
+ declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1]>(object: T, path: [K1, K2]): T[K1][K2];
205
+ /**
206
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
207
+ *
208
+ * @template T - The type of the object.
209
+ * @template K1 - The type of the first key in the object.
210
+ * @template K2 - The type of the second key in the object.
211
+ *
212
+ * @param {T | null | undefined} object - The object to query.
213
+ * @param {[K1, K2]} path - The path of the property to get.
214
+ * @returns {T[K1][K2] | undefined} - Returns the resolved value.
215
+ */
216
+ declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1]>(object: T | null | undefined, path: [K1, K2]): T[K1][K2] | undefined;
217
+ /**
218
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
219
+ *
220
+ * @template T - The type of the object.
221
+ * @template K1 - The type of the first key in the object.
222
+ * @template K2 - The type of the second key in the object.
223
+ * @template D - The type of the default value.
224
+ *
225
+ * @param {T | null | undefined} object - The object to query.
226
+ * @param {[K1, K2]} path - The path of the property to get.
227
+ * @param {D} defaultValue - The value returned if the resolved value is undefined.
228
+ * @returns {Exclude<T[K1][K2], undefined> | D} - Returns the resolved value.
229
+ */
230
+ declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], D>(object: T | null | undefined, path: [K1, K2], defaultValue: D): Exclude<T[K1][K2], undefined> | D;
231
+ /**
232
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
233
+ *
234
+ * @template T - The type of the object.
235
+ * @template K1 - The type of the first key in the object.
236
+ * @template K2 - The type of the second key in the object.
237
+ * @template K3 - The type of the third key in the object.
238
+ *
239
+ * @param {T} object - The object to query.
240
+ * @param {[K1, K2, K3]} path - The path of the property to get.
241
+ * @returns {T[K1][K2][K3]} - Returns the resolved value.
242
+ */
243
+ declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(object: T, path: [K1, K2, K3]): T[K1][K2][K3];
244
+ /**
245
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
246
+ *
247
+ * @template T - The type of the object.
248
+ * @template K1 - The type of the first key in the object.
249
+ * @template K2 - The type of the second key in the object.
250
+ * @template K3 - The type of the third key in the object.
251
+ *
252
+ * @param {T | null | undefined} object - The object to query.
253
+ * @param {[K1, K2, K3]} path - The path of the property to get.
254
+ * @returns {T[K1][K2][K3] | undefined} - Returns the resolved value.
255
+ */
256
+ declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(object: T | null | undefined, path: [K1, K2, K3]): T[K1][K2][K3] | undefined;
257
+ /**
258
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
259
+ *
260
+ * @template T - The type of the object.
261
+ * @template K1 - The type of the first key in the object.
262
+ * @template K2 - The type of the second key in the object.
263
+ * @template K3 - The type of the third key in the object.
264
+ * @template D - The type of the default value.
265
+ *
266
+ * @param {T | null | undefined} object - The object to query.
267
+ * @param {[K1, K2, K3]} path - The path of the property to get.
268
+ * @param {D} defaultValue - The value returned if the resolved value is undefined.
269
+ * @returns {Exclude<T[K1][K2][K3], undefined> | D} - Returns the resolved value.
270
+ */
271
+ declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], D>(object: T | null | undefined, path: [K1, K2, K3], defaultValue: D): Exclude<T[K1][K2][K3], undefined> | D;
272
+ /**
273
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
274
+ *
275
+ * @template T - The type of the object.
276
+ * @template K1 - The type of the first key in the object.
277
+ * @template K2 - The type of the second key in the object.
278
+ * @template K3 - The type of the third key in the object.
279
+ * @template K4 - The type of the fourth key in the object.
280
+ *
281
+ * @param {T} object - The object to query.
282
+ * @param {[K1, K2, K3, K4]} path - The path of the property to get.
283
+ * @returns {T[K1][K2][K3][K4]} - Returns the resolved value.
284
+ */
285
+ declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(object: T, path: [K1, K2, K3, K4]): T[K1][K2][K3][K4];
286
+ /**
287
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
288
+ *
289
+ * @template T - The type of the object.
290
+ * @template K1 - The type of the first key in the object.
291
+ * @template K2 - The type of the second key in the object.
292
+ * @template K3 - The type of the third key in the object.
293
+ * @template K4 - The type of the fourth key in the object.
294
+ *
295
+ * @param {T | null | undefined} object - The object to query.
296
+ * @param {[K1, K2, K3, K4]} path - The path of the property to get.
297
+ * @returns {T[K1][K2][K3][K4] | undefined} - Returns the resolved value.
298
+ */
299
+ declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(object: T | null | undefined, path: [K1, K2, K3, K4]): T[K1][K2][K3][K4] | undefined;
300
+ /**
301
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
302
+ *
303
+ * @template T - The type of the object.
304
+ * @template K1 - The type of the first key in the object.
305
+ * @template K2 - The type of the second key in the object.
306
+ * @template K3 - The type of the third key in the object.
307
+ * @template K4 - The type of the fourth key in the object.
308
+ * @template D - The type of the default value.
309
+ *
310
+ * @param {T | null | undefined} object - The object to query.
311
+ * @param {[K1, K2, K3, K4]} path - The path of the property to get.
312
+ * @param {D} defaultValue - The value returned if the resolved value is undefined.
313
+ * @returns {Exclude<T[K1][K2][K3][K4], undefined> | D} - Returns the resolved value.
314
+ */
315
+ declare function get<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3], D>(object: T | null | undefined, path: [K1, K2, K3, K4], defaultValue: D): Exclude<T[K1][K2][K3][K4], undefined> | D;
316
+ /**
317
+ * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.
318
+ *
319
+ * @template T - The type of the value.
320
+ *
321
+ * @param {Record<number, T>} object - The object to query.
322
+ * @param {number} path - The path of the property to get.
323
+ * @returns {T} - Returns the resolved value.
324
+ */
325
+ declare function get<T>(object: Record<number, T>, path: number): T;
326
+ /**
327
+ * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.
328
+ *
329
+ * @template T - The type of the value.
330
+ *
331
+ * @param {Record<number, T> | null | undefined} object - The object to query.
332
+ * @param {number} path - The path of the property to get.
333
+ * @returns {T | undefined} - Returns the resolved value.
334
+ */
335
+ declare function get<T>(object: Record<number, T> | null | undefined, path: number): T | undefined;
336
+ /**
337
+ * Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.
338
+ *
339
+ * @template T - The type of the value.
340
+ * @template D - The type of the default value.
341
+ *
342
+ * @param {Record<number, T> | null | undefined} object - The object to query.
343
+ * @param {number} path - The path of the property to get.
344
+ * @param {D} defaultValue - The value returned if the resolved value is undefined.
345
+ * @returns {T | D} - Returns the resolved value.
346
+ */
347
+ declare function get<T, D>(object: Record<number, T> | null | undefined, path: number, defaultValue: D): T | D;
348
+ /**
349
+ * Retrieves the value at a given path from a null or undefined object, returning the default value.
350
+ *
351
+ * @template D - The type of the default value.
352
+ *
353
+ * @param {null | undefined} object - The object to query.
354
+ * @param {PropertyKey} path - The path of the property to get.
355
+ * @param {D} defaultValue - The value returned if the resolved value is undefined.
356
+ * @returns {D} - Returns the default value.
357
+ */
358
+ declare function get<D>(object: null | undefined, path: PropertyKey, defaultValue: D): D;
359
+ /**
360
+ * Retrieves the value at a given path from a null or undefined object, returning undefined.
361
+ *
362
+ * @param {null | undefined} object - The object to query.
363
+ * @param {PropertyKey} path - The path of the property to get.
364
+ * @returns {undefined} - Returns undefined.
365
+ */
366
+ declare function get(object: null | undefined, path: PropertyKey): undefined;
367
+ /**
368
+ * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.
369
+ *
370
+ * @template T - The type of the object.
371
+ * @template P - The type of the path.
372
+ *
373
+ * @param {T} data - The object to query.
374
+ * @param {P} path - The path of the property to get.
375
+ * @returns {string extends P ? any : Get<T, P>} - Returns the resolved value.
376
+ */
377
+ declare function get<T, P extends string>(data: T, path: P): string extends P ? any : Get<T, P>;
378
+ /**
379
+ * Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.
380
+ *
381
+ * @template T - The type of the object.
382
+ * @template P - The type of the path.
383
+ * @template D - The type of the default value.
384
+ *
385
+ * @param {T} data - The object to query.
386
+ * @param {P} path - The path of the property to get.
387
+ * @param {D} defaultValue - The value returned if the resolved value is undefined.
388
+ * @returns {Exclude<Get<T, P>, null | undefined> | D} - Returns the resolved value.
389
+ */
390
+ declare function get<T, P extends string, D = Get<T, P>>(data: T, path: P, defaultValue: D): Exclude<Get<T, P>, null | undefined> | D;
391
+ /**
392
+ * Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
393
+ *
394
+ * @param {unknown} object - The object to query.
395
+ * @param {PropertyKey | readonly PropertyKey[]} path - The path of the property to get.
396
+ * @param {unknown} [defaultValue] - The value returned if the resolved value is undefined.
397
+ * @returns {any} - Returns the resolved value.
398
+ */
399
+ declare function get(object: unknown, path: PropertyKey | readonly PropertyKey[], defaultValue?: unknown): any;
400
+
150
401
  /**
151
402
  * Sets the value at the specified path of the given object. If any part of the path does not exist, it will be created.
152
403
  *
@@ -214,4 +465,4 @@ declare const startsWith: (str: string, target: string, position?: number) => bo
214
465
  */
215
466
  declare const endsWith: (str: string, target: string, position?: number) => boolean;
216
467
 
217
- export { chunk, endsWith, set, startsWith, zipObjectDeep };
468
+ export { chunk, endsWith, get, set, startsWith, zipObjectDeep };
@@ -917,36 +917,6 @@ function isPrimitive(value) {
917
917
  return value == null || typeof value !== "object" && typeof value !== "function";
918
918
  }
919
919
 
920
- // src/object/get.ts
921
- function get(obj, path, defaultValue) {
922
- if (!Array.isArray(path)) {
923
- const pathArr = path.split(".");
924
- path = [];
925
- for (let i = 0; i < pathArr.length; i++) {
926
- if (/^.+\[[0-9]+\]$/.test(pathArr[i])) {
927
- path.push(/^.+(?=\[[0-9]+\]$)/.exec(pathArr[i])[0]);
928
- path.push(`${new RegExp("(?<=^.+\\[)[0-9]+(?=\\]$)").exec(pathArr[i])[0]}`);
929
- } else {
930
- path.push(pathArr[i]);
931
- }
932
- }
933
- }
934
- const callback = (innerObj, innerPath) => {
935
- if (typeof innerObj[innerPath] === "undefined") {
936
- return void 0;
937
- }
938
- return innerObj[innerPath];
939
- };
940
- let currentObj = obj;
941
- for (let i = 0; i < path.length; i++) {
942
- currentObj = callback(currentObj, path[i]);
943
- if (typeof currentObj === "undefined") {
944
- return typeof defaultValue === "undefined" ? void 0 : defaultValue;
945
- }
946
- }
947
- return currentObj;
948
- }
949
-
950
920
  // src/predicate/isEqual.ts
951
921
  function isEqual(a, b) {
952
922
  if (Object.is(a, b)) {
@@ -1116,26 +1086,33 @@ function isIndex(value) {
1116
1086
  }
1117
1087
 
1118
1088
  // src/compat/_internal/toPath.ts
1119
- var ESCAPE_REGEXP = /\\(\\)?/g;
1120
- var PROPERTY_REGEXP = RegExp(
1121
- // Match anything that isn't a dot or bracket.
1122
- `[^.[\\]]+|\\[(?:([^"'][^[]*)|(["'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))`,
1123
- "g"
1124
- );
1125
1089
  function toPath(deepKey) {
1090
+ const ESCAPE_REGEXP = /\\(\\)?/g;
1091
+ const PROPERTY_REGEXP = RegExp(
1092
+ // Match anything that isn't a dot or bracket.
1093
+ `[^.[\\]]+|\\[(?:([^"'][^[]*)|(["'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))`,
1094
+ "g"
1095
+ );
1126
1096
  const result = [];
1127
1097
  if (deepKey[0] === ".") {
1128
1098
  result.push("");
1129
1099
  }
1130
1100
  let match;
1101
+ let lastIndex = 0;
1102
+ let count = 0;
1131
1103
  while ((match = PROPERTY_REGEXP.exec(deepKey)) !== null) {
1132
1104
  let [key, expr, quote, substr] = match;
1133
1105
  if (quote) {
1134
1106
  key = substr.replace(ESCAPE_REGEXP, "$1");
1135
1107
  } else if (expr) {
1136
- key = expr.trim();
1108
+ key = expr;
1137
1109
  }
1138
1110
  result.push(key);
1111
+ if (PROPERTY_REGEXP.lastIndex === lastIndex) {
1112
+ PROPERTY_REGEXP.lastIndex++;
1113
+ } else {
1114
+ lastIndex = PROPERTY_REGEXP.lastIndex;
1115
+ }
1139
1116
  }
1140
1117
  return result;
1141
1118
  }
@@ -1170,6 +1147,49 @@ function zipObjectDeep(keys, values) {
1170
1147
  return result;
1171
1148
  }
1172
1149
 
1150
+ // src/compat/_internal/isDeepKey.ts
1151
+ var IS_PLAIN = /^\w*$/;
1152
+ var IS_DEEP = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
1153
+ function isDeepKey(key) {
1154
+ switch (typeof key) {
1155
+ case "number":
1156
+ case "symbol": {
1157
+ return false;
1158
+ }
1159
+ case "string": {
1160
+ return !IS_PLAIN.test(key) && IS_DEEP.test(key);
1161
+ }
1162
+ }
1163
+ }
1164
+
1165
+ // src/compat/object/get.ts
1166
+ function get(object, path, defaultValue) {
1167
+ let resolvedPath;
1168
+ if (Array.isArray(path)) {
1169
+ resolvedPath = path;
1170
+ } else if (typeof path === "string" && isDeepKey(path) && (object == null ? void 0 : object[path]) == null) {
1171
+ resolvedPath = toPath(path);
1172
+ } else {
1173
+ resolvedPath = [path];
1174
+ }
1175
+ if (resolvedPath.length === 0) {
1176
+ return defaultValue;
1177
+ }
1178
+ let current = object;
1179
+ let index;
1180
+ for (index = 0; index < resolvedPath.length && current != null; index++) {
1181
+ let key = resolvedPath[index];
1182
+ if (Object.is(key.valueOf(), -0)) {
1183
+ key = "-0";
1184
+ }
1185
+ current = current[key];
1186
+ }
1187
+ if (current === null && index === resolvedPath.length) {
1188
+ return current;
1189
+ }
1190
+ return current != null ? current : defaultValue;
1191
+ }
1192
+
1173
1193
  // src/compat/string/startsWith.ts
1174
1194
  var startsWith = (str, target, position = 0) => {
1175
1195
  return str.startsWith(target, position);