@fluixi/utils 1.0.0-alpha.53

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 (354) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +73 -0
  3. package/dist/index.cjs +1 -0
  4. package/dist/index.d.ts +2 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +1 -0
  7. package/dist/index.mjs +1 -0
  8. package/dist/lib/array/advanced.cjs +1 -0
  9. package/dist/lib/array/advanced.d.ts +1116 -0
  10. package/dist/lib/array/advanced.d.ts.map +1 -0
  11. package/dist/lib/array/advanced.js +2429 -0
  12. package/dist/lib/array/advanced.mjs +1 -0
  13. package/dist/lib/array/array.cjs +1 -0
  14. package/dist/lib/array/array.d.ts +6 -0
  15. package/dist/lib/array/array.d.ts.map +1 -0
  16. package/dist/lib/array/array.js +31 -0
  17. package/dist/lib/array/array.mjs +1 -0
  18. package/dist/lib/array/index.cjs +1 -0
  19. package/dist/lib/array/index.d.ts +4 -0
  20. package/dist/lib/array/index.d.ts.map +1 -0
  21. package/dist/lib/array/index.js +3 -0
  22. package/dist/lib/array/index.mjs +1 -0
  23. package/dist/lib/array/utils.cjs +1 -0
  24. package/dist/lib/array/utils.d.ts +100 -0
  25. package/dist/lib/array/utils.d.ts.map +1 -0
  26. package/dist/lib/array/utils.js +165 -0
  27. package/dist/lib/array/utils.mjs +1 -0
  28. package/dist/lib/color/color.cjs +1 -0
  29. package/dist/lib/color/color.d.ts +366 -0
  30. package/dist/lib/color/color.d.ts.map +1 -0
  31. package/dist/lib/color/color.js +722 -0
  32. package/dist/lib/color/color.mjs +1 -0
  33. package/dist/lib/color/constants.cjs +1 -0
  34. package/dist/lib/color/constants.d.ts +361 -0
  35. package/dist/lib/color/constants.d.ts.map +1 -0
  36. package/dist/lib/color/constants.js +358 -0
  37. package/dist/lib/color/constants.mjs +1 -0
  38. package/dist/lib/color/conversions.cjs +1 -0
  39. package/dist/lib/color/conversions.d.ts +166 -0
  40. package/dist/lib/color/conversions.d.ts.map +1 -0
  41. package/dist/lib/color/conversions.js +766 -0
  42. package/dist/lib/color/conversions.mjs +1 -0
  43. package/dist/lib/color/helpers.cjs +1 -0
  44. package/dist/lib/color/helpers.d.ts +75 -0
  45. package/dist/lib/color/helpers.d.ts.map +1 -0
  46. package/dist/lib/color/helpers.js +419 -0
  47. package/dist/lib/color/helpers.mjs +1 -0
  48. package/dist/lib/color/index.cjs +1 -0
  49. package/dist/lib/color/index.d.ts +12 -0
  50. package/dist/lib/color/index.d.ts.map +1 -0
  51. package/dist/lib/color/index.js +15 -0
  52. package/dist/lib/color/index.mjs +1 -0
  53. package/dist/lib/color/types.cjs +1 -0
  54. package/dist/lib/color/types.d.ts +179 -0
  55. package/dist/lib/color/types.d.ts.map +1 -0
  56. package/dist/lib/color/types.js +1 -0
  57. package/dist/lib/color/types.mjs +0 -0
  58. package/dist/lib/color/utils.cjs +1 -0
  59. package/dist/lib/color/utils.d.ts +199 -0
  60. package/dist/lib/color/utils.d.ts.map +1 -0
  61. package/dist/lib/color/utils.js +858 -0
  62. package/dist/lib/color/utils.mjs +1 -0
  63. package/dist/lib/compare/comparators.cjs +1 -0
  64. package/dist/lib/compare/comparators.d.ts +65 -0
  65. package/dist/lib/compare/comparators.d.ts.map +1 -0
  66. package/dist/lib/compare/comparators.js +210 -0
  67. package/dist/lib/compare/comparators.mjs +1 -0
  68. package/dist/lib/compare/index.cjs +1 -0
  69. package/dist/lib/compare/index.d.ts +2 -0
  70. package/dist/lib/compare/index.d.ts.map +1 -0
  71. package/dist/lib/compare/index.js +1 -0
  72. package/dist/lib/compare/index.mjs +1 -0
  73. package/dist/lib/crypto/hash.cjs +1 -0
  74. package/dist/lib/crypto/hash.d.ts +6 -0
  75. package/dist/lib/crypto/hash.d.ts.map +1 -0
  76. package/dist/lib/crypto/hash.js +53 -0
  77. package/dist/lib/crypto/hash.mjs +1 -0
  78. package/dist/lib/crypto/index.cjs +1 -0
  79. package/dist/lib/crypto/index.d.ts +2 -0
  80. package/dist/lib/crypto/index.d.ts.map +1 -0
  81. package/dist/lib/crypto/index.js +1 -0
  82. package/dist/lib/crypto/index.mjs +1 -0
  83. package/dist/lib/dom/events.cjs +1 -0
  84. package/dist/lib/dom/events.d.ts +159 -0
  85. package/dist/lib/dom/events.d.ts.map +1 -0
  86. package/dist/lib/dom/events.js +50 -0
  87. package/dist/lib/dom/events.mjs +1 -0
  88. package/dist/lib/dom/index.cjs +1 -0
  89. package/dist/lib/dom/index.d.ts +3 -0
  90. package/dist/lib/dom/index.d.ts.map +1 -0
  91. package/dist/lib/dom/index.js +2 -0
  92. package/dist/lib/dom/index.mjs +1 -0
  93. package/dist/lib/dom/utils.cjs +1 -0
  94. package/dist/lib/dom/utils.d.ts +6 -0
  95. package/dist/lib/dom/utils.d.ts.map +1 -0
  96. package/dist/lib/dom/utils.js +37 -0
  97. package/dist/lib/dom/utils.mjs +1 -0
  98. package/dist/lib/functions/functions.cjs +1 -0
  99. package/dist/lib/functions/functions.d.ts +329 -0
  100. package/dist/lib/functions/functions.d.ts.map +1 -0
  101. package/dist/lib/functions/functions.js +585 -0
  102. package/dist/lib/functions/functions.mjs +1 -0
  103. package/dist/lib/functions/index.cjs +1 -0
  104. package/dist/lib/functions/index.d.ts +3 -0
  105. package/dist/lib/functions/index.d.ts.map +1 -0
  106. package/dist/lib/functions/index.js +1 -0
  107. package/dist/lib/functions/index.mjs +1 -0
  108. package/dist/lib/functions/types.cjs +1 -0
  109. package/dist/lib/functions/types.d.ts +2 -0
  110. package/dist/lib/functions/types.d.ts.map +1 -0
  111. package/dist/lib/functions/types.js +1 -0
  112. package/dist/lib/functions/types.mjs +0 -0
  113. package/dist/lib/helpers.cjs +1 -0
  114. package/dist/lib/helpers.d.ts +13 -0
  115. package/dist/lib/helpers.d.ts.map +1 -0
  116. package/dist/lib/helpers.js +66 -0
  117. package/dist/lib/helpers.mjs +1 -0
  118. package/dist/lib/index.cjs +1 -0
  119. package/dist/lib/index.d.ts +6 -0
  120. package/dist/lib/index.d.ts.map +1 -0
  121. package/dist/lib/index.js +8 -0
  122. package/dist/lib/index.mjs +1 -0
  123. package/dist/lib/maths/constants.cjs +1 -0
  124. package/dist/lib/maths/constants.d.ts +84 -0
  125. package/dist/lib/maths/constants.d.ts.map +1 -0
  126. package/dist/lib/maths/constants.js +79 -0
  127. package/dist/lib/maths/constants.mjs +1 -0
  128. package/dist/lib/maths/fn/advanced.cjs +1 -0
  129. package/dist/lib/maths/fn/advanced.d.ts +149 -0
  130. package/dist/lib/maths/fn/advanced.d.ts.map +1 -0
  131. package/dist/lib/maths/fn/advanced.js +264 -0
  132. package/dist/lib/maths/fn/advanced.mjs +1 -0
  133. package/dist/lib/maths/fn/basic.cjs +1 -0
  134. package/dist/lib/maths/fn/basic.d.ts +182 -0
  135. package/dist/lib/maths/fn/basic.d.ts.map +1 -0
  136. package/dist/lib/maths/fn/basic.js +343 -0
  137. package/dist/lib/maths/fn/basic.mjs +1 -0
  138. package/dist/lib/maths/fn/complex.cjs +1 -0
  139. package/dist/lib/maths/fn/complex.d.ts +153 -0
  140. package/dist/lib/maths/fn/complex.d.ts.map +1 -0
  141. package/dist/lib/maths/fn/complex.js +383 -0
  142. package/dist/lib/maths/fn/complex.mjs +1 -0
  143. package/dist/lib/maths/fn/index.cjs +1 -0
  144. package/dist/lib/maths/fn/index.d.ts +10 -0
  145. package/dist/lib/maths/fn/index.d.ts.map +1 -0
  146. package/dist/lib/maths/fn/index.js +9 -0
  147. package/dist/lib/maths/fn/index.mjs +1 -0
  148. package/dist/lib/maths/fn/trigo.cjs +1 -0
  149. package/dist/lib/maths/fn/trigo.d.ts +147 -0
  150. package/dist/lib/maths/fn/trigo.d.ts.map +1 -0
  151. package/dist/lib/maths/fn/trigo.js +227 -0
  152. package/dist/lib/maths/fn/trigo.mjs +1 -0
  153. package/dist/lib/maths/fn/vector.cjs +1 -0
  154. package/dist/lib/maths/fn/vector.d.ts +512 -0
  155. package/dist/lib/maths/fn/vector.d.ts.map +1 -0
  156. package/dist/lib/maths/fn/vector.js +1136 -0
  157. package/dist/lib/maths/fn/vector.mjs +1 -0
  158. package/dist/lib/maths/formatter.cjs +1 -0
  159. package/dist/lib/maths/formatter.d.ts +35 -0
  160. package/dist/lib/maths/formatter.d.ts.map +1 -0
  161. package/dist/lib/maths/formatter.js +56 -0
  162. package/dist/lib/maths/formatter.mjs +1 -0
  163. package/dist/lib/maths/guards.cjs +1 -0
  164. package/dist/lib/maths/guards.d.ts +166 -0
  165. package/dist/lib/maths/guards.d.ts.map +1 -0
  166. package/dist/lib/maths/guards.js +315 -0
  167. package/dist/lib/maths/guards.mjs +1 -0
  168. package/dist/lib/maths/index.cjs +1 -0
  169. package/dist/lib/maths/index.d.ts +24 -0
  170. package/dist/lib/maths/index.d.ts.map +1 -0
  171. package/dist/lib/maths/index.js +29 -0
  172. package/dist/lib/maths/index.mjs +1 -0
  173. package/dist/lib/maths/parser.cjs +1 -0
  174. package/dist/lib/maths/parser.d.ts +20 -0
  175. package/dist/lib/maths/parser.d.ts.map +1 -0
  176. package/dist/lib/maths/parser.js +78 -0
  177. package/dist/lib/maths/parser.mjs +1 -0
  178. package/dist/lib/maths/random.cjs +1 -0
  179. package/dist/lib/maths/random.d.ts +27 -0
  180. package/dist/lib/maths/random.d.ts.map +1 -0
  181. package/dist/lib/maths/random.js +49 -0
  182. package/dist/lib/maths/random.mjs +1 -0
  183. package/dist/lib/maths/types/advanced.cjs +1 -0
  184. package/dist/lib/maths/types/advanced.d.ts +357 -0
  185. package/dist/lib/maths/types/advanced.d.ts.map +1 -0
  186. package/dist/lib/maths/types/advanced.js +5 -0
  187. package/dist/lib/maths/types/advanced.mjs +0 -0
  188. package/dist/lib/maths/types/basic.cjs +1 -0
  189. package/dist/lib/maths/types/basic.d.ts +95 -0
  190. package/dist/lib/maths/types/basic.d.ts.map +1 -0
  191. package/dist/lib/maths/types/basic.js +5 -0
  192. package/dist/lib/maths/types/basic.mjs +0 -0
  193. package/dist/lib/maths/types/index.cjs +1 -0
  194. package/dist/lib/maths/types/index.d.ts +4 -0
  195. package/dist/lib/maths/types/index.d.ts.map +1 -0
  196. package/dist/lib/maths/types/index.js +3 -0
  197. package/dist/lib/maths/types/index.mjs +0 -0
  198. package/dist/lib/maths/types/negative.cjs +1 -0
  199. package/dist/lib/maths/types/negative.d.ts +51 -0
  200. package/dist/lib/maths/types/negative.d.ts.map +1 -0
  201. package/dist/lib/maths/types/negative.js +5 -0
  202. package/dist/lib/maths/types/negative.mjs +0 -0
  203. package/dist/lib/maths/types/operations.cjs +1 -0
  204. package/dist/lib/maths/types/operations.d.ts +188 -0
  205. package/dist/lib/maths/types/operations.d.ts.map +1 -0
  206. package/dist/lib/maths/types/operations.js +6 -0
  207. package/dist/lib/maths/types/operations.mjs +0 -0
  208. package/dist/lib/object/clone.cjs +1 -0
  209. package/dist/lib/object/clone.d.ts +46 -0
  210. package/dist/lib/object/clone.d.ts.map +1 -0
  211. package/dist/lib/object/clone.js +104 -0
  212. package/dist/lib/object/clone.mjs +1 -0
  213. package/dist/lib/object/diff.cjs +1 -0
  214. package/dist/lib/object/diff.d.ts +203 -0
  215. package/dist/lib/object/diff.d.ts.map +1 -0
  216. package/dist/lib/object/diff.js +805 -0
  217. package/dist/lib/object/diff.mjs +1 -0
  218. package/dist/lib/object/getter-setter.cjs +1 -0
  219. package/dist/lib/object/getter-setter.d.ts +361 -0
  220. package/dist/lib/object/getter-setter.d.ts.map +1 -0
  221. package/dist/lib/object/getter-setter.js +1771 -0
  222. package/dist/lib/object/getter-setter.mjs +1 -0
  223. package/dist/lib/object/index.cjs +6 -0
  224. package/dist/lib/object/index.d.ts +13 -0
  225. package/dist/lib/object/index.d.ts.map +1 -0
  226. package/dist/lib/object/index.js +12 -0
  227. package/dist/lib/object/index.mjs +6 -0
  228. package/dist/lib/object/merge.cjs +1 -0
  229. package/dist/lib/object/merge.d.ts +93 -0
  230. package/dist/lib/object/merge.d.ts.map +1 -0
  231. package/dist/lib/object/merge.js +474 -0
  232. package/dist/lib/object/merge.mjs +1 -0
  233. package/dist/lib/object/object.cjs +1 -0
  234. package/dist/lib/object/object.d.ts +128 -0
  235. package/dist/lib/object/object.d.ts.map +1 -0
  236. package/dist/lib/object/object.js +432 -0
  237. package/dist/lib/object/object.mjs +1 -0
  238. package/dist/lib/object/omit.cjs +1 -0
  239. package/dist/lib/object/omit.d.ts +351 -0
  240. package/dist/lib/object/omit.d.ts.map +1 -0
  241. package/dist/lib/object/omit.js +656 -0
  242. package/dist/lib/object/omit.mjs +1 -0
  243. package/dist/lib/object/reconcile.cjs +1 -0
  244. package/dist/lib/object/reconcile.d.ts +7 -0
  245. package/dist/lib/object/reconcile.d.ts.map +1 -0
  246. package/dist/lib/object/reconcile.js +122 -0
  247. package/dist/lib/object/reconcile.mjs +1 -0
  248. package/dist/lib/object/selector.cjs +1 -0
  249. package/dist/lib/object/selector.d.ts +50 -0
  250. package/dist/lib/object/selector.d.ts.map +1 -0
  251. package/dist/lib/object/selector.js +371 -0
  252. package/dist/lib/object/selector.mjs +1 -0
  253. package/dist/lib/object/sort.cjs +1 -0
  254. package/dist/lib/object/sort.d.ts +149 -0
  255. package/dist/lib/object/sort.d.ts.map +1 -0
  256. package/dist/lib/object/sort.js +298 -0
  257. package/dist/lib/object/sort.mjs +1 -0
  258. package/dist/lib/object/transform.cjs +1 -0
  259. package/dist/lib/object/transform.d.ts +620 -0
  260. package/dist/lib/object/transform.d.ts.map +1 -0
  261. package/dist/lib/object/transform.js +1058 -0
  262. package/dist/lib/object/transform.mjs +1 -0
  263. package/dist/lib/object/types.cjs +1 -0
  264. package/dist/lib/object/types.d.ts +250 -0
  265. package/dist/lib/object/types.d.ts.map +1 -0
  266. package/dist/lib/object/types.js +1 -0
  267. package/dist/lib/object/types.mjs +0 -0
  268. package/dist/lib/object/utils.cjs +6 -0
  269. package/dist/lib/object/utils.d.ts +165 -0
  270. package/dist/lib/object/utils.d.ts.map +1 -0
  271. package/dist/lib/object/utils.js +444 -0
  272. package/dist/lib/object/utils.mjs +6 -0
  273. package/dist/lib/primitive/boolean/boolean.cjs +1 -0
  274. package/dist/lib/primitive/boolean/boolean.d.ts +276 -0
  275. package/dist/lib/primitive/boolean/boolean.d.ts.map +1 -0
  276. package/dist/lib/primitive/boolean/boolean.js +615 -0
  277. package/dist/lib/primitive/boolean/boolean.mjs +1 -0
  278. package/dist/lib/primitive/boolean/index.cjs +1 -0
  279. package/dist/lib/primitive/boolean/index.d.ts +3 -0
  280. package/dist/lib/primitive/boolean/index.d.ts.map +1 -0
  281. package/dist/lib/primitive/boolean/index.js +2 -0
  282. package/dist/lib/primitive/boolean/index.mjs +1 -0
  283. package/dist/lib/primitive/boolean/types.cjs +1 -0
  284. package/dist/lib/primitive/boolean/types.d.ts +14 -0
  285. package/dist/lib/primitive/boolean/types.d.ts.map +1 -0
  286. package/dist/lib/primitive/boolean/types.js +1 -0
  287. package/dist/lib/primitive/boolean/types.mjs +0 -0
  288. package/dist/lib/primitive/date/date.cjs +1 -0
  289. package/dist/lib/primitive/date/date.d.ts +641 -0
  290. package/dist/lib/primitive/date/date.d.ts.map +1 -0
  291. package/dist/lib/primitive/date/date.js +1998 -0
  292. package/dist/lib/primitive/date/date.mjs +1 -0
  293. package/dist/lib/primitive/date/index.cjs +1 -0
  294. package/dist/lib/primitive/date/index.d.ts +3 -0
  295. package/dist/lib/primitive/date/index.d.ts.map +1 -0
  296. package/dist/lib/primitive/date/index.js +2 -0
  297. package/dist/lib/primitive/date/index.mjs +1 -0
  298. package/dist/lib/primitive/date/types.cjs +1 -0
  299. package/dist/lib/primitive/date/types.d.ts +205 -0
  300. package/dist/lib/primitive/date/types.d.ts.map +1 -0
  301. package/dist/lib/primitive/date/types.js +7 -0
  302. package/dist/lib/primitive/date/types.mjs +0 -0
  303. package/dist/lib/primitive/index.cjs +5 -0
  304. package/dist/lib/primitive/index.d.ts +5 -0
  305. package/dist/lib/primitive/index.d.ts.map +1 -0
  306. package/dist/lib/primitive/index.js +4 -0
  307. package/dist/lib/primitive/index.mjs +5 -0
  308. package/dist/lib/primitive/string/index.cjs +5 -0
  309. package/dist/lib/primitive/string/index.d.ts +3 -0
  310. package/dist/lib/primitive/string/index.d.ts.map +1 -0
  311. package/dist/lib/primitive/string/index.js +2 -0
  312. package/dist/lib/primitive/string/index.mjs +5 -0
  313. package/dist/lib/primitive/string/parser-2.cjs +8 -0
  314. package/dist/lib/primitive/string/parser-2.d.ts +17 -0
  315. package/dist/lib/primitive/string/parser-2.d.ts.map +1 -0
  316. package/dist/lib/primitive/string/parser-2.js +656 -0
  317. package/dist/lib/primitive/string/parser-2.mjs +8 -0
  318. package/dist/lib/primitive/string/parser.cjs +3 -0
  319. package/dist/lib/primitive/string/parser.d.ts +9 -0
  320. package/dist/lib/primitive/string/parser.d.ts.map +1 -0
  321. package/dist/lib/primitive/string/parser.js +775 -0
  322. package/dist/lib/primitive/string/parser.mjs +3 -0
  323. package/dist/lib/primitive/string/string.cjs +5 -0
  324. package/dist/lib/primitive/string/string.d.ts +535 -0
  325. package/dist/lib/primitive/string/string.d.ts.map +1 -0
  326. package/dist/lib/primitive/string/string.js +1301 -0
  327. package/dist/lib/primitive/string/string.mjs +5 -0
  328. package/dist/lib/primitive/string/types.cjs +1 -0
  329. package/dist/lib/primitive/string/types.d.ts +318 -0
  330. package/dist/lib/primitive/string/types.d.ts.map +1 -0
  331. package/dist/lib/primitive/string/types.js +5 -0
  332. package/dist/lib/primitive/string/types.mjs +0 -0
  333. package/dist/lib/primitive/types.cjs +1 -0
  334. package/dist/lib/primitive/types.d.ts +27 -0
  335. package/dist/lib/primitive/types.d.ts.map +1 -0
  336. package/dist/lib/primitive/types.js +1 -0
  337. package/dist/lib/primitive/types.mjs +0 -0
  338. package/dist/lib/url/index.cjs +1 -0
  339. package/dist/lib/url/index.d.ts +3 -0
  340. package/dist/lib/url/index.d.ts.map +1 -0
  341. package/dist/lib/url/index.js +2 -0
  342. package/dist/lib/url/index.mjs +1 -0
  343. package/dist/lib/url/parser.cjs +1 -0
  344. package/dist/lib/url/parser.d.ts +216 -0
  345. package/dist/lib/url/parser.d.ts.map +1 -0
  346. package/dist/lib/url/parser.js +488 -0
  347. package/dist/lib/url/parser.mjs +1 -0
  348. package/dist/lib/url/types.cjs +1 -0
  349. package/dist/lib/url/types.d.ts +18 -0
  350. package/dist/lib/url/types.d.ts.map +1 -0
  351. package/dist/lib/url/types.js +1 -0
  352. package/dist/lib/url/types.mjs +0 -0
  353. package/dist/tsconfig.lib.tsbuildinfo +1 -0
  354. package/package.json +150 -0
