@vielzeug/toolkit 1.0.11

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 (422) hide show
  1. package/dist/array/aggregate.cjs +2 -0
  2. package/dist/array/aggregate.cjs.map +1 -0
  3. package/dist/array/aggregate.js +16 -0
  4. package/dist/array/aggregate.js.map +1 -0
  5. package/dist/array/alternate.cjs +2 -0
  6. package/dist/array/alternate.cjs.map +1 -0
  7. package/dist/array/alternate.js +9 -0
  8. package/dist/array/alternate.js.map +1 -0
  9. package/dist/array/chunk.cjs +2 -0
  10. package/dist/array/chunk.cjs.map +1 -0
  11. package/dist/array/chunk.js +22 -0
  12. package/dist/array/chunk.js.map +1 -0
  13. package/dist/array/compact.cjs +2 -0
  14. package/dist/array/compact.cjs.map +1 -0
  15. package/dist/array/compact.js +9 -0
  16. package/dist/array/compact.js.map +1 -0
  17. package/dist/array/contains.cjs +2 -0
  18. package/dist/array/contains.cjs.map +1 -0
  19. package/dist/array/contains.js +11 -0
  20. package/dist/array/contains.js.map +1 -0
  21. package/dist/array/every.cjs +2 -0
  22. package/dist/array/every.cjs.map +1 -0
  23. package/dist/array/every.js +14 -0
  24. package/dist/array/every.js.map +1 -0
  25. package/dist/array/filter.cjs +2 -0
  26. package/dist/array/filter.cjs.map +1 -0
  27. package/dist/array/filter.js +14 -0
  28. package/dist/array/filter.js.map +1 -0
  29. package/dist/array/find.cjs +2 -0
  30. package/dist/array/find.cjs.map +1 -0
  31. package/dist/array/find.js +14 -0
  32. package/dist/array/find.js.map +1 -0
  33. package/dist/array/findIndex.cjs +2 -0
  34. package/dist/array/findIndex.cjs.map +1 -0
  35. package/dist/array/findIndex.js +14 -0
  36. package/dist/array/findIndex.js.map +1 -0
  37. package/dist/array/findLast.cjs +2 -0
  38. package/dist/array/findLast.cjs.map +1 -0
  39. package/dist/array/findLast.js +14 -0
  40. package/dist/array/findLast.js.map +1 -0
  41. package/dist/array/flatten.cjs +2 -0
  42. package/dist/array/flatten.cjs.map +1 -0
  43. package/dist/array/flatten.js +7 -0
  44. package/dist/array/flatten.js.map +1 -0
  45. package/dist/array/group.cjs +2 -0
  46. package/dist/array/group.cjs.map +1 -0
  47. package/dist/array/group.js +16 -0
  48. package/dist/array/group.js.map +1 -0
  49. package/dist/array/list.cjs +2 -0
  50. package/dist/array/list.cjs.map +1 -0
  51. package/dist/array/list.js +70 -0
  52. package/dist/array/list.js.map +1 -0
  53. package/dist/array/map.cjs +2 -0
  54. package/dist/array/map.cjs.map +1 -0
  55. package/dist/array/map.js +18 -0
  56. package/dist/array/map.js.map +1 -0
  57. package/dist/array/pick.cjs +2 -0
  58. package/dist/array/pick.cjs.map +1 -0
  59. package/dist/array/pick.js +15 -0
  60. package/dist/array/pick.js.map +1 -0
  61. package/dist/array/reduce.cjs +2 -0
  62. package/dist/array/reduce.cjs.map +1 -0
  63. package/dist/array/reduce.js +16 -0
  64. package/dist/array/reduce.js.map +1 -0
  65. package/dist/array/search.cjs +2 -0
  66. package/dist/array/search.cjs.map +1 -0
  67. package/dist/array/search.js +14 -0
  68. package/dist/array/search.js.map +1 -0
  69. package/dist/array/select.cjs +2 -0
  70. package/dist/array/select.cjs.map +1 -0
  71. package/dist/array/select.js +16 -0
  72. package/dist/array/select.js.map +1 -0
  73. package/dist/array/shift.cjs +2 -0
  74. package/dist/array/shift.cjs.map +1 -0
  75. package/dist/array/shift.js +13 -0
  76. package/dist/array/shift.js.map +1 -0
  77. package/dist/array/some.cjs +2 -0
  78. package/dist/array/some.cjs.map +1 -0
  79. package/dist/array/some.js +14 -0
  80. package/dist/array/some.js.map +1 -0
  81. package/dist/array/sort.cjs +2 -0
  82. package/dist/array/sort.cjs.map +1 -0
  83. package/dist/array/sort.js +13 -0
  84. package/dist/array/sort.js.map +1 -0
  85. package/dist/array/sortBy.cjs +2 -0
  86. package/dist/array/sortBy.cjs.map +1 -0
  87. package/dist/array/sortBy.js +6 -0
  88. package/dist/array/sortBy.js.map +1 -0
  89. package/dist/array/substitute.cjs +2 -0
  90. package/dist/array/substitute.cjs.map +1 -0
  91. package/dist/array/substitute.js +13 -0
  92. package/dist/array/substitute.js.map +1 -0
  93. package/dist/array/uniq.cjs +2 -0
  94. package/dist/array/uniq.cjs.map +1 -0
  95. package/dist/array/uniq.js +18 -0
  96. package/dist/array/uniq.js.map +1 -0
  97. package/dist/date/expires.cjs +2 -0
  98. package/dist/date/expires.cjs.map +1 -0
  99. package/dist/date/expires.js +11 -0
  100. package/dist/date/expires.js.map +1 -0
  101. package/dist/date/interval.cjs +2 -0
  102. package/dist/date/interval.cjs.map +1 -0
  103. package/dist/date/interval.js +39 -0
  104. package/dist/date/interval.js.map +1 -0
  105. package/dist/date/timeDiff.cjs +2 -0
  106. package/dist/date/timeDiff.cjs.map +1 -0
  107. package/dist/date/timeDiff.js +29 -0
  108. package/dist/date/timeDiff.js.map +1 -0
  109. package/dist/function/assert.cjs +3 -0
  110. package/dist/function/assert.cjs.map +1 -0
  111. package/dist/function/assert.js +12 -0
  112. package/dist/function/assert.js.map +1 -0
  113. package/dist/function/assertParams.cjs +2 -0
  114. package/dist/function/assertParams.cjs.map +1 -0
  115. package/dist/function/assertParams.js +13 -0
  116. package/dist/function/assertParams.js.map +1 -0
  117. package/dist/function/attempt.cjs +2 -0
  118. package/dist/function/attempt.cjs.map +1 -0
  119. package/dist/function/attempt.js +15 -0
  120. package/dist/function/attempt.js.map +1 -0
  121. package/dist/function/compare.cjs +2 -0
  122. package/dist/function/compare.cjs.map +1 -0
  123. package/dist/function/compare.js +22 -0
  124. package/dist/function/compare.js.map +1 -0
  125. package/dist/function/compareBy.cjs +2 -0
  126. package/dist/function/compareBy.cjs.map +1 -0
  127. package/dist/function/compareBy.js +15 -0
  128. package/dist/function/compareBy.js.map +1 -0
  129. package/dist/function/compose.cjs +2 -0
  130. package/dist/function/compose.cjs.map +1 -0
  131. package/dist/function/compose.js +14 -0
  132. package/dist/function/compose.js.map +1 -0
  133. package/dist/function/curry.cjs +2 -0
  134. package/dist/function/curry.cjs.map +1 -0
  135. package/dist/function/curry.js +8 -0
  136. package/dist/function/curry.js.map +1 -0
  137. package/dist/function/debounce.cjs +2 -0
  138. package/dist/function/debounce.cjs.map +1 -0
  139. package/dist/function/debounce.js +10 -0
  140. package/dist/function/debounce.js.map +1 -0
  141. package/dist/function/delay.cjs +2 -0
  142. package/dist/function/delay.cjs.map +1 -0
  143. package/dist/function/delay.js +8 -0
  144. package/dist/function/delay.js.map +1 -0
  145. package/dist/function/fp.cjs +2 -0
  146. package/dist/function/fp.cjs.map +1 -0
  147. package/dist/function/fp.js +10 -0
  148. package/dist/function/fp.js.map +1 -0
  149. package/dist/function/memo.cjs +2 -0
  150. package/dist/function/memo.cjs.map +1 -0
  151. package/dist/function/memo.js +24 -0
  152. package/dist/function/memo.js.map +1 -0
  153. package/dist/function/once.cjs +2 -0
  154. package/dist/function/once.cjs.map +1 -0
  155. package/dist/function/once.js +11 -0
  156. package/dist/function/once.js.map +1 -0
  157. package/dist/function/pipe.cjs +2 -0
  158. package/dist/function/pipe.cjs.map +1 -0
  159. package/dist/function/pipe.js +11 -0
  160. package/dist/function/pipe.js.map +1 -0
  161. package/dist/function/predict.cjs +2 -0
  162. package/dist/function/predict.cjs.map +1 -0
  163. package/dist/function/predict.js +13 -0
  164. package/dist/function/predict.js.map +1 -0
  165. package/dist/function/proxy.cjs +2 -0
  166. package/dist/function/proxy.cjs.map +1 -0
  167. package/dist/function/proxy.js +22 -0
  168. package/dist/function/proxy.js.map +1 -0
  169. package/dist/function/retry.cjs +2 -0
  170. package/dist/function/retry.cjs.map +1 -0
  171. package/dist/function/retry.js +25 -0
  172. package/dist/function/retry.js.map +1 -0
  173. package/dist/function/sleep.cjs +2 -0
  174. package/dist/function/sleep.cjs.map +1 -0
  175. package/dist/function/sleep.js +7 -0
  176. package/dist/function/sleep.js.map +1 -0
  177. package/dist/function/throttle.cjs +2 -0
  178. package/dist/function/throttle.cjs.map +1 -0
  179. package/dist/function/throttle.js +11 -0
  180. package/dist/function/throttle.js.map +1 -0
  181. package/dist/function/worker.cjs +14 -0
  182. package/dist/function/worker.cjs.map +1 -0
  183. package/dist/function/worker.js +29 -0
  184. package/dist/function/worker.js.map +1 -0
  185. package/dist/index.cjs +2 -0
  186. package/dist/index.cjs.map +1 -0
  187. package/dist/index.d.ts +2278 -0
  188. package/dist/index.js +217 -0
  189. package/dist/index.js.map +1 -0
  190. package/dist/logit/dist/logit.cjs +2 -0
  191. package/dist/logit/dist/logit.cjs.map +1 -0
  192. package/dist/logit/dist/logit.js +178 -0
  193. package/dist/logit/dist/logit.js.map +1 -0
  194. package/dist/math/average.cjs +2 -0
  195. package/dist/math/average.cjs.map +1 -0
  196. package/dist/math/average.js +19 -0
  197. package/dist/math/average.js.map +1 -0
  198. package/dist/math/boil.cjs +2 -0
  199. package/dist/math/boil.cjs.map +1 -0
  200. package/dist/math/boil.js +17 -0
  201. package/dist/math/boil.js.map +1 -0
  202. package/dist/math/clamp.cjs +2 -0
  203. package/dist/math/clamp.cjs.map +1 -0
  204. package/dist/math/clamp.js +7 -0
  205. package/dist/math/clamp.js.map +1 -0
  206. package/dist/math/max.cjs +2 -0
  207. package/dist/math/max.cjs.map +1 -0
  208. package/dist/math/max.js +12 -0
  209. package/dist/math/max.js.map +1 -0
  210. package/dist/math/median.cjs +2 -0
  211. package/dist/math/median.cjs.map +1 -0
  212. package/dist/math/median.js +11 -0
  213. package/dist/math/median.js.map +1 -0
  214. package/dist/math/min.cjs +2 -0
  215. package/dist/math/min.cjs.map +1 -0
  216. package/dist/math/min.js +12 -0
  217. package/dist/math/min.js.map +1 -0
  218. package/dist/math/range.cjs +2 -0
  219. package/dist/math/range.cjs.map +1 -0
  220. package/dist/math/range.js +10 -0
  221. package/dist/math/range.js.map +1 -0
  222. package/dist/math/rate.cjs +2 -0
  223. package/dist/math/rate.cjs.map +1 -0
  224. package/dist/math/rate.js +9 -0
  225. package/dist/math/rate.js.map +1 -0
  226. package/dist/math/round.cjs +2 -0
  227. package/dist/math/round.cjs.map +1 -0
  228. package/dist/math/round.js +9 -0
  229. package/dist/math/round.js.map +1 -0
  230. package/dist/math/sum.cjs +2 -0
  231. package/dist/math/sum.cjs.map +1 -0
  232. package/dist/math/sum.js +22 -0
  233. package/dist/math/sum.js.map +1 -0
  234. package/dist/object/clone.cjs +2 -0
  235. package/dist/object/clone.cjs.map +1 -0
  236. package/dist/object/clone.js +7 -0
  237. package/dist/object/clone.js.map +1 -0
  238. package/dist/object/diff.cjs +2 -0
  239. package/dist/object/diff.cjs.map +1 -0
  240. package/dist/object/diff.js +18 -0
  241. package/dist/object/diff.js.map +1 -0
  242. package/dist/object/entries.cjs +2 -0
  243. package/dist/object/entries.cjs.map +1 -0
  244. package/dist/object/entries.js +9 -0
  245. package/dist/object/entries.js.map +1 -0
  246. package/dist/object/keys.cjs +2 -0
  247. package/dist/object/keys.cjs.map +1 -0
  248. package/dist/object/keys.js +9 -0
  249. package/dist/object/keys.js.map +1 -0
  250. package/dist/object/merge.cjs +2 -0
  251. package/dist/object/merge.cjs.map +1 -0
  252. package/dist/object/merge.js +29 -0
  253. package/dist/object/merge.js.map +1 -0
  254. package/dist/object/parseJSON.cjs +2 -0
  255. package/dist/object/parseJSON.cjs.map +1 -0
  256. package/dist/object/parseJSON.js +19 -0
  257. package/dist/object/parseJSON.js.map +1 -0
  258. package/dist/object/path.cjs +2 -0
  259. package/dist/object/path.cjs.map +1 -0
  260. package/dist/object/path.js +24 -0
  261. package/dist/object/path.js.map +1 -0
  262. package/dist/object/seek.cjs +2 -0
  263. package/dist/object/seek.cjs.map +1 -0
  264. package/dist/object/seek.js +11 -0
  265. package/dist/object/seek.js.map +1 -0
  266. package/dist/object/values.cjs +2 -0
  267. package/dist/object/values.cjs.map +1 -0
  268. package/dist/object/values.js +9 -0
  269. package/dist/object/values.js.map +1 -0
  270. package/dist/random/draw.cjs +2 -0
  271. package/dist/random/draw.cjs.map +1 -0
  272. package/dist/random/draw.js +11 -0
  273. package/dist/random/draw.js.map +1 -0
  274. package/dist/random/random.cjs +2 -0
  275. package/dist/random/random.cjs.map +1 -0
  276. package/dist/random/random.js +10 -0
  277. package/dist/random/random.js.map +1 -0
  278. package/dist/random/shuffle.cjs +2 -0
  279. package/dist/random/shuffle.cjs.map +1 -0
  280. package/dist/random/shuffle.js +15 -0
  281. package/dist/random/shuffle.js.map +1 -0
  282. package/dist/random/uuid.cjs +2 -0
  283. package/dist/random/uuid.cjs.map +1 -0
  284. package/dist/random/uuid.js +7 -0
  285. package/dist/random/uuid.js.map +1 -0
  286. package/dist/string/_caseUtils.cjs +2 -0
  287. package/dist/string/_caseUtils.cjs.map +1 -0
  288. package/dist/string/_caseUtils.js +9 -0
  289. package/dist/string/_caseUtils.js.map +1 -0
  290. package/dist/string/camelCase.cjs +2 -0
  291. package/dist/string/camelCase.cjs.map +1 -0
  292. package/dist/string/camelCase.js +8 -0
  293. package/dist/string/camelCase.js.map +1 -0
  294. package/dist/string/kebabCase.cjs +2 -0
  295. package/dist/string/kebabCase.cjs.map +1 -0
  296. package/dist/string/kebabCase.js +8 -0
  297. package/dist/string/kebabCase.js.map +1 -0
  298. package/dist/string/pascalCase.cjs +2 -0
  299. package/dist/string/pascalCase.cjs.map +1 -0
  300. package/dist/string/pascalCase.js +8 -0
  301. package/dist/string/pascalCase.js.map +1 -0
  302. package/dist/string/similarity.cjs +2 -0
  303. package/dist/string/similarity.cjs.map +1 -0
  304. package/dist/string/similarity.js +34 -0
  305. package/dist/string/similarity.js.map +1 -0
  306. package/dist/string/snakeCase.cjs +2 -0
  307. package/dist/string/snakeCase.cjs.map +1 -0
  308. package/dist/string/snakeCase.js +8 -0
  309. package/dist/string/snakeCase.js.map +1 -0
  310. package/dist/string/truncate.cjs +2 -0
  311. package/dist/string/truncate.cjs.map +1 -0
  312. package/dist/string/truncate.js +9 -0
  313. package/dist/string/truncate.js.map +1 -0
  314. package/dist/typed/ge.cjs +2 -0
  315. package/dist/typed/ge.cjs.map +1 -0
  316. package/dist/typed/ge.js +7 -0
  317. package/dist/typed/ge.js.map +1 -0
  318. package/dist/typed/gt.cjs +2 -0
  319. package/dist/typed/gt.cjs.map +1 -0
  320. package/dist/typed/gt.js +7 -0
  321. package/dist/typed/gt.js.map +1 -0
  322. package/dist/typed/is.cjs +2 -0
  323. package/dist/typed/is.cjs.map +1 -0
  324. package/dist/typed/is.js +44 -0
  325. package/dist/typed/is.js.map +1 -0
  326. package/dist/typed/isArray.cjs +2 -0
  327. package/dist/typed/isArray.cjs.map +1 -0
  328. package/dist/typed/isArray.js +9 -0
  329. package/dist/typed/isArray.js.map +1 -0
  330. package/dist/typed/isBoolean.cjs +2 -0
  331. package/dist/typed/isBoolean.cjs.map +1 -0
  332. package/dist/typed/isBoolean.js +7 -0
  333. package/dist/typed/isBoolean.js.map +1 -0
  334. package/dist/typed/isDate.cjs +2 -0
  335. package/dist/typed/isDate.cjs.map +1 -0
  336. package/dist/typed/isDate.js +9 -0
  337. package/dist/typed/isDate.js.map +1 -0
  338. package/dist/typed/isDefined.cjs +2 -0
  339. package/dist/typed/isDefined.cjs.map +1 -0
  340. package/dist/typed/isDefined.js +7 -0
  341. package/dist/typed/isDefined.js.map +1 -0
  342. package/dist/typed/isEmpty.cjs +2 -0
  343. package/dist/typed/isEmpty.cjs.map +1 -0
  344. package/dist/typed/isEmpty.js +12 -0
  345. package/dist/typed/isEmpty.js.map +1 -0
  346. package/dist/typed/isEqual.cjs +2 -0
  347. package/dist/typed/isEqual.cjs.map +1 -0
  348. package/dist/typed/isEqual.js +25 -0
  349. package/dist/typed/isEqual.js.map +1 -0
  350. package/dist/typed/isEven.cjs +2 -0
  351. package/dist/typed/isEven.cjs.map +1 -0
  352. package/dist/typed/isEven.js +7 -0
  353. package/dist/typed/isEven.js.map +1 -0
  354. package/dist/typed/isFunction.cjs +2 -0
  355. package/dist/typed/isFunction.cjs.map +1 -0
  356. package/dist/typed/isFunction.js +9 -0
  357. package/dist/typed/isFunction.js.map +1 -0
  358. package/dist/typed/isMatch.cjs +2 -0
  359. package/dist/typed/isMatch.cjs.map +1 -0
  360. package/dist/typed/isMatch.js +19 -0
  361. package/dist/typed/isMatch.js.map +1 -0
  362. package/dist/typed/isNegative.cjs +2 -0
  363. package/dist/typed/isNegative.cjs.map +1 -0
  364. package/dist/typed/isNegative.js +7 -0
  365. package/dist/typed/isNegative.js.map +1 -0
  366. package/dist/typed/isNil.cjs +2 -0
  367. package/dist/typed/isNil.cjs.map +1 -0
  368. package/dist/typed/isNil.js +9 -0
  369. package/dist/typed/isNil.js.map +1 -0
  370. package/dist/typed/isNumber.cjs +2 -0
  371. package/dist/typed/isNumber.cjs.map +1 -0
  372. package/dist/typed/isNumber.js +9 -0
  373. package/dist/typed/isNumber.js.map +1 -0
  374. package/dist/typed/isObject.cjs +2 -0
  375. package/dist/typed/isObject.cjs.map +1 -0
  376. package/dist/typed/isObject.js +9 -0
  377. package/dist/typed/isObject.js.map +1 -0
  378. package/dist/typed/isOdd.cjs +2 -0
  379. package/dist/typed/isOdd.cjs.map +1 -0
  380. package/dist/typed/isOdd.js +7 -0
  381. package/dist/typed/isOdd.js.map +1 -0
  382. package/dist/typed/isPositive.cjs +2 -0
  383. package/dist/typed/isPositive.cjs.map +1 -0
  384. package/dist/typed/isPositive.js +7 -0
  385. package/dist/typed/isPositive.js.map +1 -0
  386. package/dist/typed/isPrimitive.cjs +2 -0
  387. package/dist/typed/isPrimitive.cjs.map +1 -0
  388. package/dist/typed/isPrimitive.js +10 -0
  389. package/dist/typed/isPrimitive.js.map +1 -0
  390. package/dist/typed/isPromise.cjs +2 -0
  391. package/dist/typed/isPromise.cjs.map +1 -0
  392. package/dist/typed/isPromise.js +10 -0
  393. package/dist/typed/isPromise.js.map +1 -0
  394. package/dist/typed/isRegex.cjs +2 -0
  395. package/dist/typed/isRegex.cjs.map +1 -0
  396. package/dist/typed/isRegex.js +7 -0
  397. package/dist/typed/isRegex.js.map +1 -0
  398. package/dist/typed/isString.cjs +2 -0
  399. package/dist/typed/isString.cjs.map +1 -0
  400. package/dist/typed/isString.js +9 -0
  401. package/dist/typed/isString.js.map +1 -0
  402. package/dist/typed/isWithin.cjs +2 -0
  403. package/dist/typed/isWithin.cjs.map +1 -0
  404. package/dist/typed/isWithin.js +10 -0
  405. package/dist/typed/isWithin.js.map +1 -0
  406. package/dist/typed/isZero.cjs +2 -0
  407. package/dist/typed/isZero.cjs.map +1 -0
  408. package/dist/typed/isZero.js +7 -0
  409. package/dist/typed/isZero.js.map +1 -0
  410. package/dist/typed/le.cjs +2 -0
  411. package/dist/typed/le.cjs.map +1 -0
  412. package/dist/typed/le.js +7 -0
  413. package/dist/typed/le.js.map +1 -0
  414. package/dist/typed/lt.cjs +2 -0
  415. package/dist/typed/lt.cjs.map +1 -0
  416. package/dist/typed/lt.js +7 -0
  417. package/dist/typed/lt.js.map +1 -0
  418. package/dist/typed/typeOf.cjs +2 -0
  419. package/dist/typed/typeOf.cjs.map +1 -0
  420. package/dist/typed/typeOf.js +14 -0
  421. package/dist/typed/typeOf.js.map +1 -0
  422. package/package.json +38 -0
