es-toolkit 1.10.1 → 1.11.0-dev.263

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.
Files changed (220) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/compat.d.ts +1 -0
  3. package/dist/array/chunk.mjs +1 -1
  4. package/dist/array/compact.mjs +1 -1
  5. package/dist/array/countBy.mjs +1 -1
  6. package/dist/array/difference.mjs +1 -1
  7. package/dist/array/differenceBy.mjs +1 -1
  8. package/dist/array/differenceWith.mjs +1 -1
  9. package/dist/array/drop.js +1 -0
  10. package/dist/array/drop.js.map +1 -1
  11. package/dist/array/drop.mjs +2 -2
  12. package/dist/array/dropRight.js +5 -1
  13. package/dist/array/dropRight.js.map +1 -1
  14. package/dist/array/dropRight.mjs +2 -2
  15. package/dist/array/dropRightWhile.js +6 -14
  16. package/dist/array/dropRightWhile.js.map +1 -1
  17. package/dist/array/dropRightWhile.mjs +2 -3
  18. package/dist/array/dropWhile.mjs +1 -1
  19. package/dist/array/fill.d.mts +10 -7
  20. package/dist/array/fill.d.ts +10 -7
  21. package/dist/array/fill.js +7 -6
  22. package/dist/array/fill.js.map +1 -1
  23. package/dist/array/fill.mjs +2 -2
  24. package/dist/array/flatMap.d.mts +23 -0
  25. package/dist/array/flatMap.d.ts +23 -0
  26. package/dist/array/flatMap.js +52 -0
  27. package/dist/array/flatMap.js.map +1 -0
  28. package/dist/array/flatMap.mjs +9 -0
  29. package/dist/array/flatten.mjs +1 -1
  30. package/dist/array/flattenDeep.mjs +1 -1
  31. package/dist/array/forEachRight.mjs +1 -1
  32. package/dist/array/groupBy.mjs +1 -1
  33. package/dist/array/head.mjs +1 -1
  34. package/dist/array/index.d.mts +1 -0
  35. package/dist/array/index.d.ts +1 -0
  36. package/dist/array/index.js +30 -14
  37. package/dist/array/index.js.map +1 -1
  38. package/dist/array/index.mjs +41 -37
  39. package/dist/array/initial.mjs +1 -1
  40. package/dist/array/intersection.mjs +1 -1
  41. package/dist/array/intersectionBy.mjs +1 -1
  42. package/dist/array/intersectionWith.mjs +1 -1
  43. package/dist/array/keyBy.mjs +1 -1
  44. package/dist/array/last.mjs +1 -1
  45. package/dist/array/maxBy.mjs +1 -1
  46. package/dist/array/minBy.mjs +1 -1
  47. package/dist/array/orderBy.mjs +1 -1
  48. package/dist/array/partition.mjs +1 -1
  49. package/dist/array/sample.mjs +1 -1
  50. package/dist/array/sampleSize.mjs +1 -1
  51. package/dist/array/shuffle.mjs +1 -1
  52. package/dist/array/tail.mjs +1 -1
  53. package/dist/array/take.mjs +1 -1
  54. package/dist/array/takeRight.mjs +1 -1
  55. package/dist/array/takeRightWhile.mjs +1 -1
  56. package/dist/array/takeWhile.mjs +1 -1
  57. package/dist/array/toFilled.mjs +1 -1
  58. package/dist/array/union.mjs +1 -1
  59. package/dist/array/unionBy.mjs +1 -1
  60. package/dist/array/unionWith.mjs +1 -1
  61. package/dist/array/uniq.mjs +1 -1
  62. package/dist/array/uniqBy.d.mts +1 -1
  63. package/dist/array/uniqBy.d.ts +1 -1
  64. package/dist/array/uniqBy.js.map +1 -1
  65. package/dist/array/uniqBy.mjs +2 -2
  66. package/dist/array/uniqWith.mjs +1 -1
  67. package/dist/array/unzip.mjs +1 -1
  68. package/dist/array/unzipWith.mjs +1 -1
  69. package/dist/array/without.mjs +1 -1
  70. package/dist/array/xor.mjs +1 -1
  71. package/dist/array/xorBy.mjs +1 -1
  72. package/dist/array/xorWith.mjs +1 -1
  73. package/dist/array/zip.mjs +1 -1
  74. package/dist/array/zipObject.mjs +1 -1
  75. package/dist/array/zipWith.mjs +1 -1
  76. package/dist/{chunk-S3CORED5.mjs → chunk-3EZAFZG3.mjs} +2 -1
  77. package/dist/{chunk-S3CORED5.mjs.map → chunk-3EZAFZG3.mjs.map} +1 -1
  78. package/dist/{chunk-2MM5EJJX.mjs → chunk-424M7IR7.mjs} +23 -2
  79. package/dist/chunk-4OIZM4HS.mjs +1 -0
  80. package/dist/{chunk-GDC64SYJ.mjs → chunk-5ASRKEB4.mjs} +1 -1
  81. package/dist/{chunk-GDC64SYJ.mjs.map → chunk-5ASRKEB4.mjs.map} +1 -1
  82. package/dist/{chunk-OXAZEEGP.mjs → chunk-B4COTK4K.mjs} +1 -1
  83. package/dist/{chunk-OXAZEEGP.mjs.map → chunk-B4COTK4K.mjs.map} +1 -1
  84. package/dist/chunk-DDH7K4QM.mjs +1 -0
  85. package/dist/chunk-F47GLYUU.mjs +1 -0
  86. package/dist/chunk-J3GE7DEU.mjs +22 -0
  87. package/dist/chunk-J3GE7DEU.mjs.map +1 -0
  88. package/dist/chunk-KIOYQRMQ.mjs +12 -0
  89. package/dist/chunk-KIOYQRMQ.mjs.map +1 -0
  90. package/dist/chunk-M7SBBYV2.mjs +14 -0
  91. package/dist/chunk-M7SBBYV2.mjs.map +1 -0
  92. package/dist/{chunk-IZAD2S7R.mjs → chunk-MY4G7R3I.mjs} +2 -2
  93. package/dist/{chunk-74WWMNZS.mjs → chunk-OLX53VEF.mjs} +4 -2
  94. package/dist/{chunk-74WWMNZS.mjs.map → chunk-OLX53VEF.mjs.map} +1 -1
  95. package/dist/chunk-OXZCMC5I.mjs +13 -0
  96. package/dist/{chunk-JEKUA56R.mjs.map → chunk-OXZCMC5I.mjs.map} +1 -1
  97. package/dist/chunk-QXTNZR7B.mjs +25 -0
  98. package/dist/chunk-QXTNZR7B.mjs.map +1 -0
  99. package/dist/{chunk-QZITBKWX.mjs → chunk-U7V3G7CR.mjs} +2 -2
  100. package/dist/chunk-UY76KTPE.mjs +13 -0
  101. package/dist/chunk-UY76KTPE.mjs.map +1 -0
  102. package/dist/chunk-XT74R35S.mjs +1 -0
  103. package/dist/chunk-XT74R35S.mjs.map +1 -0
  104. package/dist/chunk-XWPCDIFC.mjs +18 -0
  105. package/dist/chunk-XWPCDIFC.mjs.map +1 -0
  106. package/dist/chunk-YFN6KOC4.mjs +15 -0
  107. package/dist/chunk-YFN6KOC4.mjs.map +1 -0
  108. package/dist/compat/index.d.mts +392 -1
  109. package/dist/compat/index.d.ts +392 -1
  110. package/dist/compat/index.js +276 -21
  111. package/dist/compat/index.js.map +1 -1
  112. package/dist/compat/index.mjs +268 -87
  113. package/dist/compat/index.mjs.map +1 -1
  114. package/dist/error/AbortError.mjs +1 -1
  115. package/dist/error/TimeoutError.d.mts +9 -0
  116. package/dist/error/TimeoutError.d.ts +9 -0
  117. package/dist/error/TimeoutError.js +36 -0
  118. package/dist/error/TimeoutError.js.map +1 -0
  119. package/dist/error/TimeoutError.mjs +8 -0
  120. package/dist/error/TimeoutError.mjs.map +1 -0
  121. package/dist/error/index.d.mts +1 -0
  122. package/dist/error/index.d.ts +1 -0
  123. package/dist/error/index.js +12 -2
  124. package/dist/error/index.js.map +1 -1
  125. package/dist/error/index.mjs +7 -3
  126. package/dist/function/debounce.mjs +1 -1
  127. package/dist/function/index.mjs +7 -7
  128. package/dist/function/negate.mjs +1 -1
  129. package/dist/function/noop.mjs +1 -1
  130. package/dist/function/once.mjs +1 -1
  131. package/dist/function/throttle.mjs +1 -1
  132. package/dist/index.d.mts +4 -0
  133. package/dist/index.d.ts +4 -0
  134. package/dist/index.js +99 -15
  135. package/dist/index.js.map +1 -1
  136. package/dist/index.mjs +104 -87
  137. package/dist/math/clamp.mjs +1 -1
  138. package/dist/math/inRange.mjs +1 -1
  139. package/dist/math/index.js.map +1 -1
  140. package/dist/math/index.mjs +12 -12
  141. package/dist/math/mean.d.mts +1 -1
  142. package/dist/math/mean.d.ts +1 -1
  143. package/dist/math/mean.js.map +1 -1
  144. package/dist/math/mean.mjs +2 -2
  145. package/dist/math/meanBy.js.map +1 -1
  146. package/dist/math/meanBy.mjs +3 -3
  147. package/dist/math/random.mjs +1 -1
  148. package/dist/math/randomInt.mjs +1 -1
  149. package/dist/math/range.mjs +1 -1
  150. package/dist/math/round.mjs +1 -1
  151. package/dist/math/sum.mjs +1 -1
  152. package/dist/math/sumBy.mjs +1 -1
  153. package/dist/object/clone.mjs +1 -1
  154. package/dist/object/index.js +3 -1
  155. package/dist/object/index.js.map +1 -1
  156. package/dist/object/index.mjs +6 -6
  157. package/dist/object/invert.js +3 -1
  158. package/dist/object/invert.js.map +1 -1
  159. package/dist/object/invert.mjs +2 -2
  160. package/dist/object/omit.mjs +2 -2
  161. package/dist/object/omitBy.mjs +1 -1
  162. package/dist/object/pick.mjs +1 -1
  163. package/dist/object/pickBy.mjs +1 -1
  164. package/dist/predicate/index.mjs +1 -1
  165. package/dist/predicate/isEqual.mjs +1 -1
  166. package/dist/predicate/isNil.mjs +1 -1
  167. package/dist/predicate/isNotNil.mjs +1 -1
  168. package/dist/predicate/isNull.mjs +1 -1
  169. package/dist/predicate/isUndefined.mjs +1 -1
  170. package/dist/promise/delay.mjs +1 -1
  171. package/dist/promise/index.d.mts +1 -0
  172. package/dist/promise/index.d.ts +1 -0
  173. package/dist/promise/index.js +47 -2
  174. package/dist/promise/index.js.map +1 -1
  175. package/dist/promise/index.mjs +9 -3
  176. package/dist/promise/timeout.d.mts +10 -0
  177. package/dist/promise/timeout.d.ts +10 -0
  178. package/dist/promise/timeout.js +92 -0
  179. package/dist/promise/timeout.js.map +1 -0
  180. package/dist/promise/timeout.mjs +11 -0
  181. package/dist/promise/timeout.mjs.map +1 -0
  182. package/dist/promise/withTimeout.d.mts +22 -0
  183. package/dist/promise/withTimeout.d.ts +22 -0
  184. package/dist/promise/withTimeout.js +99 -0
  185. package/dist/promise/withTimeout.js.map +1 -0
  186. package/dist/promise/withTimeout.mjs +12 -0
  187. package/dist/promise/withTimeout.mjs.map +1 -0
  188. package/dist/string/camelCase.mjs +1 -1
  189. package/dist/string/capitalize.mjs +1 -1
  190. package/dist/string/index.d.mts +1 -0
  191. package/dist/string/index.d.ts +1 -0
  192. package/dist/string/index.js +21 -2
  193. package/dist/string/index.js.map +1 -1
  194. package/dist/string/index.mjs +13 -9
  195. package/dist/string/kebabCase.mjs +1 -1
  196. package/dist/string/lowerCase.mjs +1 -1
  197. package/dist/string/snakeCase.mjs +1 -1
  198. package/dist/string/startCase.d.mts +16 -0
  199. package/dist/string/startCase.d.ts +16 -0
  200. package/dist/string/startCase.js +54 -0
  201. package/dist/string/startCase.js.map +1 -0
  202. package/dist/string/startCase.mjs +9 -0
  203. package/dist/string/startCase.mjs.map +1 -0
  204. package/package.json +3 -5
  205. package/dist/chunk-2MRZANXZ.mjs +0 -1
  206. package/dist/chunk-ARZ5BDR6.mjs +0 -1
  207. package/dist/chunk-C4WE4GLC.mjs +0 -14
  208. package/dist/chunk-C4WE4GLC.mjs.map +0 -1
  209. package/dist/chunk-FZEZH22H.mjs +0 -1
  210. package/dist/chunk-JE6JKZU3.mjs +0 -15
  211. package/dist/chunk-JE6JKZU3.mjs.map +0 -1
  212. package/dist/chunk-JEKUA56R.mjs +0 -9
  213. package/dist/chunk-QKYYOLJ6.mjs +0 -1
  214. /package/dist/{chunk-2MM5EJJX.mjs.map → array/flatMap.mjs.map} +0 -0
  215. /package/dist/{chunk-2MRZANXZ.mjs.map → chunk-424M7IR7.mjs.map} +0 -0
  216. /package/dist/{chunk-ARZ5BDR6.mjs.map → chunk-4OIZM4HS.mjs.map} +0 -0
  217. /package/dist/{chunk-FZEZH22H.mjs.map → chunk-DDH7K4QM.mjs.map} +0 -0
  218. /package/dist/{chunk-QKYYOLJ6.mjs.map → chunk-F47GLYUU.mjs.map} +0 -0
  219. /package/dist/{chunk-IZAD2S7R.mjs.map → chunk-MY4G7R3I.mjs.map} +0 -0
  220. /package/dist/{chunk-QZITBKWX.mjs.map → chunk-U7V3G7CR.mjs.map} +0 -0