@@ -0,0 +1,1116 @@
1
+ /**
2
+ * @fileoverview Advanced array utilities with object integration
3
+ * Provides powerful array manipulation functions that work seamlessly with objects
4
+ */
5
+ import type { AnyObject } from '../object/types.js';
6
+ /**
7
+ * Chunks an array into smaller arrays of specified size
8
+ * @param array - Source array
9
+ * @param size - Chunk size
10
+ * @returns Array of chunks
11
+ * @example
12
+ * chunk([1, 2, 3, 4, 5], 2) // [[1, 2], [3, 4], [5]]
13
+ */
14
+ export declare function chunk<T>(array: T[], size: number): T[][];
15
+ /**
16
+ * Flattens array by one level
17
+ * @param array - Source array
18
+ * @returns Flattened array
19
+ * @example
20
+ * flatten([[1, 2], [3, 4]]) // [1, 2, 3, 4]
21
+ */
22
+ export declare function flatten<T>(array: (T | T[])[]): T[];
23
+ /**
24
+ * Deeply flattens nested arrays
25
+ * @param array - Source array
26
+ * @param depth - Maximum depth (default: Infinity)
27
+ * @returns Flattened array
28
+ * @example
29
+ * flattenDeep([[1, [2, [3, [4]]]]) // [1, 2, 3, 4]
30
+ */
31
+ export declare function flattenDeep<T>(array: any[], depth?: number): T[];
32
+ /**
33
+ * Returns unique values from array
34
+ * @param array - Source array
35
+ * @param selector - Optional key path or function for comparison
36
+ * @returns Array with unique values
37
+ * @example
38
+ * unique([1, 2, 2, 3]) // [1, 2, 3]
39
+ * unique([{id: 1}, {id: 2}, {id: 1}], 'id') // [{id: 1}, {id: 2}]
40
+ * unique([{x: 1}, {x: 2}, {x: 1}], item => item.x) // [{x: 1}, {x: 2}]
41
+ */
42
+ export declare function unique<T>(array: T[], selector?: keyof T | string | ((item: T) => any)): T[];
43
+ /**
44
+ * Groups array elements by key or callback
45
+ * @param array - Source array
46
+ * @param keyOrFn - Key name or grouping function
47
+ * @returns Grouped object
48
+ * @example
49
+ * groupBy([{type: 'a', v: 1}, {type: 'b', v: 2}, {type: 'a', v: 3}], 'type')
50
+ * // {a: [{type: 'a', v: 1}, {type: 'a', v: 3}], b: [{type: 'b', v: 2}]}
51
+ */
52
+ export declare function groupBy<T>(array: T[], keyOrFn: keyof T | string | ((item: T) => string | number)): Record<string, T[]>;
53
+ /**
54
+ * Counts occurrences of each value
55
+ * @param array - Source array
56
+ * @param key - Optional key for object arrays
57
+ * @returns Count object
58
+ * @example
59
+ * countBy(['a', 'b', 'a', 'c']) // {a: 2, b: 1, c: 1}
60
+ */
61
+ export declare function countBy<T>(array: T[], key?: keyof T | string | ((item: T) => string | number)): Record<string, number>;
62
+ /**
63
+ * Creates object from array using key/value extractors
64
+ * @param array - Source array
65
+ * @param keyFn - Key extractor function or key name
66
+ * @param valueFn - Value extractor function or value name (optional)
67
+ * @returns Object
68
+ * @example
69
+ * keyBy([{id: 1, name: 'a'}, {id: 2, name: 'b'}], 'id')
70
+ * // {1: {id: 1, name: 'a'}, 2: {id: 2, name: 'b'}}
71
+ */
72
+ export declare function keyBy<T, V = T>(array: T[], keyFn: keyof T | string | ((item: T) => string | number), valueFn?: keyof T | string | ((item: T) => V)): Record<string, V>;
73
+ /**
74
+ * Sorts array by key or multiple keys
75
+ * @param array - Source array
76
+ * @param keys - Sort key(s) with optional direction
77
+ * @returns Sorted array (new array)
78
+ * @example
79
+ * sortBy([{a: 3}, {a: 1}, {a: 2}], 'a') // [{a: 1}, {a: 2}, {a: 3}]
80
+ * sortBy([{a: 1, b: 3}, {a: 1, b: 1}], ['a', {key: 'b', dir: 'desc'}])
81
+ */
82
+ export declare function sortBy<T>(array: T[], keys: keyof T | string | (keyof T | string | {
83
+ key: keyof T | string;
84
+ dir?: 'asc' | 'desc';
85
+ })[]): T[];
86
+ /**
87
+ * Finds difference between two arrays
88
+ * @param array1 - First array
89
+ * @param array2 - Second array
90
+ * @param key - Optional key for object comparison
91
+ * @returns Elements in array1 not in array2
92
+ * @example
93
+ * difference([1, 2, 3], [2, 3, 4]) // [1]
94
+ */
95
+ export declare function difference<T>(array1: T[], array2: T[], key?: keyof T | string): T[];
96
+ /**
97
+ * Finds intersection of two arrays
98
+ * @param array1 - First array
99
+ * @param array2 - Second array
100
+ * @param key - Optional key for object comparison
101
+ * @returns Common elements
102
+ * @example
103
+ * intersection([1, 2, 3], [2, 3, 4]) // [2, 3]
104
+ */
105
+ export declare function intersection<T>(array1: T[], array2: T[], key?: keyof T | string): T[];
106
+ /**
107
+ * Finds union of two arrays (unique elements from both)
108
+ * @param array1 - First array
109
+ * @param array2 - Second array
110
+ * @param key - Optional key for object comparison
111
+ * @returns Union of arrays
112
+ * @example
113
+ * union([1, 2], [2, 3]) // [1, 2, 3]
114
+ */
115
+ export declare function union<T>(array1: T[], array2: T[], key?: keyof T | string): T[];
116
+ /**
117
+ * Partitions array into two groups based on predicate
118
+ * @param array - Source array
119
+ * @param predicate - Test function
120
+ * @returns [truthy, falsy]
121
+ * @example
122
+ * partition([1, 2, 3, 4], x => x % 2 === 0) // [[2, 4], [1, 3]]
123
+ */
124
+ export declare function partition<T>(array: T[], predicate: (item: T, index: number) => boolean): [T[], T[]];
125
+ /**
126
+ * Takes first n elements from array
127
+ * @param array - Source array
128
+ * @param n - Number of elements
129
+ * @returns First n elements
130
+ * @example
131
+ * take([1, 2, 3, 4], 2) // [1, 2]
132
+ */
133
+ export declare function take<T>(array: T[], n: number): T[];
134
+ /**
135
+ * Takes last n elements from array
136
+ * @param array - Source array
137
+ * @param n - Number of elements
138
+ * @returns Last n elements
139
+ * @example
140
+ * takeLast([1, 2, 3, 4], 2) // [3, 4]
141
+ */
142
+ export declare function takeLast<T>(array: T[], n: number): T[];
143
+ /**
144
+ * Takes elements while predicate is true
145
+ * @param array - Source array
146
+ * @param predicate - Test function
147
+ * @returns Elements taken
148
+ * @example
149
+ * takeWhile([1, 2, 3, 4], x => x < 3) // [1, 2]
150
+ */
151
+ export declare function takeWhile<T>(array: T[], predicate: (item: T, index: number) => boolean): T[];
152
+ /**
153
+ * Drops first n elements from array
154
+ * @param array - Source array
155
+ * @param n - Number of elements to drop
156
+ * @returns Remaining elements
157
+ * @example
158
+ * drop([1, 2, 3, 4], 2) // [3, 4]
159
+ */
160
+ export declare function drop<T>(array: T[], n: number): T[];
161
+ /**
162
+ * Drops elements while predicate is true
163
+ * @param array - Source array
164
+ * @param predicate - Test function
165
+ * @returns Remaining elements
166
+ * @example
167
+ * dropWhile([1, 2, 3, 4], x => x < 3) // [3, 4]
168
+ */
169
+ export declare function dropWhile<T>(array: T[], predicate: (item: T, index: number) => boolean): T[];
170
+ /**
171
+ * Compacts array by removing falsy values
172
+ * @param array - Source array
173
+ * @returns Array without falsy values
174
+ * @example
175
+ * compact([0, 1, false, 2, '', 3, null]) // [1, 2, 3]
176
+ */
177
+ export declare function compact<T>(array: (T | null | undefined | false | 0 | '')[]): T[];
178
+ /**
179
+ * Zips multiple arrays together
180
+ * @param arrays - Arrays to zip
181
+ * @returns Zipped array
182
+ * @example
183
+ * zip([1, 2], ['a', 'b'], [true, false]) // [[1, 'a', true], [2, 'b', false]]
184
+ */
185
+ export declare function zip<T extends any[][]>(...arrays: T): any[][];
186
+ /**
187
+ * Unzips array of arrays
188
+ * @param array - Array to unzip
189
+ * @returns Unzipped arrays
190
+ * @example
191
+ * unzip([[1, 'a'], [2, 'b']]) // [[1, 2], ['a', 'b']]
192
+ */
193
+ export declare function unzip<T>(array: T[][]): T[][];
194
+ /**
195
+ * Shuffles array randomly
196
+ * @param array - Source array
197
+ * @returns Shuffled array (new array)
198
+ * @example
199
+ * shuffle([1, 2, 3, 4, 5])
200
+ */
201
+ export declare function shuffle<T>(array: T[]): T[];
202
+ /**
203
+ * Gets random element from array
204
+ * @param array - Source array
205
+ * @returns Random element
206
+ * @example
207
+ * sample([1, 2, 3, 4, 5]) // Random element
208
+ */
209
+ export declare function sample<T>(array: T[]): T | undefined;
210
+ /**
211
+ * Gets n random elements from array
212
+ * @param array - Source array
213
+ * @param n - Number of elements
214
+ * @returns Random elements
215
+ * @example
216
+ * sampleSize([1, 2, 3, 4, 5], 3) // 3 random elements
217
+ */
218
+ export declare function sampleSize<T>(array: T[], n: number): T[];
219
+ /**
220
+ * Finds index of element using predicate
221
+ * @param array - Source array
222
+ * @param predicate - Search function
223
+ * @param fromIndex - Start index
224
+ * @returns Index or -1
225
+ * @example
226
+ * findIndex([1, 2, 3, 4], x => x > 2) // 2
227
+ */
228
+ export declare function findIndex<T>(array: T[], predicate: (item: T, index: number) => boolean, fromIndex?: number): number;
229
+ /**
230
+ * Finds last index of element using predicate
231
+ * @param array - Source array
232
+ * @param predicate - Search function
233
+ * @param fromIndex - Start index (from end)
234
+ * @returns Index or -1
235
+ * @example
236
+ * findLastIndex([1, 2, 3, 4, 3], x => x === 3) // 4
237
+ */
238
+ export declare function findLastIndex<T>(array: T[], predicate: (item: T, index: number) => boolean, fromIndex?: number): number;
239
+ /**
240
+ * Creates array of values at given paths
241
+ * @param array - Source array of objects
242
+ * @param path - Property path
243
+ * @returns Array of values
244
+ * @example
245
+ * pluck([{a: {b: 1}}, {a: {b: 2}}], 'a.b') // [1, 2]
246
+ */
247
+ export declare function pluck<T extends AnyObject, R = any>(array: T[], path: string): R[];
248
+ /**
249
+ * Extracts object properties from array
250
+ * @param array - Source array of objects
251
+ * @param keys - Keys to pick
252
+ * @returns Array of objects with picked keys
253
+ * @example
254
+ * pick([{a: 1, b: 2}, {a: 3, b: 4}], ['a']) // [{a: 1}, {a: 3}]
255
+ */
256
+ export declare function pick<T extends AnyObject, K extends keyof T>(array: T[], keys: K[]): Pick<T, K>[];
257
+ /**
258
+ * Omits object properties from array
259
+ * @param array - Source array of objects
260
+ * @param keys - Keys to omit
261
+ * @returns Array of objects without omitted keys
262
+ * @example
263
+ * omit([{a: 1, b: 2}, {a: 3, b: 4}], ['b']) // [{a: 1}, {a: 3}]
264
+ */
265
+ export declare function omit<T extends AnyObject, K extends keyof T>(array: T[], keys: K[]): Omit<T, K>[];
266
+ /**
267
+ * Maps and flattens array in one operation
268
+ * @param array - Source array
269
+ * @param callback - Mapping function
270
+ * @returns Flattened mapped array
271
+ * @example
272
+ * flatMap([1, 2, 3], x => [x, x * 2]) // [1, 2, 2, 4, 3, 6]
273
+ */
274
+ export declare function flatMap<T, R>(array: T[], callback: (item: T, index: number) => R | R[]): R[];
275
+ /**
276
+ * Reduces array from right to left
277
+ * @param array - Source array
278
+ * @param callback - Reducer function
279
+ * @param initialValue - Initial value
280
+ * @returns Reduced value
281
+ * @example
282
+ * reduceRight([1, 2, 3], (acc, val) => acc + val, 0) // 6
283
+ */
284
+ export declare function reduceRight<T, R>(array: T[], callback: (accumulator: R, value: T, index: number) => R, initialValue: R): R;
285
+ /**
286
+ * Creates array of numbers in range
287
+ * @param start - Start value
288
+ * @param end - End value (exclusive)
289
+ * @param step - Step value
290
+ * @returns Range array
291
+ * @example
292
+ * range(0, 5) // [0, 1, 2, 3, 4]
293
+ * range(0, 10, 2) // [0, 2, 4, 6, 8]
294
+ */
295
+ export declare function range(start: number, end: number, step?: number): number[];
296
+ /**
297
+ * Fills array with value (similar to Array.prototype.fill)
298
+ * @param array - Source array
299
+ * @param value - Fill value
300
+ * @param start - Start index (default: 0)
301
+ * @param end - End index (default: array.length)
302
+ * @returns New array with filled values
303
+ * @example
304
+ * fill([1, 2, 3], 0) // [0, 0, 0]
305
+ * fill([1, 2, 3, 4, 5], 9, 1, 3) // [1, 9, 9, 4, 5]
306
+ */
307
+ export declare function fill<T>(array: T[], value: T, start?: number, end?: number): T[];
308
+ /**
309
+ * Deeply clones array (including nested objects)
310
+ * @param array - Source array
311
+ * @returns Cloned array
312
+ * @example
313
+ * deepCloneArray([{a: 1}, {b: 2}])
314
+ */
315
+ export declare function deepCloneArray<T>(array: T[]): T[];
316
+ /**
317
+ * Merges multiple arrays of objects by key
318
+ * @param arr1 - First array
319
+ * @param arr2 - Second array (or key if only merging arr1)
320
+ * @param keyOrMore - Key to merge by, or more arrays
321
+ * @returns Merged array
322
+ * @example
323
+ * mergeByKey([{id: 1, a: 1}], [{id: 1, b: 2}], 'id')
324
+ * // [{id: 1, a: 1, b: 2}]
325
+ */
326
+ export declare function mergeByKey<T extends AnyObject>(arr1: T[], arr2: T[] | string, ...keyOrMore: (T[] | string)[]): T[];
327
+ /**
328
+ * Moves array element from one index to another
329
+ * @param array - Source array
330
+ * @param fromIndex - Source index
331
+ * @param toIndex - Destination index
332
+ * @returns New array with moved element
333
+ * @example
334
+ * move([1, 2, 3, 4], 0, 2) // [2, 3, 1, 4]
335
+ */
336
+ export declare function move<T>(array: T[], fromIndex: number, toIndex: number): T[];
337
+ /**
338
+ * Rotates array elements
339
+ * @param array - Source array
340
+ * @param n - Number of positions (positive = right, negative = left)
341
+ * @returns Rotated array
342
+ * @example
343
+ * rotate([1, 2, 3, 4], 1) // [4, 1, 2, 3]
344
+ * rotate([1, 2, 3, 4], -1) // [2, 3, 4, 1]
345
+ */
346
+ export declare function rotate<T>(array: T[], n: number): T[];
347
+ /**
348
+ * Inserts element at index
349
+ * @param array - Source array
350
+ * @param index - Insert index
351
+ * @param items - Items to insert
352
+ * @returns New array
353
+ * @example
354
+ * insert([1, 2, 4], 2, 3) // [1, 2, 3, 4]
355
+ */
356
+ export declare function insert<T>(array: T[], index: number, ...items: T[]): T[];
357
+ /**
358
+ * Removes element at index
359
+ * @param array - Source array
360
+ * @param index - Remove index
361
+ * @param count - Number of elements to remove
362
+ * @returns New array
363
+ * @example
364
+ * remove([1, 2, 3, 4], 1, 2) // [1, 4]
365
+ */
366
+ export declare function remove<T>(array: T[], index: number, count?: number): T[];
367
+ /**
368
+ * Replaces element at index
369
+ * @param array - Source array
370
+ * @param index - Replace index
371
+ * @param item - New item
372
+ * @returns New array
373
+ * @example
374
+ * replace([1, 2, 3], 1, 5) // [1, 5, 3]
375
+ */
376
+ export declare function replace<T>(array: T[], index: number, item: T): T[];
377
+ /**
378
+ * Filters array and removes null/undefined
379
+ * @param array - Source array
380
+ * @param predicate - Filter function
381
+ * @returns Filtered array without null/undefined
382
+ * @example
383
+ * filterCompact([1, null, 2, undefined, 3], x => x) // [1, 2, 3]
384
+ */
385
+ export declare function filterCompact<T>(array: (T | null | undefined)[], predicate?: (item: T) => boolean): T[];
386
+ /**
387
+ * Creates cartesian product of arrays
388
+ * @param arrays - Arrays to combine
389
+ * @returns Cartesian product
390
+ * @example
391
+ * cartesian([1, 2], ['a', 'b']) // [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]
392
+ */
393
+ export declare function cartesian<T extends any[][]>(...arrays: T): any[][];
394
+ /**
395
+ * Finds all indices where predicate is true
396
+ * @param array - Source array
397
+ * @param predicate - Test function
398
+ * @returns Array of indices
399
+ * @example
400
+ * findAllIndices([1, 2, 3, 2, 1], x => x === 2) // [1, 3]
401
+ */
402
+ export declare function findAllIndices<T>(array: T[], predicate: (item: T, index: number) => boolean): number[];
403
+ /**
404
+ * Checks if arrays are equal
405
+ * @param array1 - First array
406
+ * @param array2 - Second array
407
+ * @param deep - Deep comparison
408
+ * @returns True if equal
409
+ * @example
410
+ * isEqual([1, 2, 3], [1, 2, 3]) // true
411
+ */
412
+ export declare function isEqual<T>(array1: T[], array2: T[], deep?: boolean): boolean;
413
+ /**
414
+ * Splits array into chunks where predicate changes
415
+ * @param array - Source array
416
+ * @param predicate - Grouping function
417
+ * @returns Chunked array
418
+ * @example
419
+ * chunkBy([1, 1, 2, 2, 3], x => x) // [[1, 1], [2, 2], [3]]
420
+ */
421
+ export declare function chunkBy<T>(array: T[], predicate: (item: T, index: number) => any): T[][];
422
+ /**
423
+ * Updates array elements by predicate or key/value
424
+ * @param array - Source array
425
+ * @param predicate - Predicate function or key to match
426
+ * @param updates - Updates to apply (or value if predicate is a key)
427
+ * @param updatesOrUndefined - Updates if using key/value form
428
+ * @returns Updated array
429
+ * @example
430
+ * updateBy([{id: 1, name: 'a'}], x => x.id === 1, {name: 'b'}) // [{id: 1, name: 'b'}]
431
+ * updateBy([{id: 1, name: 'a'}], 'id', 1, {name: 'b'}) // [{id: 1, name: 'b'}]
432
+ */
433
+ export declare function updateBy<T extends AnyObject>(array: T[], predicate: ((item: T) => boolean) | keyof T | string, updates: any, updatesOrUndefined?: Partial<T>): T[];
434
+ /**
435
+ * Removes duplicates and returns removed items
436
+ * @param array - Source array
437
+ * @param key - Optional key for objects
438
+ * @returns Object with unique and duplicates arrays
439
+ * @example
440
+ * splitDuplicates([1, 2, 2, 3, 3]) // { unique: [1, 2, 3], duplicates: [2, 3] }
441
+ */
442
+ export declare function splitDuplicates<T>(array: T[], key?: keyof T | string): {
443
+ unique: T[];
444
+ duplicates: T[];
445
+ };
446
+ /**
447
+ * Ensures array (converts non-array to array)
448
+ * @param value - Value to ensure as array
449
+ * @returns Array
450
+ * @example
451
+ * ensureArray(1) // [1]
452
+ * ensureArray([1, 2]) // [1, 2]
453
+ */
454
+ export declare function ensureArray<T>(value: T | T[]): T[];
455
+ /**
456
+ * Wraps value in array if not already an array
457
+ * @param value - Value to wrap
458
+ * @returns Array
459
+ * @example
460
+ * wrap(1) // [1]
461
+ * wrap([1]) // [1]
462
+ */
463
+ export declare function wrap<T>(value: T | T[]): T[];
464
+ /**
465
+ * Creates sliding windows of specified size over the array
466
+ * @param array - Source array
467
+ * @param size - Window size
468
+ * @param step - Step size between windows (default: 1)
469
+ * @returns Array of windows
470
+ * @example
471
+ * slidingWindow([1, 2, 3, 4, 5], 3) // [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
472
+ * slidingWindow([1, 2, 3, 4, 5], 2, 2) // [[1, 2], [3, 4]]
473
+ */
474
+ export declare function slidingWindow<T>(array: T[], size: number, step?: number): T[][];
475
+ /**
476
+ * Finds the minimum value in an array by comparing a key/selector
477
+ * @param array - Source array
478
+ * @param selector - Key path or selector function
479
+ * @returns Element with minimum value, or undefined if array is empty
480
+ * @example
481
+ * minBy([{ age: 30 }, { age: 20 }], 'age') // { age: 20 }
482
+ * minBy([{ price: 100 }, { price: 50 }], obj => obj.price) // { price: 50 }
483
+ */
484
+ export declare function minBy<T>(array: T[], selector: string | ((item: T) => any)): T | undefined;
485
+ /**
486
+ * Finds the maximum value in an array by comparing a key/selector
487
+ * @param array - Source array
488
+ * @param selector - Key path or selector function
489
+ * @returns Element with maximum value, or undefined if array is empty
490
+ * @example
491
+ * maxBy([{ age: 30 }, { age: 20 }], 'age') // { age: 30 }
492
+ * maxBy([{ price: 100 }, { price: 50 }], obj => obj.price) // { price: 100 }
493
+ */
494
+ export declare function maxBy<T>(array: T[], selector: string | ((item: T) => any)): T | undefined;
495
+ /**
496
+ * Calculates sum of values in array by key/selector
497
+ * @param array - Source array
498
+ * @param selector - Key path or selector function
499
+ * @returns Sum of values
500
+ * @example
501
+ * sumBy([{ price: 10 }, { price: 20 }], 'price') // 30
502
+ * sumBy([{ x: 5 }, { x: 10 }], obj => obj.x) // 15
503
+ */
504
+ export declare function sumBy<T>(array: T[], selector: string | ((item: T) => number)): number;
505
+ /**
506
+ * Calculates average of values in array by key/selector
507
+ * @param array - Source array
508
+ * @param selector - Key path or selector function
509
+ * @returns Average of values, or 0 if array is empty
510
+ * @example
511
+ * avgBy([{ score: 80 }, { score: 90 }], 'score') // 85
512
+ * avgBy([{ x: 10 }, { x: 20 }], obj => obj.x) // 15
513
+ */
514
+ export declare function avgBy<T>(array: T[], selector: string | ((item: T) => number)): number;
515
+ /**
516
+ * Counts frequency of each unique value in array
517
+ * @param array - Source array
518
+ * @returns Map of value to frequency count
519
+ * @example
520
+ * frequencies([1, 2, 2, 3, 3, 3]) // Map { 1 => 1, 2 => 2, 3 => 3 }
521
+ * frequencies(['a', 'b', 'a']) // Map { 'a' => 2, 'b' => 1 }
522
+ */
523
+ export declare function frequencies<T>(array: T[]): Map<T, number>;
524
+ /**
525
+ * Finds the most common value(s) in array
526
+ * @param array - Source array
527
+ * @param limit - Maximum number of values to return (default: 1)
528
+ * @returns Array of most common values
529
+ * @example
530
+ * mostCommon([1, 2, 2, 3, 3, 3]) // [3]
531
+ * mostCommon([1, 1, 2, 2, 3], 2) // [1, 2] or [2, 1]
532
+ */
533
+ export declare function mostCommon<T>(array: T[], limit?: number): T[];
534
+ /**
535
+ * Finds the least common value(s) in array
536
+ * @param array - Source array
537
+ * @param limit - Maximum number of values to return (default: 1)
538
+ * @returns Array of least common values
539
+ * @example
540
+ * leastCommon([1, 2, 2, 3, 3, 3]) // [1]
541
+ * leastCommon([1, 1, 2, 2, 3, 3], 3) // [1, 2, 3] or any order
542
+ */
543
+ export declare function leastCommon<T>(array: T[], limit?: number): T[];
544
+ /**
545
+ * Processes array in batches with async callback
546
+ * @param array - Source array
547
+ * @param batchSize - Size of each batch
548
+ * @param callback - Async function to process each batch
549
+ * @returns Promise that resolves when all batches are processed
550
+ * @example
551
+ * await batchProcess([1, 2, 3, 4], 2, async (batch) => {
552
+ * await saveToDatabase(batch);
553
+ * });
554
+ */
555
+ export declare function batchProcess<T>(array: T[], batchSize: number, callback: (batch: T[], index: number) => Promise<void>): Promise<void>;
556
+ /**
557
+ * Processes array in batches in parallel with concurrency limit
558
+ * @param array - Source array
559
+ * @param batchSize - Size of each batch
560
+ * @param concurrency - Maximum number of concurrent batches
561
+ * @param callback - Async function to process each batch
562
+ * @returns Promise that resolves when all batches are processed
563
+ * @example
564
+ * await batchProcessParallel([1, 2, 3, 4, 5, 6], 2, 2, async (batch) => {
565
+ * await saveToDatabase(batch);
566
+ * });
567
+ */
568
+ export declare function batchProcessParallel<T>(array: T[], batchSize: number, concurrency: number, callback: (batch: T[], index: number) => Promise<void>): Promise<void>;
569
+ /**
570
+ * Transposes a 2D array (rows become columns, columns become rows)
571
+ * @param matrix - 2D array to transpose
572
+ * @returns Transposed 2D array
573
+ * @example
574
+ * transpose([[1, 2], [3, 4], [5, 6]]) // [[1, 3, 5], [2, 4, 6]]
575
+ */
576
+ export declare function transpose<T>(matrix: T[][]): T[][];
577
+ /**
578
+ * Checks if two arrays are equal (shallow comparison)
579
+ * @param array1 - First array
580
+ * @param array2 - Second array
581
+ * @returns True if arrays are equal
582
+ * @example
583
+ * isArrayEqual([1, 2, 3], [1, 2, 3]) // true
584
+ * isArrayEqual([1, 2], [1, 2, 3]) // false
585
+ */
586
+ export declare function isArrayEqual<T>(array1: T[], array2: T[]): boolean;
587
+ /**
588
+ * Checks if two arrays contain the same elements (order doesn't matter)
589
+ * @param array1 - First array
590
+ * @param array2 - Second array
591
+ * @returns True if arrays contain same elements
592
+ * @example
593
+ * hasSameElements([1, 2, 3], [3, 2, 1]) // true
594
+ * hasSameElements([1, 2], [1, 2, 2]) // false
595
+ */
596
+ export declare function hasSameElements<T>(array1: T[], array2: T[]): boolean;
597
+ /**
598
+ * Checks if array1 is a subset of array2 (all elements in array1 exist in array2)
599
+ * @param array1 - Subset array
600
+ * @param array2 - Superset array
601
+ * @returns True if array1 is a subset of array2
602
+ * @example
603
+ * isSubset([1, 2], [1, 2, 3, 4]) // true
604
+ * isSubset([1, 5], [1, 2, 3, 4]) // false
605
+ */
606
+ export declare function isSubset<T>(array1: T[], array2: T[]): boolean;
607
+ /**
608
+ * Checks if array1 is a superset of array2 (all elements in array2 exist in array1)
609
+ * @param array1 - Superset array
610
+ * @param array2 - Subset array
611
+ * @returns True if array1 is a superset of array2
612
+ * @example
613
+ * isSuperset([1, 2, 3, 4], [1, 2]) // true
614
+ * isSuperset([1, 2, 3], [1, 5]) // false
615
+ */
616
+ export declare function isSuperset<T>(array1: T[], array2: T[]): boolean;
617
+ /**
618
+ * Interleaves multiple arrays (takes one element from each in turn)
619
+ * @param arrays - Arrays to interleave
620
+ * @returns Interleaved array
621
+ * @example
622
+ * interleave([1, 2], ['a', 'b'], [true, false]) // [1, 'a', true, 2, 'b', false]
623
+ */
624
+ export declare function interleave<T>(...arrays: T[][]): T[];
625
+ /**
626
+ * Splits array into two arrays based on a predicate
627
+ * Similar to partition but returns object with named properties
628
+ * @param array - Source array
629
+ * @param predicate - Function to test each element
630
+ * @returns Object with 'pass' and 'fail' arrays
631
+ * @example
632
+ * bifurcate([1, 2, 3, 4], x => x % 2 === 0) // { pass: [2, 4], fail: [1, 3] }
633
+ */
634
+ export declare function bifurcate<T>(array: T[], predicate: (item: T, index: number) => boolean): {
635
+ pass: T[];
636
+ fail: T[];
637
+ };
638
+ /**
639
+ * Creates an array with a specified length filled with values from a generator function
640
+ * @param length - Length of array
641
+ * @param generator - Function that generates value for each index
642
+ * @returns Generated array
643
+ * @example
644
+ * generate(5, i => i * 2) // [0, 2, 4, 6, 8]
645
+ * generate(3, () => Math.random()) // [0.123, 0.456, 0.789]
646
+ */
647
+ export declare function generate<T>(length: number, generator: (index: number) => T): T[];
648
+ /**
649
+ * Repeats an array n times
650
+ * @param array - Source array
651
+ * @param times - Number of times to repeat
652
+ * @returns New array with repeated elements
653
+ * @example
654
+ * repeat([1, 2], 3) // [1, 2, 1, 2, 1, 2]
655
+ */
656
+ export declare function repeat<T>(array: T[], times: number): T[];
657
+ /**
658
+ * Finds the median value in a numeric array
659
+ * @param array - Array of numbers
660
+ * @returns Median value, or undefined if array is empty
661
+ * @example
662
+ * median([1, 2, 3, 4, 5]) // 3
663
+ * median([1, 2, 3, 4]) // 2.5
664
+ */
665
+ export declare function median(array: number[]): number | undefined;
666
+ /**
667
+ * Calculates the mode (most frequent value) in an array
668
+ * @param array - Source array
669
+ * @returns Most frequent value, or undefined if array is empty
670
+ * @example
671
+ * mode([1, 2, 2, 3, 3, 3]) // 3
672
+ * mode(['a', 'b', 'b']) // 'b'
673
+ */
674
+ export declare function mode<T>(array: T[]): T | undefined;
675
+ /**
676
+ * Removes all occurrences of specified values from array
677
+ * @param array - Source array
678
+ * @param values - Values to remove
679
+ * @returns New array without specified values
680
+ * @example
681
+ * without([1, 2, 3, 2, 4], 2, 3) // [1, 4]
682
+ */
683
+ export declare function without<T>(array: T[], ...values: T[]): T[];
684
+ /**
685
+ * Creates array of unique values that are in the first array but not in other arrays
686
+ * @param array - Source array
687
+ * @param others - Arrays to exclude
688
+ * @returns Array with values only in first array
689
+ * @example
690
+ * differenceWith([1, 2, 3], [2], [3]) // [1]
691
+ */
692
+ export declare function differenceWith<T>(array: T[], ...others: T[][]): T[];
693
+ /**
694
+ * Groups consecutive identical values together
695
+ * @param array - Source array
696
+ * @returns Array of arrays with consecutive identical values
697
+ * @example
698
+ * groupConsecutive([1, 1, 2, 2, 2, 3, 1]) // [[1, 1], [2, 2, 2], [3], [1]]
699
+ */
700
+ export declare function groupConsecutive<T>(array: T[]): T[][];
701
+ /**
702
+ * Removes consecutive duplicate values
703
+ * @param array - Source array
704
+ * @returns Array without consecutive duplicates
705
+ * @example
706
+ * dedupeConsecutive([1, 1, 2, 2, 2, 3, 1]) // [1, 2, 3, 1]
707
+ */
708
+ export declare function dedupeConsecutive<T>(array: T[]): T[];
709
+ /**
710
+ * Assigns ranks to array elements (1-based, lower values get lower ranks)
711
+ * @param array - Array of numbers
712
+ * @param method - Ranking method: 'standard', 'dense', or 'ordinal'
713
+ * @returns Array of ranks corresponding to input array
714
+ * @example
715
+ * rank([10, 20, 20, 30]) // [1, 2, 2, 4] (standard)
716
+ * rank([10, 20, 20, 30], 'dense') // [1, 2, 2, 3]
717
+ * rank([10, 20, 20, 30], 'ordinal') // [1, 2, 3, 4]
718
+ */
719
+ export declare function rank(array: number[], method?: 'standard' | 'dense' | 'ordinal'): number[];
720
+ /**
721
+ * Calculates the percentile value from a sorted or unsorted array
722
+ * @param array - Array of numbers
723
+ * @param percentile - Percentile to calculate (0-100)
724
+ * @returns Percentile value, or undefined if array is empty
725
+ * @example
726
+ * percentile([1, 2, 3, 4, 5], 50) // 3 (median)
727
+ * percentile([1, 2, 3, 4, 5, 6], 75) // 4.75
728
+ */
729
+ export declare function percentile(array: number[], percentile: number): number | undefined;
730
+ /**
731
+ * Calculates quartiles (Q1, Q2/median, Q3) of an array
732
+ * @param array - Array of numbers
733
+ * @returns Object with q1, q2 (median), q3, and iqr (interquartile range)
734
+ * @example
735
+ * quartiles([1, 2, 3, 4, 5]) // { q1: 1.5, q2: 3, q3: 4.5, iqr: 3 }
736
+ */
737
+ export declare function quartiles(array: number[]): {
738
+ q1: number;
739
+ q2: number;
740
+ q3: number;
741
+ iqr: number;
742
+ } | undefined;
743
+ /**
744
+ * Calculates standard deviation of numeric array
745
+ * @param array - Array of numbers
746
+ * @param sample - If true, calculates sample standard deviation (default: false for population)
747
+ * @returns Standard deviation, or undefined if array is empty
748
+ * @example
749
+ * standardDeviation([2, 4, 4, 4, 5, 5, 7, 9]) // 2
750
+ */
751
+ export declare function standardDeviation(array: number[], sample?: boolean): number | undefined;
752
+ /**
753
+ * Calculates variance of numeric array
754
+ * @param array - Array of numbers
755
+ * @param sample - If true, calculates sample variance (default: false for population)
756
+ * @returns Variance, or undefined if array is empty
757
+ * @example
758
+ * variance([2, 4, 4, 4, 5, 5, 7, 9]) // 4
759
+ */
760
+ export declare function variance(array: number[], sample?: boolean): number | undefined;
761
+ /**
762
+ * Normalizes array values to 0-1 range (min-max normalization)
763
+ * @param array - Array of numbers
764
+ * @returns Normalized array
765
+ * @example
766
+ * normalize([1, 2, 3, 4, 5]) // [0, 0.25, 0.5, 0.75, 1]
767
+ */
768
+ export declare function normalize(array: number[]): number[];
769
+ /**
770
+ * Standardizes array values (z-score normalization)
771
+ * @param array - Array of numbers
772
+ * @returns Standardized array with mean 0 and standard deviation 1
773
+ * @example
774
+ * standardize([2, 4, 4, 4, 5, 5, 7, 9]) // [-1.5, -0.5, -0.5, -0.5, 0, 0, 1, 2]
775
+ */
776
+ export declare function standardize(array: number[]): number[];
777
+ /**
778
+ * Applies a function cumulatively to array elements (like reduce but returns all intermediate results)
779
+ * @param array - Source array
780
+ * @param fn - Accumulator function
781
+ * @param initial - Initial value
782
+ * @returns Array of cumulative results
783
+ * @example
784
+ * scan([1, 2, 3, 4], (acc, x) => acc + x, 0) // [1, 3, 6, 10]
785
+ */
786
+ export declare function scan<T, R>(array: T[], fn: (accumulator: R, current: T, index: number) => R, initial: R): R[];
787
+ /**
788
+ * Creates cumulative sum array
789
+ * @param array - Array of numbers
790
+ * @returns Array of cumulative sums
791
+ * @example
792
+ * cumulativeSum([1, 2, 3, 4]) // [1, 3, 6, 10]
793
+ */
794
+ export declare function cumulativeSum(array: number[]): number[];
795
+ /**
796
+ * Creates array of differences between consecutive elements
797
+ * @param array - Array of numbers
798
+ * @returns Array of differences
799
+ * @example
800
+ * diff([1, 3, 6, 10]) // [2, 3, 4]
801
+ */
802
+ export declare function diff(array: number[]): number[];
803
+ /**
804
+ * Pads array to specified length with a value
805
+ * @param array - Source array
806
+ * @param length - Target length
807
+ * @param value - Value to pad with
808
+ * @param position - Where to add padding: 'start' or 'end' (default: 'end')
809
+ * @returns Padded array
810
+ * @example
811
+ * pad([1, 2, 3], 5, 0) // [1, 2, 3, 0, 0]
812
+ * pad([1, 2, 3], 5, 0, 'start') // [0, 0, 1, 2, 3]
813
+ */
814
+ export declare function pad<T>(array: T[], length: number, value: T, position?: 'start' | 'end'): T[];
815
+ /**
816
+ * Trims array to remove elements from start and end that match predicate
817
+ * @param array - Source array
818
+ * @param predicate - Function to test elements to trim
819
+ * @returns Trimmed array
820
+ * @example
821
+ * trim([0, 0, 1, 2, 3, 0, 0], x => x === 0) // [1, 2, 3]
822
+ */
823
+ export declare function trim<T>(array: T[], predicate: (item: T) => boolean): T[];
824
+ /**
825
+ * Creates pairs of adjacent elements
826
+ * @param array - Source array
827
+ * @returns Array of pairs
828
+ * @example
829
+ * pairwise([1, 2, 3, 4]) // [[1, 2], [2, 3], [3, 4]]
830
+ */
831
+ export declare function pairwise<T>(array: T[]): [T, T][];
832
+ /**
833
+ * Creates array of index-value pairs
834
+ * @param array - Source array
835
+ * @returns Array of [index, value] tuples
836
+ * @example
837
+ * enumerate(['a', 'b', 'c']) // [[0, 'a'], [1, 'b'], [2, 'c']]
838
+ */
839
+ export declare function enumerate<T>(array: T[]): [number, T][];
840
+ /**
841
+ * Applies different functions to array elements based on their index
842
+ * @param array - Source array
843
+ * @param functions - Array of functions to apply
844
+ * @returns Array with functions applied
845
+ * @example
846
+ * applyByIndex([1, 2, 3], [x => x * 2, x => x + 10, x => x ** 2]) // [2, 12, 9]
847
+ */
848
+ export declare function applyByIndex<T, R>(array: T[], functions: Array<(item: T) => R>): R[];
849
+ /**
850
+ * Rotates elements to left by n positions
851
+ * @param array - Source array
852
+ * @param n - Number of positions to rotate (default: 1)
853
+ * @returns Rotated array
854
+ * @example
855
+ * rotateLeft([1, 2, 3, 4, 5], 2) // [3, 4, 5, 1, 2]
856
+ */
857
+ export declare function rotateLeft<T>(array: T[], n?: number): T[];
858
+ /**
859
+ * Rotates elements to right by n positions
860
+ * @param array - Source array
861
+ * @param n - Number of positions to rotate (default: 1)
862
+ * @returns Rotated array
863
+ * @example
864
+ * rotateRight([1, 2, 3, 4, 5], 2) // [4, 5, 1, 2, 3]
865
+ */
866
+ export declare function rotateRight<T>(array: T[], n?: number): T[];
867
+ /**
868
+ * Swaps two elements in array by their indices
869
+ * @param array - Source array
870
+ * @param i - First index
871
+ * @param j - Second index
872
+ * @returns New array with swapped elements
873
+ * @example
874
+ * swap([1, 2, 3, 4], 0, 3) // [4, 2, 3, 1]
875
+ */
876
+ export declare function swap<T>(array: T[], i: number, j: number): T[];
877
+ /**
878
+ * Reverses array segments between specified indices
879
+ * @param array - Source array
880
+ * @param start - Start index (inclusive)
881
+ * @param end - End index (inclusive)
882
+ * @returns Array with reversed segment
883
+ * @example
884
+ * reverseSegment([1, 2, 3, 4, 5], 1, 3) // [1, 4, 3, 2, 5]
885
+ */
886
+ export declare function reverseSegment<T>(array: T[], start: number, end: number): T[];
887
+ /**
888
+ * Checks if array is sorted in ascending order
889
+ * @param array - Array to check
890
+ * @param compareFn - Optional comparison function
891
+ * @returns True if array is sorted
892
+ * @example
893
+ * isSorted([1, 2, 3, 4]) // true
894
+ * isSorted([1, 3, 2, 4]) // false
895
+ */
896
+ export declare function isSorted<T>(array: T[], compareFn?: (a: T, b: T) => number): boolean;
897
+ /**
898
+ * Checks if array contains duplicates
899
+ * @param array - Array to check
900
+ * @returns True if array has duplicates
901
+ * @example
902
+ * hasDuplicates([1, 2, 3]) // false
903
+ * hasDuplicates([1, 2, 2, 3]) // true
904
+ */
905
+ export declare function hasDuplicates<T>(array: T[]): boolean;
906
+ /**
907
+ * Extracts values from array of objects by multiple keys
908
+ * @param array - Array of objects
909
+ * @param keys - Keys to extract
910
+ * @returns Array of objects with only specified keys
911
+ * @example
912
+ * pickMany([{a: 1, b: 2, c: 3}], ['a', 'c']) // [{a: 1, c: 3}]
913
+ */
914
+ export declare function pickMany<T extends AnyObject, K extends keyof T>(array: T[], keys: K[]): Pick<T, K>[];
915
+ /**
916
+ * Maps array to object using key and value selectors
917
+ * @param array - Source array
918
+ * @param keySelector - Function to extract key
919
+ * @param valueSelector - Function to extract value (optional, defaults to identity)
920
+ * @returns Object with mapped keys and values
921
+ * @example
922
+ * toObject([{id: 1, name: 'A'}], x => x.id, x => x.name) // {1: 'A'}
923
+ */
924
+ export declare function toObject<T, K extends string | number | symbol, V>(array: T[], keySelector: (item: T, index: number) => K, valueSelector?: (item: T, index: number) => V): Record<K, V>;
925
+ /**
926
+ * Maps array elements asynchronously in sequence
927
+ * @param array - Source array
928
+ * @param fn - Async mapping function
929
+ * @returns Promise resolving to mapped array
930
+ * @example
931
+ * await mapAsync([1, 2, 3], async x => await fetchData(x))
932
+ */
933
+ export declare function mapAsync<T, R>(array: T[], fn: (item: T, index: number) => Promise<R>): Promise<R[]>;
934
+ /**
935
+ * Maps array elements asynchronously in parallel
936
+ * @param array - Source array
937
+ * @param fn - Async mapping function
938
+ * @returns Promise resolving to mapped array
939
+ * @example
940
+ * await mapAsyncParallel([1, 2, 3], async x => await fetchData(x))
941
+ */
942
+ export declare function mapAsyncParallel<T, R>(array: T[], fn: (item: T, index: number) => Promise<R>): Promise<R[]>;
943
+ /**
944
+ * Filters array elements asynchronously
945
+ * @param array - Source array
946
+ * @param predicate - Async predicate function
947
+ * @returns Promise resolving to filtered array
948
+ * @example
949
+ * await filterAsync([1, 2, 3], async x => await isValid(x))
950
+ */
951
+ export declare function filterAsync<T>(array: T[], predicate: (item: T, index: number) => Promise<boolean>): Promise<T[]>;
952
+ /**
953
+ * Reduces array asynchronously
954
+ * @param array - Source array
955
+ * @param fn - Async reducer function
956
+ * @param initial - Initial accumulator value
957
+ * @returns Promise resolving to final accumulator value
958
+ * @example
959
+ * await reduceAsync([1, 2, 3], async (acc, x) => acc + await process(x), 0)
960
+ */
961
+ export declare function reduceAsync<T, R>(array: T[], fn: (accumulator: R, current: T, index: number) => Promise<R>, initial: R): Promise<R>;
962
+ /**
963
+ * Finds first element that satisfies async predicate
964
+ * @param array - Source array
965
+ * @param predicate - Async predicate function
966
+ * @returns Promise resolving to found element or undefined
967
+ * @example
968
+ * await findAsync([1, 2, 3], async x => await isValid(x))
969
+ */
970
+ export declare function findAsync<T>(array: T[], predicate: (item: T, index: number) => Promise<boolean>): Promise<T | undefined>;
971
+ /**
972
+ * Checks if some element satisfies async predicate
973
+ * @param array - Source array
974
+ * @param predicate - Async predicate function
975
+ * @returns Promise resolving to true if any element matches
976
+ * @example
977
+ * await someAsync([1, 2, 3], async x => await isValid(x))
978
+ */
979
+ export declare function someAsync<T>(array: T[], predicate: (item: T, index: number) => Promise<boolean>): Promise<boolean>;
980
+ /**
981
+ * Checks if every element satisfies async predicate
982
+ * @param array - Source array
983
+ * @param predicate - Async predicate function
984
+ * @returns Promise resolving to true if all elements match
985
+ * @example
986
+ * await everyAsync([1, 2, 3], async x => await isValid(x))
987
+ */
988
+ export declare function everyAsync<T>(array: T[], predicate: (item: T, index: number) => Promise<boolean>): Promise<boolean>;
989
+ /**
990
+ * Calculates weighted average from array of {value, weight} objects or using selectors
991
+ * @param array - Source array
992
+ * @param valueSelector - Function to extract value
993
+ * @param weightSelector - Function to extract weight
994
+ * @returns Weighted average, or 0 if total weight is 0
995
+ * @example
996
+ * weightedAverage([{score: 80, credits: 3}, {score: 90, credits: 2}], x => x.score, x => x.credits) // 84
997
+ */
998
+ export declare function weightedAverage<T>(array: T[], valueSelector: string | ((item: T) => number), weightSelector: string | ((item: T) => number)): number;
999
+ /**
1000
+ * Randomly selects elements with weights
1001
+ * @param array - Source array
1002
+ * @param weightSelector - Function to extract weight
1003
+ * @param count - Number of elements to select (default: 1)
1004
+ * @returns Array of selected elements
1005
+ * @example
1006
+ * weightedSample([{item: 'A', prob: 0.7}, {item: 'B', prob: 0.3}], x => x.prob, 10)
1007
+ */
1008
+ export declare function weightedSample<T>(array: T[], weightSelector: string | ((item: T) => number), count?: number): T[];
1009
+ /**
1010
+ * Splits array into segments of varying sizes
1011
+ * @param array - Source array
1012
+ * @param sizes - Array of segment sizes
1013
+ * @returns Array of segments
1014
+ * @example
1015
+ * segment([1, 2, 3, 4, 5, 6], [2, 3, 1]) // [[1, 2], [3, 4, 5], [6]]
1016
+ */
1017
+ export declare function segment<T>(array: T[], sizes: number[]): T[][];
1018
+ /**
1019
+ * Creates array with elements that appear in first array specified number of times
1020
+ * @param array - Source array
1021
+ * @param count - Required occurrence count
1022
+ * @returns Array with elements appearing exactly count times
1023
+ * @example
1024
+ * selectByCount([1, 1, 2, 2, 2, 3], 2) // [1, 1, 2, 2]
1025
+ */
1026
+ export declare function selectByCount<T>(array: T[], count: number): T[];
1027
+ /**
1028
+ * Filters array to keep only elements that pass predicate n consecutive times
1029
+ * @param array - Source array
1030
+ * @param n - Number of consecutive passes required
1031
+ * @param predicate - Predicate function
1032
+ * @returns Filtered array
1033
+ * @example
1034
+ * filterConsecutive([1, 2, 2, 3, 3, 3], 2, x => x > 1) // [2, 2, 3, 3, 3]
1035
+ */
1036
+ export declare function filterConsecutive<T>(array: T[], n: number, predicate: (item: T) => boolean): T[];
1037
+ /**
1038
+ * Maps each element using accumulated context from previous elements
1039
+ * @param array - Source array
1040
+ * @param fn - Mapping function that receives accumulated context
1041
+ * @param initialContext - Initial context value
1042
+ * @returns Array of mapped values
1043
+ * @example
1044
+ * mapWithContext([1, 2, 3], (x, ctx) => ({value: x + ctx, newCtx: ctx + x}), 0)
1045
+ * // [{value: 1, newCtx: 1}, {value: 3, newCtx: 3}, {value: 6, newCtx: 6}]
1046
+ */
1047
+ export declare function mapWithContext<T, R, C>(array: T[], fn: (item: T, context: C, index: number) => {
1048
+ value: R;
1049
+ newContext: C;
1050
+ }, initialContext: C): R[];
1051
+ /**
1052
+ * Groups array elements into fixed-size batches, with last batch potentially smaller
1053
+ * Similar to chunk but with better naming for batch processing scenarios
1054
+ * @param array - Source array
1055
+ * @param batchSize - Size of each batch
1056
+ * @returns Array of batches
1057
+ * @example
1058
+ * batch([1, 2, 3, 4, 5], 2) // [[1, 2], [3, 4], [5]]
1059
+ */
1060
+ export declare function batch<T>(array: T[], batchSize: number): T[][];
1061
+ /**
1062
+ * Applies a function to pairs of elements from two arrays
1063
+ * @param array1 - First array
1064
+ * @param array2 - Second array
1065
+ * @param fn - Function to combine elements
1066
+ * @returns Array of combined results
1067
+ * @example
1068
+ * zipWith([1, 2, 3], [4, 5, 6], (a, b) => a + b) // [5, 7, 9]
1069
+ */
1070
+ export declare function zipWith<T1, T2, R>(array1: T1[], array2: T2[], fn: (a: T1, b: T2) => R): R[];
1071
+ /**
1072
+ * Merges multiple arrays of objects by a key, with custom merge strategy
1073
+ * @param arrays - Arrays to merge
1074
+ * @param key - Key to merge by
1075
+ * @param mergeStrategy - How to merge: 'first', 'last', 'concat', or custom function
1076
+ * @returns Merged array
1077
+ * @example
1078
+ * mergeArraysByKey(
1079
+ * [[{id: 1, a: 1}], [{id: 1, b: 2}]],
1080
+ * 'id',
1081
+ * (existing, incoming) => ({...existing, ...incoming})
1082
+ * )
1083
+ */
1084
+ export declare function mergeArraysByKey<T extends AnyObject>(arrays: T[][], key: string, mergeStrategy?: 'first' | 'last' | 'concat' | ((existing: T, incoming: T) => T)): T[];
1085
+ /**
1086
+ * Creates a lookup/index object for fast access by key
1087
+ * @param array - Array of objects
1088
+ * @param key - Key to index by
1089
+ * @returns Object mapping key values to array elements
1090
+ * @example
1091
+ * indexBy([{id: 1, name: 'A'}, {id: 2, name: 'B'}], 'id')
1092
+ * // {1: {id: 1, name: 'A'}, 2: {id: 2, name: 'B'}}
1093
+ */
1094
+ export declare function indexBy<T extends AnyObject>(array: T[], key: string): Record<string, T>;
1095
+ /**
1096
+ * Performs binary search on sorted array
1097
+ * @param array - Sorted array
1098
+ * @param target - Value to search for
1099
+ * @param compareFn - Optional comparison function
1100
+ * @returns Index of target, or -1 if not found
1101
+ * @example
1102
+ * binarySearch([1, 2, 3, 4, 5], 3) // 2
1103
+ * binarySearch([1, 2, 4, 5], 3) // -1
1104
+ */
1105
+ export declare function binarySearch<T>(array: T[], target: T, compareFn?: (a: T, b: T) => number): number;
1106
+ /**
1107
+ * Inserts value into sorted array maintaining sort order
1108
+ * @param array - Sorted array
1109
+ * @param value - Value to insert
1110
+ * @param compareFn - Optional comparison function
1111
+ * @returns New sorted array with value inserted
1112
+ * @example
1113
+ * insertSorted([1, 3, 5, 7], 4) // [1, 3, 4, 5, 7]
1114
+ */
1115
+ export declare function insertSorted<T>(array: T[], value: T, compareFn?: (a: T, b: T) => number): T[];
1116
+ //# sourceMappingURL=advanced.d.ts.map