@@ -0,0 +1,2278 @@
1
+ /**
2
+ * Aggregates an array of objects into an object based on a key generated by a selector function.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * const data = [{ a: 1 }, { a: 2 }, { a: 1 }];
7
+ * aggregate(data, 'a') // { '1': { a: 1 }, '2': { a: 2 } };
8
+ * ```
9
+ *
10
+ * @param array - The array to key.
11
+ * @param selector - The function to generate the key for each element. It can be a string representing the key or a function that returns the key.
12
+ *
13
+ * @returns An object with keys as the generated values and values as the last element responsible for generating the key.
14
+ *
15
+ * @throws {TypeError} If the provided array is not an array.
16
+ */
17
+ export declare function aggregate<T, K extends keyof T, R extends T[K] extends string ? T[K] : never>(array: T[], selector: Selector<T>): Record<R, T>;
18
+
19
+ export declare namespace aggregate {
20
+ var fp: boolean;
21
+ }
22
+
23
+ /**
24
+ * Either adds or removes an item from an array, based on whether it already exists in the array.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * alternate([1, 2, 3], 4) // [1, 2, 3, 4]
29
+ * alternate([1, 2, 3], 2) // [1, 3]
30
+ *
31
+ * alternate(
32
+ * [{ id: 1 }, { id: 2 }],
33
+ * { id: 3 },
34
+ * (obj) => obj.id,
35
+ * { strategy: 'prepend' }
36
+ * ) // [{ id: 3 }, { id: 1 }, { id: 2 }]
37
+ * ```
38
+ *
39
+ * @param array - The array to modify.
40
+ * @param item - The item to add or remove.
41
+ * @param selector - A function to determine the uniqueness of the item.
42
+ * @param [options] - Options for the alternate operation.
43
+ * @param [options.strategy] - The strategy to use when adding the item ('prepend' or 'append').
44
+ *
45
+ * @returns A new array with the item added or removed.
46
+ */
47
+ export declare function alternate<T>(array: T[], item: T, selector?: (item: T) => Primitive, options?: {
48
+ strategy?: 'prepend' | 'append';
49
+ }): T[];
50
+
51
+ export declare namespace alternate {
52
+ var fp: boolean;
53
+ }
54
+
55
+ export declare type ArgType = 'array' | 'boolean' | 'date' | 'error' | 'function' | 'map' | 'nan' | 'null' | 'number' | 'object' | 'promise' | 'regexp' | 'set' | 'string' | 'symbol' | 'weakmap' | 'weakset' | 'undefined';
56
+
57
+ /**
58
+ * Asserts that the condition is true. If the condition is false, it throws an error
59
+ * with the provided message or logs a warning in soft mode.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * assert(Array.isArray([])); // Does nothing
64
+ * assert(typeof foo === 'string', 'This is an error message'); // Throws an error
65
+ * assert(x > 0, 'x must be positive', { args: { x } }); // Throws with argument details
66
+ * ```
67
+ *
68
+ * @param condition - The condition to assert, or an array of conditions.
69
+ * @param [message] - The error message to throw. Default is 'Assertion failed'.
70
+ * @param options - Assertion options.
71
+ * @param [options.type] - The error class to throw (default: `Error`).
72
+ * @param [options.args] - Additional debugging information (e.g., variable values).
73
+ * @param [options.bypass] - If `true`, logs a warning instead of throwing an error.
74
+ *
75
+ * @throws {Error} If the condition is false and `bypass` is not set to `true`.
76
+ */
77
+ declare function assert_2(condition: boolean | boolean[], message?: string, { type, args, bypass }?: {
78
+ type?: ErrorConstructor;
79
+ args?: Obj;
80
+ bypass?: boolean;
81
+ }): void;
82
+ export { assert_2 as assert }
83
+
84
+ /**
85
+ * Asserts that the specified keys are present in the params object and are not empty strings.
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * const params = { id: '123', name: '' };
90
+ * assertParams(params, ['id']); // Does nothing
91
+ * assertParams(params, ['id', 'name'], 'UserUpdate'); // Throws: Missing required parameter: "name" in "UserUpdate"
92
+ * ```
93
+ *
94
+ * @param params - The object containing the parameters to check.
95
+ * @param keys - An array of keys that must be present and non-empty in the params object.
96
+ * @param [name] - An optional name for the context of the assertion (e.g., function name).
97
+ * @param [options] - Assertion options.
98
+ * @param [options.type] - The error class to throw (default: `Error`).
99
+ * @param [options.bypass] - If `true`, logs a warning instead of throwing an error.
100
+ *
101
+ * @throws {Error} If any of the required keys are missing or are empty strings.
102
+ */
103
+ export declare function assertParams<T extends object, K extends keyof T>(params: T, keys: K[], name?: string, options?: {
104
+ type?: ErrorConstructor;
105
+ bypass?: boolean;
106
+ }): asserts params is T & Required<Pick<T, K>>;
107
+
108
+ declare type AsyncCallback<R, T> = (prev: R, curr: T, index: number, array: T[]) => Promise<R>;
109
+
110
+ /**
111
+ * Attempts to execute a function with advanced error handling and retry logic.
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * const unreliableFunction = async () => {
116
+ * if (Math.random() < 0.7) throw new Error ('Random failure');
117
+ * return 'Success!';
118
+ * };
119
+ *
120
+ * await attempt(
121
+ * unreliableFunction,
122
+ * { retries: 3, silent: false, timeout: 5000 }); // Success! (or undefined if all attempts failed)
123
+ * ```
124
+ *
125
+ * @param fn - The function to be executed.
126
+ * @param [options] - Configuration options for the attempt.
127
+ * @param [options.identifier] - Custom identifier for logging purposes.
128
+ * @param [options.retries=0] - Number of retry attempts if the function fails.
129
+ * @param [options.silent=false] - If true, suppresses error logging.
130
+ * @param [options.timeout=7000] - Timeout in milliseconds for function execution.
131
+ *
132
+ * @returns The result of the function or undefined if it failed.
133
+ */
134
+ export declare function attempt<T extends Fn, R = Awaited<ReturnType<T>>>(fn: T, { silent, retries, timeout, identifier }?: AttemptOptions): Promise<R | undefined>;
135
+
136
+ declare type AttemptOptions = {
137
+ identifier?: string;
138
+ retries?: number;
139
+ silent?: boolean;
140
+ timeout?: number;
141
+ };
142
+
143
+ /**
144
+ * Calculates the average of an array of numbers or dates.
145
+ *
146
+ * @example
147
+ * ```ts
148
+ * const arr = [1, 2, 3, 4, 5];
149
+ * average(arr); // 3
150
+ * average(arr, (num) => num * 2); // 6
151
+ * average(arr, (num) => new Date(Date.now() + 1000 * 60 * 60 * 24 * num); // Date object representing 3 days from now
152
+ * ```
153
+ *
154
+ * @param array - The array of numbers or dates to average.
155
+ * @param callback - (optional) A callback function to map the values.
156
+ * @returns The average of the numbers or dates in the array.
157
+ */
158
+ export declare function average<T>(array: T[], callback?: (item: T) => number | Date): number | Date | undefined;
159
+
160
+ /**
161
+ * Boils down an array to a single value by applying a callback function to each pair of elements.
162
+ *
163
+ * @example
164
+ * ```ts
165
+ * boil([1, 2, 3]) // 3
166
+ * boil([1, 2, 3], (a, b) => a > b ? a : b) // 3
167
+ * boil([1, 2, 3], (a, b) => a + b) // 6
168
+ * boil([{ a: 1 }, { a: 2 }, { a: 3 }], (a, b) => ({ a: a.a + b.a })) // { a: 6 }
169
+ * boil([], (a, b) => a + b) // undefined
170
+ * boil([1], (a, b) => a + b) // 1
171
+ * ```
172
+ *
173
+ * @param array - The array to be boiled down.
174
+ * @param callback - The function to invoke for each pair of elements in the array.
175
+ *
176
+ * @return The boiled down value, or `undefined` if the array is empty.
177
+ */
178
+ export declare function boil<T>(array: readonly T[], callback: (a: T, b: T) => T): T | undefined;
179
+
180
+ /** biome-ignore-all lint/suspicious/noExplicitAny: - */
181
+ export declare type Callback<T = any, R = any> = (value: T, index: number, array: T[]) => R;
182
+
183
+ declare type Callback_2<R, T> = SyncCallback<R, T> | AsyncCallback<R, T>;
184
+
185
+ export declare type CallbackAsync<T = any, R = any> = (value: T, index: number, array: T[]) => Promise<R>;
186
+
187
+ export declare type CallbackDynamic<T = any, R = any> = (value: T, index: number, array: T[]) => R | Promise<R>;
188
+
189
+ /**
190
+ * Converts a string to camel case.
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * const text = 'hello world';
195
+ * camelCase(text); // 'helloWorld'
196
+ * ```
197
+ *
198
+ * @param str - The string to convert.
199
+ * @returns The converted string.
200
+ */
201
+ export declare function camelCase(str: string): string;
202
+
203
+ /**
204
+ * Splits an array or string into chunks of a specified size.
205
+ *
206
+ * @example
207
+ * ```ts
208
+ * chunk([1, 2, 3, 4, 5], 2) // [[1, 2], [3, 4], [5]]
209
+ * chunk("hello", 2) // ["he", "ll", "o"]
210
+ * chunk("hello", 2, { overlap: true }) // [" h", "he", "el", "ll", "lo", "o "]
211
+ * ```
212
+ *
213
+ * @param input - The input array or string to be chunked.
214
+ * @param size - The size of each chunk.
215
+ * @param [options] - Additional options for chunking.
216
+ * @param [options.overlap] -
217
+ * @param [options.pad] -
218
+ *
219
+ * @returns An array of chunks.
220
+ *
221
+ * @throws {RangeError} If the chunk size is invalid.
222
+ * @throws {TypeError} If the input type is invalid.
223
+ */
224
+ export declare function chunk<T>(input: T[] | string, size?: number, options?: ChunkOptions): ChunkResult<T>;
225
+
226
+ declare type ChunkOptions = {
227
+ overlap?: boolean;
228
+ pad?: string;
229
+ };
230
+
231
+ declare type ChunkResult<T> = (T extends string ? string : T[])[];
232
+
233
+ /**
234
+ * The `clamp` function restricts a number to be within a specified range.
235
+ *
236
+ * @example
237
+ * ```ts
238
+ * clamp(5, 1, 10) // 5
239
+ * clamp(0, 1, 10) // 1
240
+ * clamp(15, 1, 10) // 10
241
+ * ```
242
+ *
243
+ * @param n - The number to be clamped.
244
+ * @param min - The minimum value of the range.
245
+ * @param max - The maximum value of the range.
246
+ *
247
+ * @returns The clamped number.
248
+ */
249
+ export declare function clamp(n: number, min: number, max: number): number;
250
+
251
+ /**
252
+ * Creates a deep copy of the provided data using the structuredClone algorithm.
253
+ *
254
+ * @example
255
+ * ```ts
256
+ * const obj = { a: 1, b: { c: 2 } };
257
+ * const dup = clone(obj);
258
+ *
259
+ * dup.b.c = 3;
260
+ * console.log(obj.b.c); // logs 2
261
+ * console.log(dup.b.c); // logs 3
262
+ * ```
263
+ *
264
+ * @param item - The data to clone.
265
+ *
266
+ * @returns A deep copy of the provided data.
267
+ */
268
+ export declare function clone<T>(item: T): T;
269
+
270
+ /**
271
+ * Removes falsy values from an array.
272
+ *
273
+ * @example
274
+ * ```ts
275
+ * const arr = [0, 1, false, 2, '', 3];
276
+ * compact(arr); // [1, 2, 3]
277
+ * ```
278
+ *
279
+ * @param array - The array to compact.
280
+ *
281
+ * @returns A new array with falsy values removed.
282
+ *
283
+ * @throws {TypeError} If the provided array is not an array.
284
+ */
285
+ export declare function compact<T>(array: T[]): NonNullable<T>[];
286
+
287
+ /**
288
+ * Compares two values and returns:
289
+ * - 0 if they are equal
290
+ * - 1 if the first value is greater
291
+ * - -1 if the second value is greater
292
+ *
293
+ * @example
294
+ * ```ts
295
+ * compare('a', 'b'); // -1
296
+ * compare(1, 2); // -1
297
+ * compare(new Date('2023-01-01'), new Date('2023-01-02')); // -1
298
+ * compare('a', 'a'); // 0
299
+ * compare(1, 1); // 0
300
+ * compare(new Date('2023-01-01'), new Date('2023-01-01')); // 0
301
+ * ```
302
+ *
303
+ * @param a - The first value to compare.
304
+ * @param b - The second value to compare.
305
+ *
306
+ * @returns 0 if equal, 1 if the first value is greater, -1 if the second value is greater.
307
+ */
308
+ export declare const compare: (a: any, b: any) => number;
309
+
310
+ /**
311
+ * Compares two objects based on multiple selectors.
312
+ * The comparison is done in the order of the selectors provided.
313
+ * Each selector can be 'asc' for ascending or 'desc' for descending order.
314
+ *
315
+ * @example
316
+ * ```ts
317
+ * const compareByNameAndAge = compareBy<{ name: string; age: number }>({
318
+ * name: 'asc',
319
+ * age: 'desc',
320
+ * });
321
+ *
322
+ * const a = { name: 'Alice', age: 30 };
323
+ * const b = { name: 'Bob', age: 25 };
324
+ *
325
+ * console.log(compareByNameAndAge(a, b)); // -1 (Alice < Bob)
326
+ * ```
327
+ *
328
+ * @param selectors - An object where keys are properties to compare and values are 'asc' or 'desc'.
329
+ *
330
+ * @returns A comparison function that can be used with array sorting methods.
331
+ */
332
+ export declare const compareBy: <T>(selectors: Partial<Record<keyof T, "asc" | "desc">>) => (a: T, b: T) => number;
333
+
334
+ /**
335
+ * Composes multiple functions into a single function. It starts from the rightmost function and proceeds to the left.
336
+ *
337
+ * @example
338
+ * ```ts
339
+ * const add = (x) => x + 2;
340
+ * const multiply = (x) => x * 3;
341
+ * const subtract = (x) => x - 4;
342
+ * const composedFn = compose(subtract, multiply, add);
343
+ * composedFn(5); // ((5 + 2) * 3) - 4 = 17
344
+ * ```
345
+ *
346
+ * @example
347
+ * ```ts
348
+ * const square = async (x) => x * x;
349
+ * const add = async (x) => x + 2;
350
+ * const composedFn = compose(square, add);
351
+ * await composedFn(4); // (4 * 4) + 2 = 18
352
+ * ```
353
+ *
354
+ * @param fns - List of the functions to be composed.
355
+ *
356
+ * @returns A new function that is the composition of the input functions.
357
+ */
358
+ export declare function compose<T extends FnDynamic[]>(...fns: T): ComposeReturn<T>;
359
+
360
+ declare type ComposeReturn<T extends FnDynamic[]> = (...args: LastParameters<T>) => FirstReturnType<T> extends Promise<any> ? Promise<Awaited<FirstReturnType<T>>> : FirstReturnType<T>;
361
+
362
+ declare type Config<T> = {
363
+ filterFn?: Predicate<T>;
364
+ limit?: number;
365
+ sortFn?: (a: T, b: T) => number;
366
+ };
367
+
368
+ /**
369
+ * Checks if a value is present in an array.
370
+ *
371
+ * @example
372
+ * ```ts
373
+ * const arr = [1, 2, 3, { a: 1 }, 'hello'];
374
+ * const value = { a: 1 };
375
+ * contains(arr, value) // true;
376
+ * ```
377
+ *
378
+ * @param array - The array to check.
379
+ * @param value - The value to search for.
380
+ *
381
+ * @returns true if the value is present in the array, else false.
382
+ *
383
+ * @throws {TypeError} If the first argument is not an array.
384
+ */
385
+ export declare function contains<T>(array: T[], value: any): boolean;
386
+
387
+ export declare namespace contains {
388
+ var fp: boolean;
389
+ }
390
+
391
+ declare type CurriedFunction<Params extends any[], R> = Params extends [infer A, ...infer Rest] ? (arg: A) => CurriedFunction<Rest, R> : R;
392
+
393
+ /**
394
+ * Curries a function, allowing it to be called with partial arguments.
395
+ *
396
+ * @example
397
+ * ```ts
398
+ * const add = (a: number, b: number) => a + b;
399
+ * const curriedAdd = curry(add);
400
+ * curriedAdd(1)(2) // 3;
401
+ * ```
402
+ *
403
+ * @param fn - The function to curry.
404
+ *
405
+ * @returns A curried version of the function.
406
+ */
407
+ export declare const curry: <T extends (...args: any[]) => any>(fn: T) => T extends (...args: infer P) => infer R ? CurriedFunction<P, R> : never;
408
+
409
+ /**
410
+ * Creates a debounced function that delays invoking the provided function until after
411
+ * a specified wait time has elapsed since the last invocation.
412
+ *
413
+ * @example
414
+ * ```ts
415
+ * const debouncedLog = debounce(console.log, 1000);
416
+ *
417
+ * debouncedLog('Hello'); // Will log after 1 second if not called again
418
+ * debouncedLog('World'); // Resets the timer, will log 'World' after 1 second
419
+ * ```
420
+ *
421
+ * @param fn - The function to debounce.
422
+ * @param [delay=300] - - The number of milliseconds to delay invoking the function.
423
+ *
424
+ * @returns - A debounced function
425
+ */
426
+ export declare function debounce<T extends Fn>(fn: T, delay?: number): (...args: Parameters<T>) => void;
427
+
428
+ declare type DeepMerge<T, U> = T extends Obj ? U extends Obj ? {
429
+ [K in keyof T | keyof U]: K extends keyof T ? K extends keyof U ? DeepMerge<T[K], U[K]> : T[K] : K extends keyof U ? U[K] : never;
430
+ } : U : U;
431
+
432
+ /**
433
+ * Delays the execution of a function by a specified amount of time.
434
+ *
435
+ * @example
436
+ * ```ts
437
+ * const log = () => console.log('Hello, world!');
438
+ *
439
+ * delay(log, 1000); // logs 'Hello, world!' after 1 second
440
+ * ```
441
+ *
442
+ * @param fn - The function to be delayed.
443
+ * @param delay - The amount of time to delay the function execution, in milliseconds. Default is 700.
444
+ *
445
+ * @returns A Promise that resolves with the result of the function execution.
446
+ */
447
+ export declare function delay<T extends Fn>(fn: T, delay?: number): Promise<any>;
448
+
449
+ /**
450
+ * Computes the difference between two objects.
451
+ *
452
+ * @example
453
+ * ```ts
454
+ * const obj1 = { a: 1, b: 2, c: 3 };
455
+ * const obj2 = { b: 2, c: 3, d: 4 };
456
+ *
457
+ * diff(obj1, obj2); // { d: 4 }
458
+ * ```
459
+ *
460
+ * @param curr - The current object.
461
+ * @param prev - The previous object.
462
+ * @param [compareFn] - A custom function to compare values.
463
+ * @returns An object containing new/modified properties.
464
+ */
465
+ export declare function diff<T extends Obj>(curr?: T, prev?: T, compareFn?: (a: unknown, b: unknown) => boolean): Partial<T>;
466
+
467
+ /**
468
+ * “Draw” a random item from an array.
469
+ *
470
+ * @example
471
+ * ```ts
472
+ * draw([1, 2, 3]) // 3
473
+ * ```
474
+ *
475
+ * @param array - The array to draw from.
476
+ *
477
+ * @returns A random item from the array or `undefined` if the array is empty.
478
+ *
479
+ * @throws {TypeError} If the provided array is not an array.
480
+ */
481
+ export declare const draw: <T>(array: T[]) => T | undefined;
482
+
483
+ declare type Entries<T> = {
484
+ [K in keyof T]: [K, T[K]];
485
+ }[keyof T][];
486
+
487
+ /**
488
+ * Returns an array of a given object's own enumerable string-keyed property [key, value] pairs.
489
+ *
490
+ * @example
491
+ * ```ts
492
+ * const obj = { a: 1, b: 2, c: 3 };
493
+ * entries(obj); // logs [['a', 1], ['b', 2], ['c', 3]]
494
+ * ```
495
+ *
496
+ * @param item - The object whose properties are to be returned.
497
+ *
498
+ * @returns an array of the object's own enumerable string-keyed property [key, value] pairs.
499
+ */
500
+ export declare function entries<T extends Obj>(item: T): Entries<T>;
501
+
502
+ /**
503
+ * Checks if all elements in an array pass a predicate function.
504
+ *
505
+ * @example
506
+ * ```ts
507
+ * const arr = [1, 2, 3, 4, 5];
508
+ * const isEven = (num) => num % 2 === 0;
509
+ * every(arr, isEven); // false
510
+ * ```
511
+ *
512
+ * @param array - The array to check.
513
+ * @param predicate - The predicate function to test each element.
514
+ *
515
+ * @returns true if all elements pass the predicate test, else false.
516
+ *
517
+ * @throws {TypeError} If the first argument is not an array.
518
+ */
519
+ export declare function every<T>(array: T[], predicate: Predicate<T>): boolean;
520
+
521
+ export declare namespace every {
522
+ var fp: boolean;
523
+ }
524
+
525
+ export declare type Expires = 'EXPIRED' | 'SOON' | 'LATER' | 'NEVER' | 'UNKNOWN';
526
+
527
+ /**
528
+ * Determines the expiry status of a given date.
529
+ *
530
+ * @param date - The date to check, as a string or Date object.
531
+ * @param days - Number of days before expiry to be considered "SOON" (default: 7).
532
+ * @returns
533
+ * - 'EXPIRED' if the date is in the past,
534
+ * - 'SOON' if the date is within the next `days`,
535
+ * - 'LATER' if the date is further in the future,
536
+ * - 'NEVER' if the year is >= 9999,
537
+ * - 'UNKNOWN' if the date is invalid.
538
+ */
539
+ export declare function expires(date: string | Date, days?: number): Expires;
540
+
541
+ /**
542
+ * Filters an array based on a predicate function.
543
+ *
544
+ * @example
545
+ * ```ts
546
+ * const arr = [1, 2, 3, 4, 5];
547
+ * const isEven = (num) => num % 2 === 0;
548
+ * filter(arr, isEven); // [2, 4]
549
+ * ```
550
+ *
551
+ * @param array - The array to filter.
552
+ * @param predicate - The predicate function to test each element.
553
+ *
554
+ * @returns A new array with elements that pass the predicate test.
555
+ *
556
+ * @throws {TypeError} If the provided array is not an array.
557
+ */
558
+ export declare function filter<T>(array: T[], predicate: Predicate<T>): T[];
559
+
560
+ export declare namespace filter {
561
+ var fp: boolean;
562
+ }
563
+
564
+ /**
565
+ * Finds the first element in an array that satisfies a predicate function.
566
+ *
567
+ * @example
568
+ * ```ts
569
+ * const arr = [1, 2, 3, 4, 5];
570
+ * const isEven = (num) => num % 2 === 0;
571
+ * find(arr, isEven); // 2
572
+ * find(arr, (num) => num > 5, 0); // 0
573
+ * find(arr, (num) => num > 5); // undefined
574
+ * ```
575
+ *
576
+ * @param array - The array to search through.
577
+ * @param predicate - A function that is called for each element in the array.
578
+ * @param [defaultValue] - (optional) value to return if no element satisfies the predicate.
579
+ *
580
+ * @return The first element in the array that satisfies the predicate, or the default value if none match.
581
+ */
582
+ export declare function find<T>(array: T[], predicate: Predicate<T>, defaultValue?: T): T | undefined;
583
+
584
+ export declare namespace find {
585
+ var fp: boolean;
586
+ }
587
+
588
+ /**
589
+ * Finds the first element in an array that satisfies a predicate function. If no such element is found, returns -1.
590
+ *
591
+ * @example
592
+ * ```ts
593
+ * const arr = [1, 2, 3, 4, 5];
594
+ * const isEven = (num) => num % 2 === 0;
595
+ * findIndex(arr, isEven); // 1
596
+ * findIndex(arr, (num) => num > 5); // -1
597
+ * ```
598
+ *
599
+ * @param array - The array to search.
600
+ * @param predicate - A function that is called for each element in the array.
601
+ *
602
+ * @return The index of the first element that satisfies the predicate, or -1 if no such element is found.
603
+ */
604
+ export declare function findIndex<T>(array: T[], predicate: Predicate<T>): number;
605
+
606
+ export declare namespace findIndex {
607
+ var fp: boolean;
608
+ }
609
+
610
+ /**
611
+ * Finds the last element in the array that satisfies the provided predicate function.
612
+ * If no such element is found, returns the specified default value (if provided).
613
+ *
614
+ * @example
615
+ * ```ts
616
+ * const arr = [1, 2, 3, 4, 5];
617
+ * const isEven = (num) => num % 2 === 0;
618
+ * findLast(arr, isEven); // 4
619
+ * findLast(arr, (num) => num > 5, 0); // 0
620
+ * findLast(arr, (num) => num > 5); // undefined
621
+ * ```
622
+ *
623
+ * @param array - The array to search through.
624
+ * @param predicate - A function to test each element of the array.
625
+ * @param [defaultValue] - The value to return if no element satisfies the predicate.
626
+ *
627
+ * @return The last element in the array that satisfies the predicate, or the default value if none match.
628
+ */
629
+ export declare function findLast<T>(array: T[], predicate: Predicate<T>, defaultValue?: T): T | undefined;
630
+
631
+ export declare namespace findLast {
632
+ var fp: boolean;
633
+ }
634
+
635
+ declare type FirstParameters<T> = T extends [infer First extends FnDynamic, ...any] ? Parameters<First> : never;
636
+
637
+ declare type FirstReturnType<F> = F extends [infer First extends FnDynamic, ...any] ? ReturnType<First> : never;
638
+
639
+ declare type FlatArray_2<T> = T extends readonly (infer U)[] ? U : T;
640
+
641
+ /**
642
+ * Flattens a nested array into a single-level array.
643
+ *
644
+ * @example
645
+ * ```ts
646
+ * const arr = [1, [2, [3, [4, [5]]]]];
647
+ * flatten(arr) // [1, 2, 3, 4, 5];
648
+ * ```
649
+ *
650
+ * @param array - The array to flatten.
651
+ *
652
+ * @returns A single-level array.
653
+ */
654
+ export declare function flatten<T>(array: T[]): FlatArray_2<T>[];
655
+
656
+ export declare type Fn<P = any, R = any> = (...args: P[]) => R;
657
+
658
+ export declare type FnAsync<P = any, R = any> = (...args: P[]) => Promise<R>;
659
+
660
+ export declare type FnDynamic<P = any, R = any> = (...args: P[]) => R | Promise<R>;
661
+
662
+ /**
663
+ * Creates a function that can be used in functional programming mode.
664
+ * This function is a wrapper around the original function, allowing you to pass the first argument as an array.
665
+ *
666
+ * @example
667
+ * ```ts
668
+ * import { fp } from './fp';
669
+ * import { map } from './map';
670
+ *
671
+ * const double = (num: number) => num * 2;
672
+ * const doubleArray = fp(map, double);
673
+ *
674
+ * doubleArray([1, 2, 3]) // [2, 4, 6]
675
+ * ```
676
+ *
677
+ * @param callback - The function to be wrapped.
678
+ * @param args - The arguments to be passed to the function.
679
+ *
680
+ * @returns A function that takes an array and applies the original function to it.
681
+ *
682
+ * @throws {TypeError} If the function cannot be used in functional programming mode.
683
+ */
684
+ export declare const fp: <T, F extends Fn = Fn>(callback: F, ...args: RemoveFirstParameter<F>) => (array: T[]) => any;
685
+
686
+ /**
687
+ * Checks if the first argument is greater than or equal to the second argument.
688
+ *
689
+ * @example
690
+ * ```ts
691
+ * gte(5, 3); // true
692
+ * gte(3, 5); // false
693
+ * gte(5, 5); // true
694
+ * gte(5, '3'); // false
695
+ * gte('5', 3); // false
696
+ * gte('5', '3'); // false
697
+ * ```
698
+ * @param a - The first argument to compare.
699
+ * @param b - The second argument to compare.
700
+ *
701
+ * @returns `true` if `a` is greater than or equal to `b`, otherwise `false`.
702
+ */
703
+ export declare function ge(a: unknown, b: unknown): boolean;
704
+
705
+ /**
706
+ * Groups the elements of an array based on the given key.
707
+ *
708
+ * @example
709
+ * ```ts
710
+ * const data = [{ a: 2 }, { a: 1 }];
711
+ * group(data, 'a') // { '1': [{ a: 2 }], '2': [{ a: 1 }] };
712
+ * ```
713
+ *
714
+ * @param array - The array to group.
715
+ * @param selector - The function to generate the key for each element. It can be a string representing the key or a function that returns the key.
716
+ *
717
+ * @returns an object with keys as the grouped values and values as arrays of elements.
718
+ *
719
+ * @throws {TypeError} If the provided array is not an array.
720
+ */
721
+ export declare function group<T, K extends keyof T, R extends T[K] extends string ? T[K] : never>(array: T[], selector: Selector<T>): Record<R, T[]>;
722
+
723
+ export declare namespace group {
724
+ var fp: boolean;
725
+ }
726
+
727
+ /**
728
+ * Checks if the first argument is greater than the second argument.
729
+ *
730
+ * @example
731
+ * ```ts
732
+ * gt(5, 3); // true
733
+ * gt(3, 5); // false
734
+ * gt(5, 5); // false
735
+ * ```
736
+ *
737
+ * @param a - The first argument to compare.
738
+ * @param b - The second argument to compare.
739
+ *
740
+ * @returns `true` if `a` is greater than `b`, otherwise `false`.
741
+ */
742
+ export declare function gt(a: unknown, b: unknown): boolean;
743
+
744
+ /**
745
+ * Generates an array of dates between a start and end date, with a specified interval and step size.
746
+ *
747
+ * @example
748
+ * ```ts
749
+ * const options = { interval: 'D', steps: 1, latest: false };
750
+ *
751
+ * interval('2022-01-01', '2022-01-31', options); // Returns an array of dates for every day in January 2022
752
+ * ```
753
+ *
754
+ * @param start - The start date (Date object or ISO string).
755
+ * @param end - The end date (Date object or ISO string).
756
+ * @param options - Options for an interval and steps.
757
+ *
758
+ * @returns An array of generated dates.
759
+ */
760
+ export declare function interval(start: Date | string, end: Date | string, { interval, steps, latest }?: IntervalOptions): Date[];
761
+
762
+ declare type IntervalOptions = {
763
+ interval?: IntervalType;
764
+ steps?: number;
765
+ latest?: boolean;
766
+ };
767
+
768
+ declare type IntervalType = 'D' | 'W' | 'M' | 'MS' | 'ME' | 'Y' | 'YS' | 'YE';
769
+
770
+ /**
771
+ * @description
772
+ * Checks if the value type of argument.
773
+ *
774
+ * @example
775
+ * ```ts
776
+ * is('array', []);
777
+ * is('boolean', true);
778
+ * is('date', new Date());
779
+ * is('defined', 123);
780
+ * is('empty', []);
781
+ * is('even', 2);
782
+ * is('function', () => {});
783
+ * is('match', { a: 1, b: 2 }, { a: 1 });
784
+ * is('nan', Number.NaN);
785
+ * is('negative', -123);
786
+ * is('nil', null);
787
+ * is('null', null);
788
+ * is('number', 123);
789
+ * is('object', {});
790
+ * is('odd', 3);
791
+ * is('positive', 123);
792
+ * is('string', 'hello');
793
+ * is('symbol', Symbol('test'));
794
+ * is('regex', /abc/);
795
+ * is('string', 'hello world');
796
+ * is('undefined', undefined);
797
+ * is('within', 1, 2, 3);
798
+ * is('zero', 0);
799
+ * is('eq', [1, 2, 3], [1, 2, 3]);
800
+ * is('ne', [1, 2, 3], [1, 2]);
801
+ * is('ge', 5, 5);
802
+ * is('gt', 5, 3);
803
+ * is('le', 5, 5);
804
+ * is('lt', 3, 5);
805
+ * ```
806
+ *
807
+ * @param type - The type to check against.
808
+ * @param args - The argument to be checked.
809
+ *
810
+ * @returns `true` if the value is of the specified type, else `false`.
811
+ */
812
+ export declare function is(type: 'within', ...args: Parameters<typeof isWithin>): boolean;
813
+
814
+ export declare function is(type: 'eq', ...args: Parameters<typeof isEqual>): boolean;
815
+
816
+ export declare function is(type: 'ne', ...args: Parameters<typeof isEqual>): boolean;
817
+
818
+ export declare function is(type: 'gt', ...args: Parameters<typeof gt>): boolean;
819
+
820
+ export declare function is(type: 'ge', ...args: Parameters<typeof ge>): boolean;
821
+
822
+ export declare function is(type: 'lt', ...args: Parameters<typeof lt>): boolean;
823
+
824
+ export declare function is(type: 'le', ...args: Parameters<typeof le>): boolean;
825
+
826
+ export declare function is(type: 'match', ...args: Parameters<typeof isMatch>): boolean;
827
+
828
+ export declare function is(type: 'empty', ...args: Parameters<typeof isEmpty>): boolean;
829
+
830
+ export declare function is(type: 'array', arg: unknown): arg is Array<unknown>;
831
+
832
+ export declare function is(type: 'string', arg: unknown): arg is string;
833
+
834
+ export declare function is(type: 'number', arg: unknown): arg is number;
835
+
836
+ export declare function is(type: 'object', arg: unknown): arg is object;
837
+
838
+ export declare function is(type: 'nil', arg: unknown): arg is null | undefined;
839
+
840
+ export declare function is(type: 'primitive', arg: unknown): arg is string | number | boolean;
841
+
842
+ export declare function is(type: isType, arg: unknown): boolean;
843
+
844
+ export declare const IS_ARRAY_ERROR_MSG = "Expected an array";
845
+
846
+ export declare const IS_DATE_ERROR_MSG = "Expected a Date object";
847
+
848
+ export declare const IS_EMPTY_ERROR_MSG = "Expected an empty value";
849
+
850
+ export declare const IS_EQUAL_ERROR_MSG = "Expected two values to be equal";
851
+
852
+ export declare const IS_FUNCTION_ERROR_MSG = "Expected a function";
853
+
854
+ export declare const IS_NIL_ERROR_MSG = "Expected a null or undefined value";
855
+
856
+ export declare const IS_NUMBER_ERROR_MSG = "Expected a number";
857
+
858
+ export declare const IS_OBJECT_ERROR_MSG = "Expected an object";
859
+
860
+ export declare const IS_PRIMITIVE_ERROR_MSG = "Expected a primitive value";
861
+
862
+ export declare const IS_PROMISE_ERROR_MSG = "Expected a promise";
863
+
864
+ export declare const IS_STRING_ERROR_MSG = "Expected a string";
865
+
866
+ export declare const IS_WITHIN_ERROR_MSG = "Expected a number within a specified range";
867
+
868
+ /**
869
+ * Determines if the passed value is an array.
870
+ *
871
+ * @example
872
+ * ```ts
873
+ * isArray([1, 2, 3]) // true
874
+ * isArray(1, 2, 3) // false
875
+ * ```
876
+ *
877
+ * @param arg - The argument to be checked.
878
+ *
879
+ * @returns `true` if the value is an array, else `false`.
880
+ */
881
+ export declare function isArray(arg: unknown): arg is Array<unknown>;
882
+
883
+ /**
884
+ * Checks if the value is a boolean.
885
+ *
886
+ * @example
887
+ * ```ts
888
+ * isBoolean(true); // true
889
+ * isBoolean(false); // true
890
+ * isBoolean(123); // false
891
+ * isBoolean('hello world'); // false
892
+ * isBoolean({}); // false
893
+ * isBoolean([]); // false
894
+ * isBoolean(new Date()); // false
895
+ * isBoolean(null); // false
896
+ * isBoolean(undefined); // false
897
+ * isBoolean(NaN); // false
898
+ * ```
899
+ *
900
+ * @param arg - The argument to be checked.
901
+ *
902
+ * @returns `true` if the value is a boolean, else `false`.
903
+ */
904
+ export declare function isBoolean(arg: unknown): arg is boolean;
905
+
906
+ /**
907
+ * Determines if the passed value is a valid Date Object.
908
+ *
909
+ * @example
910
+ * ```ts
911
+ * isDate(new Date()); // true
912
+ * isDate(123); // false
913
+ * ```
914
+ *
915
+ * @param arg - The argument to be checked.
916
+ *
917
+ * @returns `true` if the value is a valid Date object, else `false`.
918
+ */
919
+ export declare function isDate(arg: unknown): arg is Date;
920
+
921
+ /**
922
+ * Checks if a value is defined (not `undefined`).
923
+ *
924
+ * @example
925
+ * ```ts
926
+ * isDefined(123); // true
927
+ * isDefined(undefined); // false
928
+ * isDefined('hello world'); // true
929
+ * isDefined({}); // true
930
+ * isDefined([]); // true
931
+ * isDefined(null); // true
932
+ * ```
933
+ *
934
+ * @param arg - The value to check.
935
+ *
936
+ * @returns `true` if the value is defined, else `false`.
937
+ */
938
+ export declare function isDefined<T>(arg: T | undefined): arg is T;
939
+
940
+ /**
941
+ * Checks if the given argument is empty.
942
+ *
943
+ * @example
944
+ * ```ts
945
+ * isEmpty(null); // true
946
+ * isEmpty(undefined); // true
947
+ * isEmpty([]); // true
948
+ * isEmpty({}); // true
949
+ * isEmpty(''); // true
950
+ * isEmpty(0); // false
951
+ * isEmpty(123); // false
952
+ * isEmpty('abc'); // false
953
+ * isEmpty([1, 2, 3]); // false
954
+ * isEmpty({ a: 1, b: 2 }); // false
955
+ * ```
956
+ *
957
+ * @param arg - The argument to be checked.
958
+ *
959
+ * @returns `true` if all arguments are `null`, `undefined`, `{}`, `[]`, or empty strings. Otherwise, it returns `false`.
960
+ */
961
+ export declare function isEmpty(arg: any): boolean;
962
+
963
+ /**
964
+ * Deeply compares two values for equality, including objects, arrays, and primitives.
965
+ * Detects circular references and optimizes performance.
966
+ *
967
+ * @example
968
+ * ```ts
969
+ * isEqual([1, 2, 3], [1, 2, 3]); // true
970
+ * isEqual([1, 2], [1, 2, 3]); // false
971
+ * isEqual({ a: 1, b: 2 }, { a: 1, b: 2 }); // true
972
+ * isEqual({ a: { b: 2 } }, { a: { b: 2 } }); // true
973
+ * isEqual({ a: 1 }, { a: 2 }); // false
974
+ * isEqual({ a: 1 }, { b: 1 }); // false
975
+ * isEqual(new Date('2023-01-01'), new Date('2023-01-01')); // true
976
+ * isEqual(new Date('2023-01-01'), new Date('2023-01-02')); // false
977
+ * isEqual(new Date('2023-01-01'), 1); // false
978
+ * ```
979
+ *
980
+ * @param a - First value to compare.
981
+ * @param b - Second value to compare.
982
+ * @returns Whether the values are deeply equal.
983
+ */
984
+ export declare function isEqual(a: unknown, b: unknown): boolean;
985
+
986
+ /**
987
+ * Checks if a number is even.
988
+ *
989
+ * @param {number} arg - The number to check.
990
+ *
991
+ * @returns {boolean} - Returns true if the number is even, otherwise false.
992
+ */
993
+ export declare function isEven(arg: unknown): arg is number;
994
+
995
+ /**
996
+ * Determines if the passed value is a function.
997
+ *
998
+ * @example
999
+ * ```ts
1000
+ * isFunction(function() {}) // true
1001
+ * isFunction(() => {}) // true
1002
+ * isFunction('hello world') // false
1003
+ * ```
1004
+ *
1005
+ * @param arg - The argument to be checked.
1006
+ *
1007
+ * @returns `true` if the value is a function, else `false`.
1008
+ */
1009
+ export declare function isFunction(arg: unknown): arg is (...args: any[]) => any;
1010
+
1011
+ /**
1012
+ * Performs a partial deep comparison between object and source to determine if object contains equivalent property values.
1013
+ *
1014
+ * @example
1015
+ * ```ts
1016
+ * const object = { a: 1, b: 2, c: { d: 3 } };
1017
+ *
1018
+ * isMatch(object, { a: 1, c: { d: 3 } }); // true
1019
+ * isMatch(object, { a: 1, b: 2 }); // true
1020
+ * isMatch(object, { a: 1, c: { d: 4 } }); // false
1021
+ *
1022
+ * isMatch([1, 2, 3], [1, 2]); // true
1023
+ * isMatch([1, 2, 3], [1, 2, 3]); // true
1024
+ * isMatch([1, 2, 3], [1, 2, 4]); // false
1025
+ * ```
1026
+ *
1027
+ * @param object - The object to inspect.
1028
+ * @param source - The object of property values to match.
1029
+ *
1030
+ * @returns `true` if the object is a match, else `false`.
1031
+ */
1032
+ declare function isMatch(object: any, source: any): boolean;
1033
+
1034
+ /**
1035
+ * @description
1036
+ * Checks if the value is a negative number.
1037
+ *
1038
+ * @example
1039
+ * ```ts
1040
+ * isNegative(-123); // true
1041
+ * isNegative(123); // false
1042
+ * isNegative(0); // false
1043
+ * isNegative(0.1); // false
1044
+ * isNegative(-0.1); // true
1045
+ * isNegative('hello world'); // false
1046
+ * isNegative({}); // false
1047
+ * isNegative([]); // false
1048
+ * isNegative(new Date()); // false
1049
+ * isNegative(null); // false
1050
+ * isNegative(undefined); // false
1051
+ * isNegative(NaN); // false
1052
+ * ```
1053
+ *
1054
+ * @param arg - The argument to be checked.
1055
+ *
1056
+ * @returns `true` if the value is a negative number, else `false`.
1057
+ */
1058
+ export declare function isNegative(arg: unknown): arg is number;
1059
+
1060
+ /**
1061
+ * Determines if the passed value is null or undefined.
1062
+ *
1063
+ * @example
1064
+ * ```ts
1065
+ * isNil(null); // true
1066
+ * isNil(undefined); // true
1067
+ * isNil(''); // false
1068
+ * isNil(0); // false
1069
+ * ```
1070
+ *
1071
+ * @param arg - The argument to be checked.
1072
+ *
1073
+ * @returns `true` if the value is null or undefined, else `false`.
1074
+ */
1075
+ export declare function isNil(arg: unknown): arg is null | undefined;
1076
+
1077
+ /**
1078
+ * Determines if the passed value is a number.
1079
+ *
1080
+ * @example
1081
+ * ```ts
1082
+ * isNumber(123); // true
1083
+ * isNumber('hello world'); // false
1084
+ * ```
1085
+ *
1086
+ * @param arg - The argument to be checked.
1087
+ *
1088
+ * @returns `true` if the value is a number, else `false`.
1089
+ */
1090
+ export declare function isNumber(arg: unknown): arg is number;
1091
+
1092
+ /**
1093
+ * Determines if the passed value is an object.
1094
+ *
1095
+ * @example
1096
+ * ```ts
1097
+ * const value = { key: 'value' };
1098
+ * isObject(value); // true
1099
+ * isObject('hello world'); // false
1100
+ * isObject(value, 1); // false
1101
+ * isObject(value, value); // true
1102
+ * ```
1103
+ *
1104
+ * @param arg - The argument to be checked.
1105
+ *
1106
+ * @returns `true` if the value is an object, else `false`.
1107
+ */
1108
+ export declare function isObject(arg: unknown): arg is object;
1109
+
1110
+ /**
1111
+ * Checks if a number is odd.
1112
+ *
1113
+ * @param {number} arg - The number to check.
1114
+ *
1115
+ * @returns {boolean} - Returns true if the number is odd, otherwise false.
1116
+ */
1117
+ export declare function isOdd(arg: unknown): arg is number;
1118
+
1119
+ /**
1120
+ * Checks if the value is a positive number.
1121
+ *
1122
+ * @example
1123
+ * ```ts
1124
+ * isPositive(123); // true
1125
+ * isPositive(-123); // false
1126
+ * isPositive(0); // false
1127
+ * isPositive(0.1); // true
1128
+ * isPositive(-0.1); // false
1129
+ * isPositive('hello world'); // false
1130
+ * isPositive({}); // false
1131
+ * isPositive([]); // false
1132
+ * isPositive(new Date()); // false
1133
+ * isPositive(null); // false
1134
+ * isPositive(undefined); // false
1135
+ * isPositive(NaN); // false
1136
+ * ```
1137
+ *
1138
+ * @param arg - The argument to be checked.
1139
+ *
1140
+ * @returns `true` if the value is a positive number, else `false`.
1141
+ *
1142
+ */
1143
+ export declare function isPositive(arg: unknown): arg is number;
1144
+
1145
+ /**
1146
+ * Type guard to check if a value is a primitive
1147
+ *
1148
+ * @example
1149
+ * ```ts
1150
+ * isPrimitive('Hello World'); // true
1151
+ * isPrimitive(42); // true
1152
+ * isPrimitive(true); // true
1153
+ * isPrimitive({}); // false
1154
+ * isPrimitive([]); // false
1155
+ * isPrimitive(() => {}); // false
1156
+ * ```
1157
+ * @param arg - The argument to be checked.
1158
+ *
1159
+ * @returns `true` if the value is a primitive, else `false`.
1160
+ */
1161
+ export declare function isPrimitive(arg: unknown): arg is string | number | boolean;
1162
+
1163
+ /**
1164
+ * Determines if the passed value is a promise.
1165
+ *
1166
+ * @example
1167
+ * ```ts
1168
+ * isPromise(new Promise((resolve, reject) => {})); // true
1169
+ * isPromise(async () => {}); // true
1170
+ * isPromise(() => {}); // false
1171
+ * ```
1172
+ *
1173
+ * @param arg - The argument to be checked.
1174
+ *
1175
+ * @returns `true` if the value is a promise, else `false`.
1176
+ */
1177
+ export declare function isPromise(arg: unknown): arg is Promise<unknown>;
1178
+
1179
+ /**
1180
+ * Checks if the provided argument is a regular expression.
1181
+ *
1182
+ * @example
1183
+ * ```ts
1184
+ * isRegex(/abc/); // true
1185
+ * isRegex(new RegExp('abc')); // true
1186
+ * isRegex('abc'); // false
1187
+ * isRegex(123); // false
1188
+ * isRegex({}); // false
1189
+ * isRegex([]); // false
1190
+ * isRegex(null); // false
1191
+ * isRegex(undefined); // false
1192
+ * ```
1193
+ *
1194
+ * @param arg - The argument to be checked.
1195
+ *
1196
+ * @return `true` if the argument is a regular expression, otherwise `false`.
1197
+ */
1198
+ export declare function isRegex(arg: unknown): arg is RegExp;
1199
+
1200
+ /**
1201
+ * Determines if the passed value is a String.
1202
+ *
1203
+ * @example
1204
+ * ```ts
1205
+ * isString('Hello World'); // true
1206
+ * isString(42); // false
1207
+ * ```
1208
+ *
1209
+ * @param arg - The argument to be checked.
1210
+ *
1211
+ * @returns `true` if the value is a String, else `false`.
1212
+ */
1213
+ export declare function isString(arg: unknown): arg is string;
1214
+
1215
+ declare type isType = ArgType | 'defined' | 'empty' | 'eq' | 'even' | 'ge' | 'gt' | 'le' | 'lt' | 'match' | 'ne' | 'negative' | 'nil' | 'odd' | 'positive' | 'regex' | 'within' | 'zero';
1216
+
1217
+ /**
1218
+ * Checks if a value is within a specified range.
1219
+ *
1220
+ * @example
1221
+ * ```ts
1222
+ * isWithin(1, 0, 1); // true
1223
+ * isWithin(1, 0, 1, false); // false
1224
+ * isWithin(0.5, 0, 1); // true
1225
+ * ```
1226
+ *
1227
+ * @param arg - The value to be checked.
1228
+ * @param min - The minimum value of the range.
1229
+ * @param max - The maximum value of the range.
1230
+ * @param inclusive - Whether the range is inclusive or exclusive. (defaults: `true`).
1231
+ *
1232
+ * @returns `true` if the value is in between, else `false`.
1233
+ */
1234
+ export declare function isWithin(arg: unknown, min: unknown, max: unknown, inclusive?: boolean): boolean;
1235
+
1236
+ /**
1237
+ * Checks if the value is a positive number.
1238
+ *
1239
+ * @example
1240
+ * ```ts
1241
+ * isPositive(0); // true
1242
+ * isPositive(123); // false
1243
+ * isPositive(-123); // false
1244
+ * isPositive(0.0000001); // false
1245
+ * isPositive('hello world'); // false
1246
+ * isPositive({}); // false
1247
+ * isPositive([]); // false
1248
+ * isPositive(new Date()); // false
1249
+ * isPositive(null); // false
1250
+ * isPositive(undefined); // false
1251
+ * isPositive(NaN); // false
1252
+ * ```
1253
+ *
1254
+ * @param arg - The argument to be checked.
1255
+ *
1256
+ * @returns `true` if the value is a positive number, else `false`.
1257
+ *
1258
+ */
1259
+ export declare function isZero(arg: unknown): arg is number;
1260
+
1261
+ declare type JSONValue = string | number | boolean | null | JSONValue[] | {
1262
+ [key: string]: JSONValue;
1263
+ };
1264
+
1265
+ /**
1266
+ * Converts a string to kebab case.
1267
+ *
1268
+ * @example
1269
+ * ```ts
1270
+ * const text = 'Hello World';
1271
+ * kebabCase(text); // 'hello-world'
1272
+ * ```
1273
+ *
1274
+ * @param str - The string to convert.
1275
+ *
1276
+ * @returns The converted string.
1277
+ */
1278
+ export declare function kebabCase(str: string): string;
1279
+
1280
+ /**
1281
+ * Returns an array of the keys for an object's properties.
1282
+ *
1283
+ * @example
1284
+ * ```ts
1285
+ * const obj = { a: 1, b: 2, c: 3 };
1286
+ *
1287
+ * keys(obj); // ['a', 'b', 'c']
1288
+ * ```
1289
+ *
1290
+ * @param item - The object to query.
1291
+ *
1292
+ * @returns true if the object has the property, false otherwise.
1293
+ */
1294
+ export declare function keys<T extends Obj, K extends keyof T>(item: T): K[];
1295
+
1296
+ declare type LastParameters<T> = T extends [...any, infer Last extends FnDynamic] ? Parameters<Last> : never;
1297
+
1298
+ declare type LastReturnType<T> = T extends [...any, infer Last extends FnDynamic] ? ReturnType<Last> : never;
1299
+
1300
+ /**
1301
+ * Check if the first argument is less than or equal to the second argument.
1302
+ *
1303
+ * @example
1304
+ * ```ts
1305
+ * le(3, 5); // true
1306
+ * le(5, 3); // false
1307
+ * le(5, 5); // true
1308
+ * ```
1309
+ *
1310
+ * @param a - The first argument to compare.
1311
+ * @param b - The second argument to compare.
1312
+ *
1313
+ * @returns `true` if `a` is less than or equal to `b`, otherwise `false`.
1314
+ */
1315
+ export declare function le(a: unknown, b: unknown): boolean;
1316
+
1317
+ export declare function list<T>(initialData: T[], config?: Config<T>): {
1318
+ readonly current: T[];
1319
+ data: T[];
1320
+ filter(predicate: (item: T) => boolean): T[];
1321
+ limit: number;
1322
+ readonly meta: {
1323
+ end: number;
1324
+ isEmpty: boolean;
1325
+ isFirst: boolean;
1326
+ isLast: boolean;
1327
+ limit: number;
1328
+ page: number;
1329
+ pages: number;
1330
+ start: number;
1331
+ total: number;
1332
+ };
1333
+ next(): void;
1334
+ page: number;
1335
+ readonly pages: T[][];
1336
+ prev(): void;
1337
+ reset(): T[];
1338
+ search: (str: string) => void;
1339
+ sort(fn?: (a: T, b: T) => number): T[];
1340
+ [Symbol.iterator](): Generator<T[], void, unknown>;
1341
+ };
1342
+
1343
+ /**
1344
+ * Checks if the first argument is less than the second argument.
1345
+ *
1346
+ * @example
1347
+ * ```ts
1348
+ * lt(3, 5); // true
1349
+ * lt(5, 3); // false
1350
+ * lt(5, 5); // false
1351
+ * ```
1352
+ *
1353
+ * @param a - The first argument to compare.
1354
+ * @param b - The second argument to compare.
1355
+ *
1356
+ * @returns `true` if `a` is less than `b`, otherwise `false`.
1357
+ */
1358
+ export declare function lt(a: unknown, b: unknown): boolean;
1359
+
1360
+ /**
1361
+ * Transforms an array by applying a callback function to each of its elements.
1362
+ *
1363
+ * @example
1364
+ * ```ts
1365
+ * const arr = [1, 2, 3];
1366
+ * map(arr, x => x * 2); // [2, 4, 6]
1367
+ * map(arr, async x => x * 2); // Promise<[2, 4, 6]>
1368
+ * ```
1369
+ *
1370
+ * @param array - The array to be transformed.
1371
+ * @param callback - The function to invoke for each element in the array.
1372
+ *
1373
+ * @return The transformed array, either as a synchronous result or a Promise if lazy is set.
1374
+ *
1375
+ * @throws {TypeError} If the provided array is not an array.
1376
+ */
1377
+ export declare function map<T, R, C extends CallbackDynamic<T, R>>(array: T[], callback: C): ResultArray<C>;
1378
+
1379
+ export declare namespace map {
1380
+ var fp: boolean;
1381
+ }
1382
+
1383
+ /**
1384
+ * Finds the maximum item in an array.
1385
+ *
1386
+ * @description
1387
+ * This function can be used to find the maximum number, string, or any other type of item in an array.
1388
+ *
1389
+ * @example
1390
+ * ```ts
1391
+ * max([1, 2, 3]); // 3
1392
+ * max([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 3
1393
+ * max(['apple', 'banana', 'cherry']); // 'cherry'
1394
+ * max([new Date('2023-01-01'), new Date('2022-01-01')]); // 2023-01-01
1395
+ * ```
1396
+ *
1397
+ * @param array - The array to be searched.
1398
+ * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.
1399
+ *
1400
+ * @return The item with the maximum value as determined by the callback function.
1401
+ *
1402
+ * @throws {TypeError} If the provided array is not an array.
1403
+ */
1404
+ export declare function max<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined;
1405
+
1406
+ /**
1407
+ * Returns the median of an array of numbers.
1408
+ *
1409
+ * @example
1410
+ * ```ts
1411
+ * median([1, 2, 3, 4, 100]); // 3
1412
+ * median([1, 2, 3, 4, 5], (n) => n * 2); // 6
1413
+ * median([]); // undefined
1414
+ * median([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); // 5.5
1415
+ * median([new Date(2020-01-01), new Date(2020-01-02), new Date(2020-01-31)]) // 2020-01-02
1416
+ * ```
1417
+ *
1418
+ * @param arr - The array of numbers.
1419
+ * @param callback - (optional) A callback function to map the numbers.
1420
+ * @returns The median of the numbers.
1421
+ */
1422
+ export declare function median<T>(arr: T[], callback?: (item: T) => number | Date): number | Date | undefined;
1423
+
1424
+ /**
1425
+ * Creates a function that memorizes the result of the provided function.
1426
+ * Supports expiration (TTL) and limited cache size (LRU).
1427
+ *
1428
+ * @example
1429
+ * ```ts
1430
+ * const add = (x, y) => x + y;
1431
+ * const memoizedAdd = memo(add, { ttl: 5000, maxSize: 10 });
1432
+ *
1433
+ * memoizedAdd(1, 2); // 3 (caches the result)
1434
+ * memoizedAdd(1, 2); // 3 (from cache)
1435
+ * ```
1436
+ *
1437
+ * @param fn - The function to memorize.
1438
+ * @param options - Memoization options.
1439
+ * @param [options.ttl] - (optional) time-to-live (TTL) for cache expiration (in milliseconds).
1440
+ * @param [options.maxSize] - (optional) maximum cache size (LRU eviction).
1441
+ *
1442
+ * @returns A new function that memorizes the input function.
1443
+ */
1444
+ export declare function memo<T extends Fn>(fn: T, { ttl, maxSize }?: MemoizeOptions): (...args: Parameters<T>) => ReturnType<T>;
1445
+
1446
+ declare type MemoizeOptions = {
1447
+ ttl?: number;
1448
+ maxSize?: number;
1449
+ };
1450
+
1451
+ declare type Merge<T extends Obj[]> = T extends [infer First, ...infer Rest] ? First extends Obj ? Rest extends Obj[] ? DeepMerge<First, Merge<Rest>> : First : Obj : Obj;
1452
+
1453
+ /**
1454
+ * Merges multiple objects based on a specified merge strategy.
1455
+ *
1456
+ * @example
1457
+ * ```ts
1458
+ * const obj1 = { a: 1, b: { x: 10, y: "hello" }, c: [1] };
1459
+ * const obj2 = { b: { y: 20, z: true }, c: [2] };
1460
+ * const obj3 = { d: false, c: [3] };
1461
+ *
1462
+ * merge("deep", obj1, obj2, obj3); // { a: 1, b: { x: 10, y: 20, z: true }, c: [1, 2, 3], d: false }
1463
+ * merge("shallow", obj1, obj2, obj3); // { a: 1, b: { y: 20, z: true }, c: [3], d: false }
1464
+ * ```
1465
+ *
1466
+ * @param [strategy='deep'] - The merging strategy to use.
1467
+ * @param items - The objects to merge.
1468
+ * @returns A new merged object.
1469
+ */
1470
+ export declare function merge<T extends Obj[]>(strategy?: MergeStrategy, ...items: [...T]): Merge<T>;
1471
+
1472
+ declare type MergeStrategy = 'deep' | 'shallow' | 'lastWins' | 'arrayConcat' | 'arrayReplace' | ((target: any, source: any) => any);
1473
+
1474
+ /**
1475
+ * Finds the minimum item in an array.
1476
+ *
1477
+ * @description
1478
+ * This function can be used to find the minimum number, string, or any other type of item in an array.
1479
+ *
1480
+ * @example
1481
+ * ```ts
1482
+ * min([1, 2, 3]); // 1
1483
+ * min([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 1
1484
+ * min(['apple', 'banana', 'cherry']); // 'apple'
1485
+ * min([new Date('2023-01-01'), new Date('2022-01-01')]); // 2022-01-01
1486
+ * ```
1487
+ *
1488
+ * @param array - The array to be searched.
1489
+ * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.
1490
+ *
1491
+ * @return The item with the minimum value as determined by the callback function.
1492
+ *
1493
+ * @throws {TypeError} If the provided array is not an array.
1494
+ */
1495
+ export declare function min<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined;
1496
+
1497
+ export declare type Obj = Record<string, any>;
1498
+
1499
+ /**
1500
+ * Create a function that runs once and returns the first result.
1501
+ *
1502
+ * @example
1503
+ * ```ts
1504
+ * const onceRandom = once(() => Math.random())
1505
+ * onceRandom() // 0.3
1506
+ * onceRandom() // 0.3
1507
+ *
1508
+ * onceRandom.reset()
1509
+ *
1510
+ * onceRandom() // 0.2
1511
+ * onceRandom() // 0.2
1512
+ * ```
1513
+ *
1514
+ * @param fn - The function to wrap.
1515
+ *
1516
+ * @returns A function that can only be called once.
1517
+ */
1518
+ export declare const once: <T extends Fn>(fn: T) => T & {
1519
+ reset: () => void;
1520
+ };
1521
+
1522
+ /**
1523
+ * Parses a JSON string and returns the resulting object.
1524
+ *
1525
+ * @example
1526
+ * ```ts
1527
+ * const json = '{"a":1,"b":2,"c":3}';
1528
+ * const result = parseJSON<Record<string, number>>(json, {
1529
+ * defaultValue: { a: 0, b: 0, c: 0 },
1530
+ * validator: (value) => Object.values(value).every(v => typeof v === 'number'),
1531
+ * errorHandler: (err) => console.warn('Parsing failed:', err.message),
1532
+ * silent: true
1533
+ * });
1534
+ * console.log(result); // { a: 1, b: 2, c: 3 }
1535
+ * ```
1536
+ *
1537
+ * @template T - The expected type of the parsed JSON.
1538
+ * @param json - The JSON string to parse. If not a string, it is returned as is.
1539
+ * @param options - Configuration options for parsing.
1540
+ *
1541
+ * @returns The parsed object if successful, otherwise the default value.
1542
+ */
1543
+ export declare function parseJSON<T extends JSONValue>(json: unknown, options?: ParseJSONOptions<T>): T | undefined;
1544
+
1545
+ declare interface ParseJSONOptions<T> {
1546
+ defaultValue?: T;
1547
+ reviver?: (key: string, value: any) => any;
1548
+ validator?: (value: any) => boolean;
1549
+ silent?: boolean;
1550
+ }
1551
+
1552
+ /**
1553
+ * Converts a string to Pascal case.
1554
+ *
1555
+ * @example
1556
+ * ```ts
1557
+ * const text = 'Hello World';
1558
+ * pascalCase(text) // 'HelloWorld';
1559
+ * ```
1560
+ *
1561
+ * @param str - The string to convert.
1562
+ *
1563
+ * @returns The converted string.
1564
+ */
1565
+ export declare function pascalCase(str: string): string;
1566
+
1567
+ /**
1568
+ * Retrieves the value at a given path of the object. If the value is undefined, the default value is returned.
1569
+ *
1570
+ * @example
1571
+ * ```ts
1572
+ * const obj = { a: { b: { c: 3 } }, d: [1, 2, 3] };
1573
+ *
1574
+ * getValue(obj, 'a.b.c'); // 3
1575
+ * getValue(obj, 'a.b.d', 'default'); // 'default'
1576
+ * getValue(obj, 'd[1]', undefined, { allowArrayIndex: true }); // 2
1577
+ * getValue(obj, 'e.f.g', 'default', { throwOnMissing: true }); // throws Error
1578
+ * ```
1579
+ *
1580
+ * @template T - The type of the object to query.
1581
+ * @template P - The type of the path string.
1582
+ * @param item - The object to query.
1583
+ * @param path - The path of the property to get.
1584
+ * @param [defaultValue] - The value returned for undefined resolved values.
1585
+ * @param [options] - Additional options for value retrieval.
1586
+ *
1587
+ * @returns The resolved value.
1588
+ *
1589
+ * @throws If throwOnMissing is true and the path doesn't exist.
1590
+ */
1591
+ export declare function path<T extends Obj, P extends string>(item: T, path: P, defaultValue?: unknown, options?: PathOptions): PathValue<T, P> | undefined;
1592
+
1593
+ declare type PathOptions = {
1594
+ throwOnMissing?: boolean;
1595
+ allowArrayIndex?: boolean;
1596
+ };
1597
+
1598
+ declare type PathValue<T, P extends string> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? PathValue<T[Key], Rest> : undefined : P extends keyof T ? T[P] : undefined;
1599
+
1600
+ /**
1601
+ * Picks the first element from an array that satisfies a predicate function
1602
+ *
1603
+ * @example
1604
+ * ```ts
1605
+ * const arr = [1, 2, 3, 4];
1606
+ * pick(arr, x => x * x, x => x > 2) // 9
1607
+ * await pick(arr, async x => x * x, x => x > 2) // 9
1608
+ * ```
1609
+ *
1610
+ * @param array - The array to search.
1611
+ * @param callback - A function that is called for each element in the array.
1612
+ * @param predicate - A function that is called to validate each element in the array.
1613
+ *
1614
+ * @return The first element that satisfies the predicate, or undefined if no such element is found.
1615
+ *
1616
+ * @throws {TypeError} If the first argument is not an array.
1617
+ */
1618
+ export declare function pick<T, R, C extends CallbackDynamic<T, R>>(array: T[], callback: C, predicate?: Predicate<T>): Result<C> | undefined;
1619
+
1620
+ export declare namespace pick {
1621
+ var fp: boolean;
1622
+ }
1623
+
1624
+ /**
1625
+ * Pipes multiple functions into a single function. It starts from the leftmost function and proceeds to the right.
1626
+ *
1627
+ * @example
1628
+ * ```ts
1629
+ * const add = (x) => x + 2;
1630
+ * const multiply = (x) => x * 3;
1631
+ * const subtract = (x) => x - 4;
1632
+ * const pipedFn = pipe(subtract, multiply, add);
1633
+ *
1634
+ * pipedFn(5); // ((5-4) * 3) + 2 = 5
1635
+ * ```
1636
+ *
1637
+ * @example
1638
+ * ```ts
1639
+ * const square = async (x) => x * x;
1640
+ * const add = async (x) => x + 2;
1641
+ * const pipedFn = pipe(square, add);
1642
+ *
1643
+ * await pipedFn(4); // (4 * 4) + 2 = 18
1644
+ * ```
1645
+ *
1646
+ * @param fns - List of functions to be piped.
1647
+ *
1648
+ * @returns A new function that is the pipe of the input functions.
1649
+ */
1650
+ export declare function pipe<T extends FnDynamic[]>(...fns: T): PipeReturn<T>;
1651
+
1652
+ declare type PipeReturn<T extends FnDynamic[]> = (...args: FirstParameters<T>) => LastReturnType<T> extends Promise<any> ? Promise<Awaited<LastReturnType<T>>> : LastReturnType<T>;
1653
+
1654
+ export declare type Predicate<T> = (value: T, index: number, array: T[]) => boolean | boolean[];
1655
+
1656
+ /**
1657
+ * Creates a Promise that can be aborted using an AbortController.
1658
+ *
1659
+ * @example
1660
+ * ```ts
1661
+ * const slowFn = () => new Promise(resolve => setTimeout(() => resolve('slow'), 10000));
1662
+ * const fastFn = () => new Promise(resolve => setTimeout(() => resolve('fast'), 5000));
1663
+ *
1664
+ * predict(slowFn); // rejects after 7 seconds
1665
+ * predict(fastFn); // resolves with 'fast' after 5 seconds
1666
+ * ```
1667
+ *
1668
+ * @param fn - The function to execute, which receives an AbortSignal.
1669
+ * @param options - The options for the abortable function.
1670
+ * @param [options.signal] - The AbortSignal to use for aborting the Promise.
1671
+ * @param [options.timeout=7000] - The timeout in milliseconds after which the Promise will be aborted.
1672
+ *
1673
+ * @returns - A Promise that resolves with the result of the callback or rejects if aborted.
1674
+ */
1675
+ export declare function predict<T>(fn: (signal: AbortSignal) => Promise<T>, options?: {
1676
+ signal?: AbortSignal;
1677
+ timeout?: number;
1678
+ }): Promise<T>;
1679
+
1680
+ export declare type Primitive = string | number | boolean;
1681
+
1682
+ /**
1683
+ * Creates a new Proxy for the given object that invokes functions when properties are accessed or modified.
1684
+
1685
+ * @example
1686
+ * ```ts
1687
+ * const obj = { a: 1, b: 2 };
1688
+ * const log = (prop, curr, prev, target) => console.log(`Property '${prop}' changed from ${prev} to ${curr}`);
1689
+ * const proxyObj = proxy(obj, { set: log });
1690
+ * proxyObj.a = 3; // logs 'Property 'a' changed from 1 to 3'
1691
+ * ```
1692
+ *
1693
+ * @param item - The object to observe.
1694
+ * @param options - Configuration options for the proxy.
1695
+ * @param [options.set] - A function to call when a property is set. It receives the property name, current value, previous value, and the target object.
1696
+ * @param [options.get] - A function to call when a property is accessed. It receives the property name, value, and the target object.
1697
+ * @param [options.deep] - If true, the proxy will also apply to nested objects.
1698
+ * @param [options.watch] - An array of property names to watch. If provided, only these properties will trigger the set and get functions.
1699
+ *
1700
+ * @returns A new Proxy for the given object.
1701
+ */
1702
+ export declare function proxy<T extends Obj>(item: T, options: ProxyOptions<T>): T;
1703
+
1704
+ declare type ProxyOptions<T> = {
1705
+ set?: <K extends PropertyKey>(prop: K, curr: unknown, prev: unknown, target: T) => unknown;
1706
+ get?: <K extends PropertyKey>(prop: K, val: unknown, target: T) => unknown;
1707
+ deep?: boolean;
1708
+ watch?: (keyof T)[];
1709
+ };
1710
+
1711
+ /**
1712
+ * Generates a random integer between two values, inclusive.
1713
+ *
1714
+ * @example
1715
+ * ```ts
1716
+ * random(1, 10); // a random integer between 1 and 10
1717
+ * ```
1718
+ *
1719
+ * @param min - The minimum value.
1720
+ * @param max - The maximum value.
1721
+ * @returns A random integer between min and max.
1722
+ */
1723
+ export declare function random(min: number, max: number): number;
1724
+
1725
+ /**
1726
+ * Creates an array of numbers progressing from start up to, but not including, end. A step is used to specify the difference between each number in the array.
1727
+ *
1728
+ * @example
1729
+ * ```ts
1730
+ * const start = 0;
1731
+ * const stop = 10;
1732
+ * const step = 2;
1733
+ *
1734
+ * range(start, stop, step) // [0, 2, 4, 6, 8];
1735
+ * ```
1736
+ *
1737
+ * @param start - The start of the range.
1738
+ * @param stop - The end of the range.
1739
+ * @param step - The value to increment or decrement by.
1740
+ *
1741
+ * @returns The range of numbers.
1742
+ */
1743
+ export declare function range(start: number, stop: number, step: number): number[];
1744
+
1745
+ /**
1746
+ * Creates an array of numbers progressing from min to max with a specified number of steps.
1747
+ *
1748
+ * @example
1749
+ * ```ts
1750
+ * const min = 0;
1751
+ * const max = 10;
1752
+ * const steps = 5;
1753
+ *
1754
+ * rate(min, max, steps) // [0, 2.5, 5, 7.5, 10];
1755
+ * ```
1756
+ *
1757
+ * @param min - The start of the range.
1758
+ * @param max - The end of the range.
1759
+ * @param [steps=5] - The number of steps between min and max.
1760
+ *
1761
+ * @returns The range of numbers.
1762
+ */
1763
+ export declare function rate(min: number, max: number, steps?: number): number[];
1764
+
1765
+ /**
1766
+ * Reduces an array to a single value by applying a callback function
1767
+ * to each element in the array, passing the accumulated result and
1768
+ * the current element as arguments. Supports both synchronous and
1769
+ * asynchronous callback functions.
1770
+ *
1771
+ * @example
1772
+ * ```ts
1773
+ * const arr = [1, 2, 3];
1774
+ * reduce(arr, (acc, curr) => acc + curr, 0); // 10
1775
+ * await reduce(arr, async (acc, curr) => acc + curr, 0); // 10
1776
+ * ```
1777
+ *
1778
+ * @param array - The array to reduce.
1779
+ * @param callback - The callback function to apply to each element.
1780
+ * @param initialValue - The initial value for the accumulator.
1781
+ *
1782
+ * @returns The reduced value, or a Promise that resolves to the reduced value if the callback is asynchronous.
1783
+ *
1784
+ * @throws {TypeError} If the first argument is not an array.
1785
+ */
1786
+ export declare function reduce<T, R, C extends Callback_2<R, T>>(array: T[], callback: C, initialValue: R): Result<C>;
1787
+
1788
+ export declare namespace reduce {
1789
+ var fn: boolean;
1790
+ }
1791
+
1792
+ declare type RemoveFirstParameter<T extends Fn> = T extends (first: any, ...rest: infer R) => any ? R : never;
1793
+
1794
+ export declare type Result<C extends FnDynamic> = C extends FnAsync ? Promise<Awaited<ReturnType<C>>> : ReturnType<C>;
1795
+
1796
+ export declare type ResultArray<C extends FnDynamic> = C extends FnAsync ? Promise<Awaited<ReturnType<C>>[]> : ReturnType<C>[];
1797
+
1798
+ /**
1799
+ * Retries an asynchronous function a specified number of times with delay and optional exponential backoff.
1800
+ *
1801
+ * @example
1802
+ * ```ts
1803
+ * retry(() => fetchData(), { times: 3, delay: 1000, backoff: 2, signal: abortSignal })
1804
+ * .then(result => console.log(result))
1805
+ * .catch(error => console.error(error));
1806
+ * ```
1807
+ *
1808
+ * @param fn - The asynchronous function to retry.
1809
+ * @param options - (optional) Options for retrying the function.
1810
+ * @param [options.times=3] - The number of retry attempts.
1811
+ * @param [options.delay=250] - The delay in milliseconds between retries.
1812
+ * @param [options.backoff=1] - Exponential backoff factor (default: 1 → no backoff).
1813
+ * @param [options.signal] - `AbortSignal` to allow canceling retries.
1814
+ *
1815
+ * @returns The result of the asynchronous function.
1816
+ */
1817
+ export declare function retry<T>(fn: () => Promise<T>, { times, delay, backoff, signal, }?: {
1818
+ times?: number;
1819
+ delay?: number;
1820
+ backoff?: number;
1821
+ signal?: AbortSignal;
1822
+ }): Promise<T>;
1823
+
1824
+ /**
1825
+ * Rounds a number to a specified number of decimal places.
1826
+ *
1827
+ * The `precision` argument is limited to be within the range of -323 to +292 to avoid NaN results.
1828
+ *
1829
+ * @example
1830
+ * ```ts
1831
+ * round(123.456) // 123
1832
+ * round(123.456, -1) // 120
1833
+ * round(123.456, 1, Math.ceil) // 123.5
1834
+ * round(123.456, 1, Math.floor) // 123.4
1835
+ * ```
1836
+ *
1837
+ * @param value - The number to round.
1838
+ * @param precision - The number of decimal places to round to.
1839
+ * @param [parser] - (optional) function to convert the number to a value.
1840
+ *
1841
+ * @returns The rounded number.
1842
+ */
1843
+ export declare function round(value: number, precision?: number, parser?: (value: number) => number): number;
1844
+
1845
+ /**
1846
+ * Performs a search on an array of objects, checking all values for a match with the search string.
1847
+ *
1848
+ * @example
1849
+ * ```ts
1850
+ * const data = [{ name: 'John Doe', age: 25 }, { name: 'Jane Doe', age: 30 }];
1851
+ * search(data, 'doe', 0.5); // [{ name: 'John Doe', age: 25 }, { name: 'Jane Doe', age: 30 }]
1852
+ * ```
1853
+ *
1854
+ * @param array - The array of objects to search.
1855
+ * @param query - The string to search for.
1856
+ * @param [tone=0.25] - Degree of similarity between 0 and 1.
1857
+ *
1858
+ * @returns The filtered array of objects that match the search string.
1859
+ *
1860
+ * @throws {Error} If input values are invalid.
1861
+ */
1862
+ export declare function search<T>(array: T[], query: string, tone?: number): T[];
1863
+
1864
+ /**
1865
+ * Recursively checks if an object contains a value similar to the search string.
1866
+ *
1867
+ * @example
1868
+ * ```ts
1869
+ * const obj = { a: 'hello', b: { c: 'world' }, d: [1, 2, 3] };
1870
+ *
1871
+ * seek(obj, 'hello'); // true
1872
+ * seek(obj, 'world'); // true
1873
+ * seek(obj, 'foo'); // false
1874
+ * seek(obj, 'hello', 0.5); // true
1875
+ * seek(obj, 'hello', 0.8); // true
1876
+ * seek(obj, 'hello', 1); // true
1877
+ * seek(obj, 'hello', 1.5); // false
1878
+ * seek(obj, 'hello', -1); // false
1879
+ * seek(obj, 'hello', 0); // false
1880
+ * ```
1881
+ *
1882
+ * @param item - The object to search within.
1883
+ * @param query - The search string.
1884
+ * @param [tone=1] - The similarity threshold.
1885
+ *
1886
+ * @returns Whether the object contains a matching value.
1887
+ */
1888
+ export declare function seek<T>(item: T, query: string, tone?: number): boolean;
1889
+
1890
+ /**
1891
+ * Selects elements from an array based on a callback function and an optional predicate function.
1892
+ *
1893
+ * @example
1894
+ * ```ts
1895
+ * const arr = [1, 2, 3, 4];
1896
+ * select(arr, x => x * x, x => x > 2) // [9, 16]
1897
+ * await select(arr, async x => x * x, x => x > 2) // [9, 16]
1898
+ * ```
1899
+ *
1900
+ * @param array - The array to select from.
1901
+ * @param callback - The function to map the values.
1902
+ * @param [predicate] - (optional) The function to filter the values.
1903
+ *
1904
+ * @returns A new array with the selected values.
1905
+ *
1906
+ * @throws {TypeError} If the provided array is not an array.
1907
+ */
1908
+ export declare function select<T, R, C extends CallbackDynamic<T, R>>(array: T[], callback: C, predicate?: Predicate<T>): ResultArray<C>;
1909
+
1910
+ export declare namespace select {
1911
+ var fp: boolean;
1912
+ }
1913
+
1914
+ export declare type Selector<T> = keyof T | ((item: T) => Primitive);
1915
+
1916
+ /**
1917
+ * Shifts the elements of an array to the left by a specified number of positions.
1918
+ *
1919
+ * @example
1920
+ * ```ts
1921
+ * const arr = [1, 2, 3, 4, 5];
1922
+ * shift(arr, 2); // [3, 4, 5]
1923
+ * shift(arr, 2, true); // [3, 4, 5, 1, 2]
1924
+ * ```
1925
+ * @param array - The array to shift.
1926
+ * @param positions - The number of positions to shift the array.
1927
+ * @param rotate - If `true`, the elements that are shifted out will be added to the end of the array.
1928
+ *
1929
+ * @returns A new array with the elements shifted.
1930
+ *
1931
+ * @throws {TypeError} If the first argument is not an array, or the second argument is not a number.
1932
+ */
1933
+ export declare function shift<T>(array: T[], positions: number, rotate?: boolean): T[];
1934
+
1935
+ export declare namespace shift {
1936
+ var fp: boolean;
1937
+ }
1938
+
1939
+ /**
1940
+ * Shuffles an array randomly.
1941
+ *
1942
+ * @example
1943
+ * ```ts
1944
+ * const arr = [1, 2, 3, 4];
1945
+ * shuffle(arr); // a shuffled version of the array
1946
+ * ```
1947
+ *
1948
+ * @param array - The array to shuffle.
1949
+ *
1950
+ * @returns A new shuffled array.
1951
+ *
1952
+ * @throws {TypeError} If the provided array is not an array.
1953
+ */
1954
+ export declare function shuffle<T>(array: T[]): T[];
1955
+
1956
+ /**
1957
+ * Calculate the similarity between two strings using the Levenshtein distance algorithm.
1958
+ *
1959
+ * @example
1960
+ * ```ts
1961
+ * similarity('abc', 'abc') // 1
1962
+ * similarity('a', 'b') // 0
1963
+ * similarity('ab', 'ac') // 0.5
1964
+ * similarity('doe', 'John Doe') // 0.25
1965
+ * similarity('abc', 'axc') // 0.6666666666666667
1966
+ * similarity('kitten', 'sitting') // 0.5714285714285714
1967
+ * ```
1968
+ *
1969
+ * @param str1 - The first string.
1970
+ * @param str2 - The second string.
1971
+ *
1972
+ * @returns A number between 0 and 1 representing the similarity between the two strings.
1973
+ */
1974
+ export declare function similarity(str1: unknown, str2: unknown): number;
1975
+
1976
+ /**
1977
+ * Creates a Promise that resolves after a specified amount of time.
1978
+ *
1979
+ * @example
1980
+ * ```ts
1981
+ * sleep(1000).then(() => console.log('Hello, world!')); // logs 'Hello, world!' after 1 second
1982
+ * ```
1983
+ *
1984
+ * @param timeout - The number of milliseconds to wait before resolving the Promise.
1985
+ *
1986
+ * @returns A Promise that resolves after the specified time.
1987
+ */
1988
+ export declare function sleep(timeout: number): Promise<void>;
1989
+
1990
+ /**
1991
+ * Converts a string to snake case.
1992
+ *
1993
+ * @example
1994
+ * ```ts
1995
+ * const text = 'Hello World';
1996
+ * toSnakeCase(text) // 'hello_world';
1997
+ * ```
1998
+ *
1999
+ * @param str - The string to convert.
2000
+ *
2001
+ * @returns The converted string.
2002
+ */
2003
+ export declare function snakeCase(str: string): string;
2004
+
2005
+ /**
2006
+ * Checks if at least one element in the array satisfies the provided predicate function.
2007
+ *
2008
+ * @example
2009
+ * ```ts
2010
+ * some([1, 2, 3], (n) => n === 2) // true
2011
+ * some([1, 2, 3], (n) => n === 4) // false
2012
+ * ```
2013
+ *
2014
+ * @param array - The array to be checked.
2015
+ * @param predicate - The function to test each element of the array.
2016
+ *
2017
+ * @returns `true` if at least one element satisfies the predicate, otherwise `false`.
2018
+ *
2019
+ * @throws {TypeError} If the provided array is not an array.
2020
+ */
2021
+ export declare function some<T>(array: T[], predicate: Predicate<T>): boolean;
2022
+
2023
+ export declare namespace some {
2024
+ var fp: boolean;
2025
+ }
2026
+
2027
+ /**
2028
+ * Sorts an array of objects by a specific key in ascending order.
2029
+ *
2030
+ * @example
2031
+ * ```ts
2032
+ * const data = [{ a: 2 }, { a: 3 }, { a: 1 }];
2033
+ * sort(data, (item) => item.a); // [{ a: 1 }, { a: 2 }, { a: 3 }]
2034
+ * ```
2035
+ *
2036
+ * @param array - The array of objects to sort.
2037
+ * @param selector - A function that extracts the key to sort by.
2038
+ * @param desc - A boolean indicating whether to sort in descending order (default: false).
2039
+ *
2040
+ * @returns A new array sorted by the specified key.
2041
+ *
2042
+ * @throws {TypeError} If the provided array is not an array.
2043
+ */
2044
+ export declare const sort: {
2045
+ <T>(array: T[], selector: (item: T) => any, desc?: boolean): T[];
2046
+ fp: boolean;
2047
+ };
2048
+
2049
+ /**
2050
+ * Sorts an array of objects based on multiple selectors.
2051
+ *
2052
+ * @example
2053
+ * ```ts
2054
+ * const data = [
2055
+ * { name: 'Alice', age: 30 },
2056
+ * { name: 'Bob', age: 25 },
2057
+ * { name: 'Charlie', age: 35 },
2058
+ * { name: 'Alice', age: 25 },
2059
+ * { name: 'Bob', age: 30 },
2060
+ * { name: 'Charlie', age: 30 },
2061
+ * ].sortBy(data, { name: 'asc', age: 'desc' }); // [ { name: 'Alice', age: 30 }, { name: 'Alice', age: 25 }, { name: 'Bob', age: 30 }, { name: 'Bob', age: 25 }, { name: 'Charlie', age: 35 }, { name: 'Charlie', age: 30 } ]
2062
+ * ```
2063
+ *
2064
+ * @param array - The array to sort.
2065
+ * @param selectors - An object where keys are the properties to sort by and values are 'asc' or 'desc'.
2066
+ * @returns A new sorted array.
2067
+ */
2068
+ export declare const sortBy: <T>(array: T[], selectors: Partial<Record<keyof T, "asc" | "desc">>) => T[];
2069
+
2070
+ /**
2071
+ * Replaces the first element in an array that satisfies the provided predicate function with a new value.
2072
+ *
2073
+ * @example
2074
+ * ```ts
2075
+ * substitute([1, 2, 3], (n) => n === 2, 4) // [1, 4, 3]
2076
+ * ```
2077
+ *
2078
+ * @param array - The array to search.
2079
+ * @param predicate - A function to test each element of the array.
2080
+ * @param value - The new value to replace the found element.
2081
+ *
2082
+ * @return A new array with the replaced value.
2083
+ *
2084
+ * @throws {TypeError} If the first argument is not an array.
2085
+ */
2086
+ export declare function substitute<T>(array: T[], predicate: Predicate<T>, value: T): T[];
2087
+
2088
+ export declare namespace substitute {
2089
+ var fn: boolean;
2090
+ }
2091
+
2092
+ /**
2093
+ * Sum numbers in an array or numbers mapped by a callback function.
2094
+ *
2095
+ * @example
2096
+ * ```ts
2097
+ * sum([1, 2, 3]) // 6
2098
+ * sum([{value: 1}, {value: 2}, {value: 3}], (item) => item.value) // 6
2099
+ * sum(['apple', 'banana', 'cherry']) // TypeError
2100
+ * sum([new Date('2023-01-01'), new Date('2022-01-01')]) // 467308800000
2101
+ * ```
2102
+ *
2103
+ * @param array - The array to sum.
2104
+ * @param callback - An optional callback function to map the values.
2105
+ *
2106
+ * @returns The sum of the numbers in the array or the sum of the mapped values.
2107
+ */
2108
+ export declare function sum<T>(array: T[], callback?: (item: T) => number | Date): number | Date | undefined;
2109
+
2110
+ declare type SyncCallback<R, T> = (prev: R, curr: T, index: number, array: T[]) => R;
2111
+
2112
+ /**
2113
+ * Creates a throttled function that only invokes the provided function at most once per every specified milliseconds.
2114
+ *
2115
+ * @example
2116
+ * ```ts
2117
+ * const log = () => console.log('Hello, world!');
2118
+ * const throttledLog = throttle(log, 1000);
2119
+ *
2120
+ * throttledLog(); // logs 'Hello, world!' immediately
2121
+ * throttledLog(); // does nothing because less than 1 second has passed since the last invocation
2122
+ * setTimeout(throttledLog, 1000); // logs 'Hello, world!' after 1 second
2123
+ * ```
2124
+ *
2125
+ * @param fn - The function to throttle.
2126
+ * @param [delay=700] - The number of milliseconds to wait before invoking the function again.
2127
+ *
2128
+ * @returns A new function that throttles the input function.
2129
+ */
2130
+ export declare function throttle<T extends Fn>(fn: T, delay?: number): (...args: Parameters<T>) => void;
2131
+
2132
+ /**
2133
+ * Calculates the remaining time until a target date.
2134
+ *
2135
+ * @example
2136
+ * ```ts
2137
+ * timeDiff(new Date(Date.now() + 1000 * 60 * 60 * 24 * 5)); // { value: 5, unit: 'DAY' }
2138
+ * timeDiff(new Date(Date.now() - 1000 * 60 * 60 * 24 * 3), 'past'); // { value: 3, unit: 'DAY' }
2139
+ * timeDiff(new Date(Date.now() + 1000 * 60 * 60 * 24 * 31)); // { value: 1, unit: 'MONTH' }
2140
+ * timeDiff(new Date(Date.now() + 1000 * 60 * 60 * 24 * 365)); // { value: 1, unit: 'YEAR' }
2141
+ * ```
2142
+ *
2143
+ * @param a - The target date (Date object or ISO string).
2144
+ * @param b - The target date (Date object or ISO string).
2145
+ * @param allowedUnits - (optional) array of units to filter the result. If provided, only these units will be considered.
2146
+ *
2147
+ * @returns An object containing the remaining time and its unit ('DAY', 'HOUR', or 'MINUTE').
2148
+ */
2149
+ export declare function timeDiff(a: Date | string, b?: Date | string, allowedUnits?: TimeUnit[]): TimeResult;
2150
+
2151
+ export declare namespace timeDiff {
2152
+ var defaultUnits: (units: TimeUnit[]) => void;
2153
+ }
2154
+
2155
+ export declare type TimeDirection = 'FUTURE' | 'PAST';
2156
+
2157
+ export declare type TimeResult = {
2158
+ unit: TimeUnit;
2159
+ value: number;
2160
+ };
2161
+
2162
+ export declare type TimeUnit = 'YEAR' | 'MONTH' | 'WEEK' | 'DAY' | 'HOUR' | 'MINUTE' | 'SECOND' | 'INVALID_DATE';
2163
+
2164
+ /**
2165
+ * Truncates a string if it is longer than the given maximum string length. The last characters of the truncated string are replaced with the ellipsis sign "…".
2166
+ *
2167
+ * @example
2168
+ * ```ts
2169
+ * const text = 'Hello World';
2170
+ * truncate(text, 5); // 'Hello…'
2171
+ * truncate(text, 3, true); // 'Hello…'
2172
+ * truncate(text, 5, true, '...'); // 'Hello...'
2173
+ * ```
2174
+ *
2175
+ * @param str - The string to truncate.
2176
+ * @param limit - The maximum string length.
2177
+ * @param completeWords - If true, the string is truncated to the nearest word, instead of character.
2178
+ * @param ellipsis - The characters to end the truncated string with.
2179
+ *
2180
+ * @returns The truncated string.
2181
+ */
2182
+ export declare function truncate(str: string, limit?: number, completeWords?: boolean, ellipsis?: string): string;
2183
+
2184
+ /**
2185
+ * Returns the type of the given argument.
2186
+ *
2187
+ * @example
2188
+ * ```ts
2189
+ * typeOf(null); // 'null'
2190
+ * typeOf(undefined); // 'undefined'
2191
+ * typeOf(NaN); // 'nan'
2192
+ * typeOf(async function() {}); // 'promise'
2193
+ * typeOf(123); // 'number'
2194
+ * typeOf('abc'); // 'string'
2195
+ * typeOf({}); // 'object'
2196
+ * typeOf([]); // 'array'
2197
+ * typeOf(() => {}); // 'function'
2198
+ * typeOf(new Date()); // 'date'
2199
+ * typeOf(new Error()); // 'error'
2200
+ * typeOf(new Map()); // 'map'
2201
+ * typeOf(new Set()); // 'set'
2202
+ * typeOf(new WeakMap()); // 'weakmap'
2203
+ * typeOf(new WeakSet()); // 'weakset'
2204
+ * typeOf(new RegExp('')); // 'regexp'
2205
+ * ```
2206
+ *
2207
+ * @param arg - The argument whose type is to be determined.
2208
+ *
2209
+ * @returns The type of the argument.
2210
+ */
2211
+ export declare function typeOf(arg: unknown): ArgType;
2212
+
2213
+ /**
2214
+ * Creates a new array with duplicate values removed.
2215
+ *
2216
+ * @example
2217
+ * ```ts
2218
+ * uniq([1, 2, 2, 3, 3, 3]); // [1, 2, 3]
2219
+ * const arrObj = [{ id: 1 }, { id: 2 }, { id: 2 }, { id: 3 }, { id: 3 }, { id: 3 }];
2220
+ * uniq(arrObj, 'id'); // [{ id: 1 }, { id: 2 }, { id: 3 }]
2221
+ * uniq(arrObj, item => item.id); // [{ id: 1 }, { id: 2 }, { id: 3 }]
2222
+ * ```
2223
+ *
2224
+ * @param array - The array to process.
2225
+ * @param [selector] - The key(s) to compare objects or a function to generate comparison values.
2226
+
2227
+ * @returns A new duplicate-free array.
2228
+
2229
+ * @throws {TypeError} - If the input is not an array or if the key is invalid.
2230
+ */
2231
+ export declare function uniq<T>(array: T[], selector?: Selector<T>): T[];
2232
+
2233
+ export declare namespace uniq {
2234
+ var fp: boolean;
2235
+ }
2236
+
2237
+ /**
2238
+ * Generates a unique identifier.
2239
+ *
2240
+ * @example
2241
+ * ```ts
2242
+ * uuid(); // a unique identifier, e.g., '22a746d0-08be-4aff-bbc2-4deddf0914e0'
2243
+ * ```
2244
+ *
2245
+ * @returns A unique identifier.
2246
+ */
2247
+ export declare function uuid(): string;
2248
+
2249
+ /**
2250
+ * Returns an array of values for an object's properties
2251
+ *
2252
+ * @example
2253
+ * ```ts
2254
+ * const obj = { a: 1, b: 2, c: 3 };
2255
+ * toValues(obj); // [1, 2, 3]
2256
+ * ```
2257
+ *
2258
+ * @param item - The object whose property values are to be returned.
2259
+ *
2260
+ * @returns an array of the object's own enumerable string-keyed property values.
2261
+ */
2262
+ export declare function values<T extends Obj, K extends keyof T>(item: T): T[K][];
2263
+
2264
+ /**
2265
+ * Creates a function that runs the provided callback in a web worker with specified dependencies.
2266
+ *
2267
+ * @example
2268
+ * const sum = worker(({ _ }) => (...args) => _.sum([...args]), ['https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js']);
2269
+ * await sum(1, 2); // 3
2270
+ *
2271
+ * @param callback - A function that receives the worker's `self` and performs work.
2272
+ * @param dependencies - (optional) array of URLs to scripts that the worker should import.
2273
+ *
2274
+ * @returns A function that takes the arguments for the callback and returns a promise with the result.
2275
+ */
2276
+ export declare function worker<T extends (...args: any) => any, R = Awaited<ReturnType<T>>>(callback: (self: any) => T, dependencies?: string[]): (...args: Parameters<T>) => Promise<R>;
2277
+
2278
+ export { }