@@ -8,6 +8,7 @@ export { dropRight } from '../array/dropRight.js';
8
8
  export { dropRightWhile } from '../array/dropRightWhile.js';
9
9
  export { dropWhile } from '../array/dropWhile.js';
10
10
  export { fill } from '../array/fill.js';
11
+ export { flatMap } from '../array/flatMap.js';
11
12
  export { flatten } from '../array/flatten.js';
12
13
  export { flattenDeep } from '../array/flattenDeep.js';
13
14
  export { forEachRight } from '../array/forEachRight.js';
@@ -48,6 +49,7 @@ export { toFilled } from '../array/toFilled.js';
48
49
  export { last } from '../array/last.js';
49
50
  export { initial } from '../array/initial.js';
50
51
  export { AbortError } from '../error/AbortError.js';
52
+ export { TimeoutError } from '../error/TimeoutError.js';
51
53
  export { debounce } from '../function/debounce.js';
52
54
  export { noop } from '../function/noop.js';
53
55
  export { once } from '../function/once.js';
@@ -75,10 +77,12 @@ export { isNotNil } from '../predicate/isNotNil.js';
75
77
  export { isNull } from '../predicate/isNull.js';
76
78
  export { isUndefined } from '../predicate/isUndefined.js';
77
79
  export { delay } from '../promise/delay.js';
80
+ export { withTimeout } from '../promise/withTimeout.js';
78
81
  export { camelCase } from '../string/camelCase.js';
79
82
  export { snakeCase } from '../string/snakeCase.js';
80
83
  export { kebabCase } from '../string/kebabCase.js';
81
84
  export { lowerCase } from '../string/lowerCase.js';
85
+ export { startCase } from '../string/startCase.js';
82
86
  export { capitalize } from '../string/capitalize.js';
83
87
 
84
88
  /**
@@ -106,4 +110,391 @@ export { capitalize } from '../string/capitalize.js';
106
110
  */
107
111
  declare function chunk<T>(arr: readonly T[], size?: number): T[][];
108
112
 
109
- export { chunk };
113
+ /**
114
+ * Creates a deeply nested object given arrays of paths and values.
115
+ *
116
+ * This function takes two arrays: one containing arrays of property paths, and the other containing corresponding values.
117
+ * It returns a new object where paths from the first array are used as key paths to set values, with corresponding elements from the second array as values.
118
+ * Paths can be dot-separated strings or arrays of property names.
119
+ *
120
+ * If the `keys` array is longer than the `values` array, the remaining keys will have `undefined` as their values.
121
+ *
122
+ * @template V - The type of elements in the array.
123
+ * @param {string[] | string[][]} keys - An array of property paths, each path can be a dot-separated string or an array of property names.
124
+ * @param {V[]} values - An array of values corresponding to the property paths.
125
+ * @returns {object} A new object composed of the given property paths and values.
126
+ *
127
+ * @example
128
+ * const paths = ['a.b.c', 'd.e.f'];
129
+ * const values = [1, 2];
130
+ * const result = zipObjectDeep(paths, values);
131
+ * // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } }
132
+ *
133
+ * @example
134
+ * const paths = [['a', 'b', 'c'], ['d', 'e', 'f']];
135
+ * const values = [1, 2];
136
+ * const result = zipObjectDeep(paths, values);
137
+ * // result will be { a: { b: { c: 1 } }, d: { e: { f: 2 } } }
138
+ *
139
+ * @example
140
+ * const paths = ['a.b[0].c', 'a.b[1].d'];
141
+ * const values = [1, 2];
142
+ * const result = zipObjectDeep(paths, values);
143
+ * // result will be { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
144
+ */
145
+ declare function zipObjectDeep<P extends string | number | symbol, V>(keys: P[], values: V[]): {
146
+ [K in P]: V;
147
+ };
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
+
401
+ /**
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.
403
+ *
404
+ * @template T - The type of the object.
405
+ * @param {Settable} obj - The object to modify.
406
+ * @param {Path} path - The path of the property to set.
407
+ * @param {any} value - The value to set.
408
+ * @returns {T} - The modified object.
409
+ *
410
+ * @example
411
+ * // Set a value in a nested object
412
+ * const obj = { a: { b: { c: 3 } } };
413
+ * set(obj, 'a.b.c', 4);
414
+ * console.log(obj.a.b.c); // 4
415
+ *
416
+ * @example
417
+ * // Set a value in an array
418
+ * const arr = [1, 2, 3];
419
+ * set(arr, 1, 4);
420
+ * console.log(arr[1]); // 4
421
+ *
422
+ * @example
423
+ * // Create non-existent path and set value
424
+ * const obj = {};
425
+ * set(obj, 'a.b.c', 4);
426
+ * console.log(obj); // { a: { b: { c: 4 } } }
427
+ */
428
+ declare function set<T>(obj: object, path: PropertyKey | readonly PropertyKey[], value: unknown): T;
429
+
430
+ /**
431
+ * Checks if a string contains another string at the beginning of the string.
432
+ *
433
+ * Checks if one string startsWith another string. Optional position parameter to start searching from a certain index.
434
+ *
435
+ * @param {string} str - The string that might contain the target string.
436
+ * @param {string} target - The string to search for.
437
+ * @param {number} position - An optional offset to start searching in the str string
438
+ * @returns {boolean} - True if the str string starts with the target string.
439
+ *
440
+ * @example
441
+ * const isPrefix = startsWith('fooBar', 'foo') // returns true
442
+ * const isPrefix = startsWith('fooBar', 'bar') // returns false
443
+ * const isPrefix = startsWith('fooBar', 'abc') // returns false
444
+ * const isPrefix = startsWith('fooBar', 'Bar', 2) // returns true
445
+ * const isPrefix = startsWith('fooBar', 'Bar', 5) // returns false
446
+ */
447
+ declare const startsWith: (str: string, target: string, position?: number) => boolean;
448
+
449
+ /**
450
+ * Checks if a string contains another string at the end of the string.
451
+ *
452
+ * Checks if one string endsWith another string. Optional position parameter to offset searching before a certain index.
453
+ *
454
+ * @param {string} str - The string that might contain the target string.
455
+ * @param {string} target - The string to search for.
456
+ * @param {number} position - An optional position from the start to search up to this index
457
+ * @returns {boolean} - True if the str string ends with the target string.
458
+ *
459
+ * @example
460
+ * const isPrefix = endsWith('fooBar', 'foo') // returns true
461
+ * const isPrefix = endsWith('fooBar', 'bar') // returns false
462
+ * const isPrefix = endsWith('fooBar', 'abc') // returns false
463
+ * const isPrefix = endsWith('fooBar', 'foo', 3) // returns true
464
+ * const isPrefix = endsWith('fooBar', 'abc', 5) // returns false
465
+ */
466
+ declare const endsWith: (str: string, target: string, position?: number) => boolean;
467
+
468
+ /**
469
+ * Finds the element in an array that has the maximum value.
470
+ *
471
+ * @template T - The type of elements in the array.
472
+ * @param {T[]} items The array of elements to search.
473
+ * @returns {T} The element with the maximum value.
474
+ * @example
475
+ * // Returns 9
476
+ * max([3, 1, 4, 1, 5, 9])
477
+ *
478
+ * @example
479
+ * // Returns 8
480
+ * max([0, -3, 2, 8, 7])
481
+ */
482
+ declare function max<T>(items?: readonly T[]): T;
483
+
484
+ /**
485
+ * Finds the element in an array that has the minimum value.
486
+ *
487
+ * @template T - The type of elements in the array.
488
+ * @param {T[]} items The array of elements to search.
489
+ * @returns {T} The element with the minimum value.
490
+ * @example
491
+ * // Returns 1
492
+ * min([3, 1, 4, 1, 5, 9])
493
+ *
494
+ * @example
495
+ * // Returns -3
496
+ * min([0, -3, 2, 8, 7])
497
+ */
498
+ declare function min<T>(items?: readonly T[]): T;
499
+
500
+ export { chunk, endsWith, get, max, min, set, startsWith, zipObjectDeep };