@pawells/typescript-common 2.0.0 → 2.1.6

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 (426) hide show
  1. package/README.md +370 -223
  2. package/{build → dist}/array/array-chunk.d.ts +1 -1
  3. package/{build → dist}/array/array-chunk.js +2 -3
  4. package/{build → dist}/array/array-compact.d.ts +1 -1
  5. package/{build → dist}/array/array-compact.js +1 -2
  6. package/{build → dist}/array/array-contains.d.ts +1 -1
  7. package/{build → dist}/array/array-contains.js +2 -3
  8. package/{build → dist}/array/array-count-by.d.ts +1 -1
  9. package/{build → dist}/array/array-count-by.js +2 -3
  10. package/{build → dist}/array/array-difference.d.ts +12 -5
  11. package/dist/array/array-difference.d.ts.map +1 -0
  12. package/dist/array/array-difference.js +70 -0
  13. package/dist/array/array-element.js +1 -0
  14. package/{build → dist}/array/array-filter.d.ts +1 -1
  15. package/{build → dist}/array/array-filter.js +1 -2
  16. package/{build → dist}/array/array-flatten.d.ts +2 -2
  17. package/{build → dist}/array/array-flatten.d.ts.map +1 -1
  18. package/{build → dist}/array/array-flatten.js +1 -2
  19. package/{build → dist}/array/array-group-by.d.ts +1 -1
  20. package/{build → dist}/array/array-group-by.d.ts.map +1 -1
  21. package/{build → dist}/array/array-group-by.js +10 -9
  22. package/{build → dist}/array/array-intersection.d.ts +12 -5
  23. package/dist/array/array-intersection.d.ts.map +1 -0
  24. package/dist/array/array-intersection.js +79 -0
  25. package/{build → dist}/array/array-partition.d.ts +1 -1
  26. package/{build → dist}/array/array-partition.js +2 -3
  27. package/{build → dist}/array/array-range.d.ts +1 -1
  28. package/{build → dist}/array/array-range.js +1 -2
  29. package/{build → dist}/array/array-sample.d.ts +2 -2
  30. package/{build → dist}/array/array-sample.js +3 -5
  31. package/{build → dist}/array/array-shuffle.d.ts +1 -1
  32. package/{build → dist}/array/array-shuffle.js +1 -2
  33. package/{build → dist}/array/array-sort-by.d.ts +1 -1
  34. package/{build → dist}/array/array-sort-by.js +1 -2
  35. package/{build → dist}/array/array-zip.d.ts +1 -1
  36. package/{build → dist}/array/array-zip.js +1 -2
  37. package/{build → dist}/array/assert.d.ts +5 -5
  38. package/{build → dist}/array/assert.d.ts.map +1 -1
  39. package/{build → dist}/array/assert.js +13 -14
  40. package/{build → dist}/array/index.d.ts +1 -0
  41. package/{build → dist}/array/index.d.ts.map +1 -1
  42. package/{build → dist}/array/index.js +1 -1
  43. package/dist/array/iterators.d.ts +40 -0
  44. package/dist/array/iterators.d.ts.map +1 -0
  45. package/dist/array/iterators.js +54 -0
  46. package/{build → dist}/array/types.d.ts +20 -2
  47. package/{build → dist}/array/types.d.ts.map +1 -1
  48. package/dist/array/types.js +1 -0
  49. package/{build → dist}/array/unique.d.ts +1 -1
  50. package/{build → dist}/array/unique.js +1 -2
  51. package/dist/asserts/errors.d.ts.map +1 -0
  52. package/{build → dist}/asserts/errors.js +5 -3
  53. package/{build → dist}/asserts/generic.d.ts +23 -3
  54. package/dist/asserts/generic.d.ts.map +1 -0
  55. package/{build → dist}/asserts/generic.js +39 -7
  56. package/dist/asserts/index.d.ts +47 -0
  57. package/dist/asserts/index.d.ts.map +1 -0
  58. package/dist/asserts/index.js +46 -0
  59. package/{build → dist}/asserts/internal-utils.d.ts.map +1 -1
  60. package/{build → dist}/asserts/internal-utils.js +0 -1
  61. package/{build → dist}/asserts/types.d.ts +56 -17
  62. package/dist/asserts/types.d.ts.map +1 -0
  63. package/dist/asserts/types.js +1 -0
  64. package/{build → dist}/asserts/utils.d.ts +5 -21
  65. package/dist/asserts/utils.d.ts.map +1 -0
  66. package/{build → dist}/asserts/utils.js +14 -39
  67. package/{build → dist}/boolean/assert.d.ts +1 -2
  68. package/{build → dist}/boolean/assert.d.ts.map +1 -1
  69. package/{build → dist}/boolean/assert.js +1 -3
  70. package/dist/boolean/index.d.ts +13 -0
  71. package/dist/boolean/index.d.ts.map +1 -0
  72. package/dist/boolean/index.js +12 -0
  73. package/{build → dist}/enum/enum-entries.d.ts +1 -1
  74. package/dist/enum/enum-entries.d.ts.map +1 -0
  75. package/{build → dist}/enum/enum-entries.js +0 -1
  76. package/{build → dist}/enum/enum-key-by-value.d.ts +1 -1
  77. package/dist/enum/enum-key-by-value.d.ts.map +1 -0
  78. package/{build → dist}/enum/enum-key-by-value.js +0 -1
  79. package/{build → dist}/enum/enum-keys.js +0 -1
  80. package/{build → dist}/enum/enum-safe-value.d.ts +1 -1
  81. package/dist/enum/enum-safe-value.d.ts.map +1 -0
  82. package/{build → dist}/enum/enum-safe-value.js +0 -1
  83. package/{build → dist}/enum/enum-values.js +0 -1
  84. package/{build → dist}/enum/index.d.ts +1 -1
  85. package/dist/enum/index.d.ts.map +1 -0
  86. package/{build → dist}/enum/index.js +1 -2
  87. package/dist/enum/types.js +1 -0
  88. package/{build → dist}/enum/validate-enum-value.d.ts +1 -1
  89. package/dist/enum/validate-enum-value.d.ts.map +1 -0
  90. package/{build → dist}/enum/validate-enum-value.js +0 -1
  91. package/{build → dist}/function/compose.d.ts +6 -0
  92. package/dist/function/compose.d.ts.map +1 -0
  93. package/{build → dist}/function/compose.js +0 -1
  94. package/{build → dist}/function/debounce.d.ts +6 -0
  95. package/dist/function/debounce.d.ts.map +1 -0
  96. package/{build → dist}/function/debounce.js +6 -1
  97. package/{build → dist}/function/index.js +0 -1
  98. package/dist/function/memoize.d.ts +56 -0
  99. package/dist/function/memoize.d.ts.map +1 -0
  100. package/dist/function/memoize.js +72 -0
  101. package/{build → dist}/function/once.d.ts.map +1 -1
  102. package/{build → dist}/function/once.js +1 -1
  103. package/{build → dist}/function/sleep.js +0 -1
  104. package/{build → dist}/function/throttle.d.ts +7 -0
  105. package/dist/function/throttle.d.ts.map +1 -0
  106. package/{build → dist}/function/throttle.js +7 -1
  107. package/dist/function/types.d.ts +18 -0
  108. package/dist/function/types.d.ts.map +1 -0
  109. package/dist/function/types.js +1 -0
  110. package/dist/index.d.ts +14 -0
  111. package/dist/index.d.ts.map +1 -0
  112. package/dist/index.js +13 -0
  113. package/dist/json.sanitization.d.ts +14 -0
  114. package/dist/json.sanitization.d.ts.map +1 -0
  115. package/dist/json.sanitization.js +37 -0
  116. package/{build → dist}/lru-cache.d.ts +19 -0
  117. package/dist/lru-cache.d.ts.map +1 -0
  118. package/{build → dist}/lru-cache.js +24 -2
  119. package/{build → dist}/number/assert.js +0 -1
  120. package/dist/number/index.d.ts +13 -0
  121. package/dist/number/index.d.ts.map +1 -0
  122. package/dist/number/index.js +12 -0
  123. package/{build → dist}/object/assert-object.d.ts +5 -1
  124. package/{build → dist}/object/assert-object.d.ts.map +1 -1
  125. package/{build → dist}/object/assert-object.js +4 -1
  126. package/{build → dist}/object/assert.d.ts +1 -1
  127. package/dist/object/assert.d.ts.map +1 -0
  128. package/{build → dist}/object/assert.js +7 -29
  129. package/{build → dist}/object/clone.d.ts +6 -0
  130. package/dist/object/clone.d.ts.map +1 -0
  131. package/{build → dist}/object/clone.js +14 -5
  132. package/{build → dist}/object/equals.d.ts.map +1 -1
  133. package/{build → dist}/object/equals.js +3 -7
  134. package/dist/object/filter-cached.d.ts +26 -0
  135. package/{build → dist}/object/filter-cached.d.ts.map +1 -1
  136. package/{build → dist}/object/filter-cached.js +27 -6
  137. package/{build → dist}/object/filter.d.ts.map +1 -1
  138. package/{build → dist}/object/filter.js +22 -6
  139. package/{build → dist}/object/has-circular-reference.d.ts.map +1 -1
  140. package/{build → dist}/object/has-circular-reference.js +4 -2
  141. package/{build → dist}/object/hash.d.ts +4 -0
  142. package/dist/object/hash.d.ts.map +1 -0
  143. package/{build → dist}/object/hash.js +20 -7
  144. package/{build → dist}/object/index.d.ts +2 -2
  145. package/{build → dist}/object/index.d.ts.map +1 -1
  146. package/{build → dist}/object/index.js +1 -2
  147. package/{build → dist}/object/json-circular-replacer.d.ts.map +1 -1
  148. package/{build → dist}/object/json-circular-replacer.js +0 -1
  149. package/{build → dist}/object/key-value-pairs.js +0 -1
  150. package/dist/object/map-cached.d.ts +31 -0
  151. package/dist/object/map-cached.d.ts.map +1 -0
  152. package/{build → dist}/object/map-cached.js +34 -6
  153. package/{build → dist}/object/map.js +0 -1
  154. package/{build → dist}/object/merge.d.ts.map +1 -1
  155. package/{build → dist}/object/merge.js +7 -7
  156. package/{build → dist}/object/object-diff.d.ts +2 -2
  157. package/{build → dist}/object/object-diff.d.ts.map +1 -1
  158. package/{build → dist}/object/object-diff.js +11 -5
  159. package/{build → dist}/object/object-flatten.d.ts +1 -1
  160. package/{build → dist}/object/object-flatten.d.ts.map +1 -1
  161. package/{build → dist}/object/object-flatten.js +10 -4
  162. package/{build → dist}/object/object-invert.js +0 -1
  163. package/{build → dist}/object/omit.js +0 -1
  164. package/{build → dist}/object/pick.js +0 -1
  165. package/{build → dist}/object/property-paths.d.ts +2 -0
  166. package/{build → dist}/object/property-paths.d.ts.map +1 -1
  167. package/{build → dist}/object/property-paths.js +8 -7
  168. package/dist/object/security-utils.d.ts +193 -0
  169. package/dist/object/security-utils.d.ts.map +1 -0
  170. package/dist/object/security-utils.js +304 -0
  171. package/{build → dist}/object/sort-keys.d.ts +15 -1
  172. package/dist/object/sort-keys.d.ts.map +1 -0
  173. package/dist/object/sort-keys.js +73 -0
  174. package/{build → dist}/object/types.d.ts +0 -61
  175. package/dist/object/types.d.ts.map +1 -0
  176. package/dist/object/types.js +1 -0
  177. package/{build → dist}/string/assert.d.ts +24 -0
  178. package/dist/string/assert.d.ts.map +1 -0
  179. package/{build → dist}/string/assert.js +30 -1
  180. package/{build → dist}/string/case-conversion.js +0 -1
  181. package/{build → dist}/string/comparison.d.ts.map +1 -1
  182. package/{build → dist}/string/comparison.js +3 -1
  183. package/{build → dist}/string/formatting.d.ts.map +1 -1
  184. package/{build → dist}/string/formatting.js +5 -3
  185. package/{build → dist}/string/index.js +0 -1
  186. package/{build → dist}/string/transformation.js +0 -1
  187. package/dist/string/types.d.ts +118 -0
  188. package/dist/string/types.d.ts.map +1 -0
  189. package/dist/string/types.js +1 -0
  190. package/{build → dist}/string/validation.js +0 -1
  191. package/dist/time/elapsed-time/constants.d.ts +36 -0
  192. package/{build → dist}/time/elapsed-time/constants.d.ts.map +1 -1
  193. package/{build → dist}/time/elapsed-time/constants.js +32 -3
  194. package/{build → dist}/time/elapsed-time/elapsed-time.d.ts +74 -22
  195. package/dist/time/elapsed-time/elapsed-time.d.ts.map +1 -0
  196. package/{build → dist}/time/elapsed-time/elapsed-time.js +183 -89
  197. package/dist/time/elapsed-time/types.d.ts +336 -0
  198. package/dist/time/elapsed-time/types.d.ts.map +1 -0
  199. package/dist/time/elapsed-time/types.js +1 -0
  200. package/{build → dist}/time/elapsed-time/utils.d.ts +1 -1
  201. package/dist/time/elapsed-time/utils.d.ts.map +1 -0
  202. package/{build → dist}/time/elapsed-time/utils.js +0 -1
  203. package/dist/time/index.d.ts +14 -0
  204. package/dist/time/index.d.ts.map +1 -0
  205. package/{build → dist}/time/index.js +0 -5
  206. package/{build → dist}/time/stopwatch/entry.d.ts +1 -1
  207. package/dist/time/stopwatch/entry.d.ts.map +1 -0
  208. package/{build → dist}/time/stopwatch/entry.js +0 -1
  209. package/{build → dist}/time/stopwatch/stopwatch.d.ts +27 -3
  210. package/dist/time/stopwatch/stopwatch.d.ts.map +1 -0
  211. package/{build → dist}/time/stopwatch/stopwatch.js +32 -4
  212. package/dist/zod-util.d.ts +145 -0
  213. package/dist/zod-util.d.ts.map +1 -0
  214. package/dist/zod-util.js +126 -0
  215. package/package.json +51 -67
  216. package/LICENSE +0 -21
  217. package/build/array/array-chunk.js.map +0 -1
  218. package/build/array/array-compact.js.map +0 -1
  219. package/build/array/array-contains.js.map +0 -1
  220. package/build/array/array-count-by.js.map +0 -1
  221. package/build/array/array-difference.d.ts.map +0 -1
  222. package/build/array/array-difference.js +0 -51
  223. package/build/array/array-difference.js.map +0 -1
  224. package/build/array/array-element.js +0 -2
  225. package/build/array/array-element.js.map +0 -1
  226. package/build/array/array-filter.js.map +0 -1
  227. package/build/array/array-flatten.js.map +0 -1
  228. package/build/array/array-group-by.js.map +0 -1
  229. package/build/array/array-intersection.d.ts.map +0 -1
  230. package/build/array/array-intersection.js +0 -57
  231. package/build/array/array-intersection.js.map +0 -1
  232. package/build/array/array-partition.js.map +0 -1
  233. package/build/array/array-range.js.map +0 -1
  234. package/build/array/array-sample.js.map +0 -1
  235. package/build/array/array-shuffle.js.map +0 -1
  236. package/build/array/array-sort-by.js.map +0 -1
  237. package/build/array/array-zip.js.map +0 -1
  238. package/build/array/assert.js.map +0 -1
  239. package/build/array/index.js.map +0 -1
  240. package/build/array/types.js +0 -2
  241. package/build/array/types.js.map +0 -1
  242. package/build/array/unique.js.map +0 -1
  243. package/build/asserts/errors.d.ts.map +0 -1
  244. package/build/asserts/errors.js.map +0 -1
  245. package/build/asserts/generic.d.ts.map +0 -1
  246. package/build/asserts/generic.js.map +0 -1
  247. package/build/asserts/index.d.ts +0 -41
  248. package/build/asserts/index.d.ts.map +0 -1
  249. package/build/asserts/index.js +0 -41
  250. package/build/asserts/index.js.map +0 -1
  251. package/build/asserts/internal-utils.js.map +0 -1
  252. package/build/asserts/types.d.ts.map +0 -1
  253. package/build/asserts/types.js +0 -2
  254. package/build/asserts/types.js.map +0 -1
  255. package/build/asserts/utils.d.ts.map +0 -1
  256. package/build/asserts/utils.js.map +0 -1
  257. package/build/boolean/assert.js.map +0 -1
  258. package/build/boolean/index.d.ts +0 -9
  259. package/build/boolean/index.d.ts.map +0 -1
  260. package/build/boolean/index.js +0 -9
  261. package/build/boolean/index.js.map +0 -1
  262. package/build/enum/enum-entries.d.ts.map +0 -1
  263. package/build/enum/enum-entries.js.map +0 -1
  264. package/build/enum/enum-key-by-value.d.ts.map +0 -1
  265. package/build/enum/enum-key-by-value.js.map +0 -1
  266. package/build/enum/enum-keys.js.map +0 -1
  267. package/build/enum/enum-safe-value.d.ts.map +0 -1
  268. package/build/enum/enum-safe-value.js.map +0 -1
  269. package/build/enum/enum-values.js.map +0 -1
  270. package/build/enum/index.d.ts.map +0 -1
  271. package/build/enum/index.js.map +0 -1
  272. package/build/enum/types.js +0 -2
  273. package/build/enum/types.js.map +0 -1
  274. package/build/enum/validate-enum-value.d.ts.map +0 -1
  275. package/build/enum/validate-enum-value.js.map +0 -1
  276. package/build/function/compose.d.ts.map +0 -1
  277. package/build/function/compose.js.map +0 -1
  278. package/build/function/debounce.d.ts.map +0 -1
  279. package/build/function/debounce.js.map +0 -1
  280. package/build/function/index.js.map +0 -1
  281. package/build/function/memoize.d.ts +0 -30
  282. package/build/function/memoize.d.ts.map +0 -1
  283. package/build/function/memoize.js +0 -44
  284. package/build/function/memoize.js.map +0 -1
  285. package/build/function/once.js.map +0 -1
  286. package/build/function/sleep.js.map +0 -1
  287. package/build/function/throttle.d.ts.map +0 -1
  288. package/build/function/throttle.js.map +0 -1
  289. package/build/function/types.d.ts +0 -5
  290. package/build/function/types.d.ts.map +0 -1
  291. package/build/function/types.js +0 -2
  292. package/build/function/types.js.map +0 -1
  293. package/build/index.d.ts +0 -38
  294. package/build/index.d.ts.map +0 -1
  295. package/build/index.js +0 -64
  296. package/build/index.js.map +0 -1
  297. package/build/lru-cache.d.ts.map +0 -1
  298. package/build/lru-cache.js.map +0 -1
  299. package/build/number/assert.js.map +0 -1
  300. package/build/number/index.d.ts +0 -9
  301. package/build/number/index.d.ts.map +0 -1
  302. package/build/number/index.js +0 -9
  303. package/build/number/index.js.map +0 -1
  304. package/build/object/assert-object.js.map +0 -1
  305. package/build/object/assert.d.ts.map +0 -1
  306. package/build/object/assert.js.map +0 -1
  307. package/build/object/clone.d.ts.map +0 -1
  308. package/build/object/clone.js.map +0 -1
  309. package/build/object/equals.js.map +0 -1
  310. package/build/object/filter-cached.d.ts +0 -21
  311. package/build/object/filter-cached.js.map +0 -1
  312. package/build/object/filter.js.map +0 -1
  313. package/build/object/has-circular-reference.js.map +0 -1
  314. package/build/object/hash.d.ts.map +0 -1
  315. package/build/object/hash.js.map +0 -1
  316. package/build/object/index.js.map +0 -1
  317. package/build/object/json-circular-replacer.js.map +0 -1
  318. package/build/object/key-value-pairs.js.map +0 -1
  319. package/build/object/map-cached.d.ts +0 -20
  320. package/build/object/map-cached.d.ts.map +0 -1
  321. package/build/object/map-cached.js.map +0 -1
  322. package/build/object/map.js.map +0 -1
  323. package/build/object/merge.js.map +0 -1
  324. package/build/object/object-diff.js.map +0 -1
  325. package/build/object/object-flatten.js.map +0 -1
  326. package/build/object/object-invert.js.map +0 -1
  327. package/build/object/omit.js.map +0 -1
  328. package/build/object/pick.js.map +0 -1
  329. package/build/object/property-paths.js.map +0 -1
  330. package/build/object/security-utils.d.ts +0 -59
  331. package/build/object/security-utils.d.ts.map +0 -1
  332. package/build/object/security-utils.js +0 -161
  333. package/build/object/security-utils.js.map +0 -1
  334. package/build/object/sort-keys.d.ts.map +0 -1
  335. package/build/object/sort-keys.js +0 -52
  336. package/build/object/sort-keys.js.map +0 -1
  337. package/build/object/types.d.ts.map +0 -1
  338. package/build/object/types.js +0 -6
  339. package/build/object/types.js.map +0 -1
  340. package/build/string/assert.d.ts.map +0 -1
  341. package/build/string/assert.js.map +0 -1
  342. package/build/string/case-conversion.js.map +0 -1
  343. package/build/string/comparison.js.map +0 -1
  344. package/build/string/formatting.js.map +0 -1
  345. package/build/string/index.js.map +0 -1
  346. package/build/string/transformation.js.map +0 -1
  347. package/build/string/types.d.ts +0 -44
  348. package/build/string/types.d.ts.map +0 -1
  349. package/build/string/types.js +0 -2
  350. package/build/string/types.js.map +0 -1
  351. package/build/string/validation.js.map +0 -1
  352. package/build/time/elapsed-time/constants.d.ts +0 -10
  353. package/build/time/elapsed-time/constants.js.map +0 -1
  354. package/build/time/elapsed-time/elapsed-time.d.ts.map +0 -1
  355. package/build/time/elapsed-time/elapsed-time.js.map +0 -1
  356. package/build/time/elapsed-time/types.d.ts +0 -150
  357. package/build/time/elapsed-time/types.d.ts.map +0 -1
  358. package/build/time/elapsed-time/types.js +0 -2
  359. package/build/time/elapsed-time/types.js.map +0 -1
  360. package/build/time/elapsed-time/utils.d.ts.map +0 -1
  361. package/build/time/elapsed-time/utils.js.map +0 -1
  362. package/build/time/index.d.ts +0 -18
  363. package/build/time/index.d.ts.map +0 -1
  364. package/build/time/index.js.map +0 -1
  365. package/build/time/stopwatch/entry-types.d.ts +0 -13
  366. package/build/time/stopwatch/entry-types.d.ts.map +0 -1
  367. package/build/time/stopwatch/entry-types.js +0 -2
  368. package/build/time/stopwatch/entry-types.js.map +0 -1
  369. package/build/time/stopwatch/entry.d.ts.map +0 -1
  370. package/build/time/stopwatch/entry.js.map +0 -1
  371. package/build/time/stopwatch/stopwatch.d.ts.map +0 -1
  372. package/build/time/stopwatch/stopwatch.js.map +0 -1
  373. /package/{build → dist}/array/array-chunk.d.ts.map +0 -0
  374. /package/{build → dist}/array/array-compact.d.ts.map +0 -0
  375. /package/{build → dist}/array/array-contains.d.ts.map +0 -0
  376. /package/{build → dist}/array/array-count-by.d.ts.map +0 -0
  377. /package/{build → dist}/array/array-element.d.ts +0 -0
  378. /package/{build → dist}/array/array-element.d.ts.map +0 -0
  379. /package/{build → dist}/array/array-filter.d.ts.map +0 -0
  380. /package/{build → dist}/array/array-partition.d.ts.map +0 -0
  381. /package/{build → dist}/array/array-range.d.ts.map +0 -0
  382. /package/{build → dist}/array/array-sample.d.ts.map +0 -0
  383. /package/{build → dist}/array/array-shuffle.d.ts.map +0 -0
  384. /package/{build → dist}/array/array-sort-by.d.ts.map +0 -0
  385. /package/{build → dist}/array/array-zip.d.ts.map +0 -0
  386. /package/{build → dist}/array/unique.d.ts.map +0 -0
  387. /package/{build → dist}/asserts/errors.d.ts +0 -0
  388. /package/{build → dist}/asserts/internal-utils.d.ts +0 -0
  389. /package/{build → dist}/enum/enum-keys.d.ts +0 -0
  390. /package/{build → dist}/enum/enum-keys.d.ts.map +0 -0
  391. /package/{build → dist}/enum/enum-values.d.ts +0 -0
  392. /package/{build → dist}/enum/enum-values.d.ts.map +0 -0
  393. /package/{build → dist}/enum/types.d.ts +0 -0
  394. /package/{build → dist}/enum/types.d.ts.map +0 -0
  395. /package/{build → dist}/function/index.d.ts +0 -0
  396. /package/{build → dist}/function/index.d.ts.map +0 -0
  397. /package/{build → dist}/function/once.d.ts +0 -0
  398. /package/{build → dist}/function/sleep.d.ts +0 -0
  399. /package/{build → dist}/function/sleep.d.ts.map +0 -0
  400. /package/{build → dist}/number/assert.d.ts +0 -0
  401. /package/{build → dist}/number/assert.d.ts.map +0 -0
  402. /package/{build → dist}/object/equals.d.ts +0 -0
  403. /package/{build → dist}/object/filter.d.ts +0 -0
  404. /package/{build → dist}/object/has-circular-reference.d.ts +0 -0
  405. /package/{build → dist}/object/json-circular-replacer.d.ts +0 -0
  406. /package/{build → dist}/object/key-value-pairs.d.ts +0 -0
  407. /package/{build → dist}/object/key-value-pairs.d.ts.map +0 -0
  408. /package/{build → dist}/object/map.d.ts +0 -0
  409. /package/{build → dist}/object/map.d.ts.map +0 -0
  410. /package/{build → dist}/object/merge.d.ts +0 -0
  411. /package/{build → dist}/object/object-invert.d.ts +0 -0
  412. /package/{build → dist}/object/object-invert.d.ts.map +0 -0
  413. /package/{build → dist}/object/omit.d.ts +0 -0
  414. /package/{build → dist}/object/omit.d.ts.map +0 -0
  415. /package/{build → dist}/object/pick.d.ts +0 -0
  416. /package/{build → dist}/object/pick.d.ts.map +0 -0
  417. /package/{build → dist}/string/case-conversion.d.ts +0 -0
  418. /package/{build → dist}/string/case-conversion.d.ts.map +0 -0
  419. /package/{build → dist}/string/comparison.d.ts +0 -0
  420. /package/{build → dist}/string/formatting.d.ts +0 -0
  421. /package/{build → dist}/string/index.d.ts +0 -0
  422. /package/{build → dist}/string/index.d.ts.map +0 -0
  423. /package/{build → dist}/string/transformation.d.ts +0 -0
  424. /package/{build → dist}/string/transformation.d.ts.map +0 -0
  425. /package/{build → dist}/string/validation.d.ts +0 -0
  426. /package/{build → dist}/string/validation.d.ts.map +0 -0
@@ -4,7 +4,7 @@
4
4
  * @template T - The type of array elements
5
5
  * @param array - The array to split
6
6
  * @param size - Size of each chunk (last chunk may be smaller)
7
- * @returns Array of arrays, each of the specified size
7
+ * @returns Array of arrays, each of the specified size. Returns `[]` if `array` is `null`, `undefined`, or `size` is not positive.
8
8
  *
9
9
  * @example
10
10
  * ```typescript
@@ -4,7 +4,7 @@
4
4
  * @template T - The type of array elements
5
5
  * @param array - The array to split
6
6
  * @param size - Size of each chunk (last chunk may be smaller)
7
- * @returns Array of arrays, each of the specified size
7
+ * @returns Array of arrays, each of the specified size. Returns `[]` if `array` is `null`, `undefined`, or `size` is not positive.
8
8
  *
9
9
  * @example
10
10
  * ```typescript
@@ -13,7 +13,7 @@
13
13
  * ```
14
14
  */
15
15
  export function ArrayChunk(array, size) {
16
- if (array === null || array === undefined || !(size > 0)) {
16
+ if (array == null || !(size > 0)) {
17
17
  return [];
18
18
  }
19
19
  const result = [];
@@ -22,4 +22,3 @@ export function ArrayChunk(array, size) {
22
22
  }
23
23
  return result;
24
24
  }
25
- //# sourceMappingURL=array-chunk.js.map
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @template T - The non-nullish element type
5
5
  * @param array - The array to compact
6
- * @returns A new array with `null`/`undefined` entries removed
6
+ * @returns A new array with `null`/`undefined` entries removed. Returns `[]` if `array` is `null` or `undefined`.
7
7
  *
8
8
  * @example
9
9
  * ```typescript
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @template T - The non-nullish element type
5
5
  * @param array - The array to compact
6
- * @returns A new array with `null`/`undefined` entries removed
6
+ * @returns A new array with `null`/`undefined` entries removed. Returns `[]` if `array` is `null` or `undefined`.
7
7
  *
8
8
  * @example
9
9
  * ```typescript
@@ -19,4 +19,3 @@ export function ArrayCompact(array) {
19
19
  return [];
20
20
  return array.filter((item) => item !== null && item !== undefined);
21
21
  }
22
- //# sourceMappingURL=array-compact.js.map
@@ -8,7 +8,7 @@ import type { TPredicate } from './types.js';
8
8
  * @template T - The type of array elements
9
9
  * @param array - The array to check
10
10
  * @param predicate - A function that tests each element; returns `true` to signal a match
11
- * @returns `true` if at least one element passes the test, `false` otherwise
11
+ * @returns `true` if at least one element passes the test, `false` if no element passes, the array is `null`, `undefined`, or empty
12
12
  *
13
13
  * @example
14
14
  * ```typescript
@@ -7,7 +7,7 @@
7
7
  * @template T - The type of array elements
8
8
  * @param array - The array to check
9
9
  * @param predicate - A function that tests each element; returns `true` to signal a match
10
- * @returns `true` if at least one element passes the test, `false` otherwise
10
+ * @returns `true` if at least one element passes the test, `false` if no element passes, the array is `null`, `undefined`, or empty
11
11
  *
12
12
  * @example
13
13
  * ```typescript
@@ -17,9 +17,8 @@
17
17
  */
18
18
  export function ArrayContains(array, predicate) {
19
19
  // Predicate functions use array.some() / array.every() for consistency
20
- if (!array || array.length === 0) {
20
+ if (array === null || array === undefined || array.length === 0) {
21
21
  return false;
22
22
  }
23
23
  return array.some(predicate);
24
24
  }
25
- //# sourceMappingURL=array-contains.js.map
@@ -8,7 +8,7 @@ import type { TTransform } from './types.js';
8
8
  * @template K - The key type (string, number, or symbol)
9
9
  * @param array - The array to count
10
10
  * @param keyFn - Function that assigns each element to a group key
11
- * @returns A record where keys are group identifiers and values are occurrence counts
11
+ * @returns A record where keys are group identifiers and values are occurrence counts. Returns `{}` if `array` is `null`, `undefined`, or an empty array.
12
12
  *
13
13
  * @example
14
14
  * ```typescript
@@ -7,7 +7,7 @@
7
7
  * @template K - The key type (string, number, or symbol)
8
8
  * @param array - The array to count
9
9
  * @param keyFn - Function that assigns each element to a group key
10
- * @returns A record where keys are group identifiers and values are occurrence counts
10
+ * @returns A record where keys are group identifiers and values are occurrence counts. Returns `{}` if `array` is `null`, `undefined`, or an empty array.
11
11
  *
12
12
  * @example
13
13
  * ```typescript
@@ -20,7 +20,7 @@
20
20
  */
21
21
  export function ArrayCountBy(array, keyFn) {
22
22
  // Consistent null-check: early return for null/undefined arrays
23
- if (!array)
23
+ if (array === null || array === undefined)
24
24
  return {};
25
25
  const result = {};
26
26
  for (const item of array) {
@@ -29,4 +29,3 @@ export function ArrayCountBy(array, keyFn) {
29
29
  }
30
30
  return result;
31
31
  }
32
- //# sourceMappingURL=array-count-by.js.map
@@ -2,15 +2,16 @@ import type { TArrayComparisonOptions } from './types.js';
2
2
  /**
3
3
  * Returns elements present in the first array but not in the second (set difference).
4
4
  * Optimised O(n+m) using a Set when no custom comparator is provided.
5
- * Supports custom comparators for advanced comparison logic, or deep equality checking.
5
+ * Supports custom comparators for advanced comparison logic, deep equality checking, or key extraction.
6
6
  *
7
7
  * @template T - The type of array elements
8
8
  * @param array1 - The source array
9
9
  * @param array2 - Elements to exclude
10
- * @param options - Optional configuration
10
+ * @param options - Optional configuration. Choose one strategy: `comparator`, `useDeepEqual`, or `keyFn`.
11
11
  * @param options.comparator - Custom function to determine if elements are equal (optional)
12
- * @param options.useDeepEqual - Use deep equality for comparison instead of custom comparator (optional)
13
- * @returns Array of elements in `array1` that are not in `array2`
12
+ * @param options.useDeepEqual - Use deep equality for comparison (optional)
13
+ * @param options.keyFn - Optional function to extract a primitive key for O(n+m) Set-based lookup. When provided, enables efficient comparison by mapping each item to a key that can be stored in a Set. Example: `{ keyFn: item => item.id }` for objects with a unique id field.
14
+ * @returns Array of elements in `array1` that are not in `array2`. Returns `[]` if `array1` is `null`, `undefined`, or an empty array.
14
15
  *
15
16
  * @example
16
17
  * ```typescript
@@ -28,9 +29,15 @@ import type { TArrayComparisonOptions } from './types.js';
28
29
  * comparator: (a, b) => a.id === b.id
29
30
  * });
30
31
  * // [{ id: 1, name: 'Alice' }]
32
+ *
33
+ * // Key function for O(n+m) lookup
34
+ * ArrayDifference(arr1, arr2, {
35
+ * keyFn: item => item.id
36
+ * });
37
+ * // [{ id: 1, name: 'Alice' }]
31
38
  * ```
32
39
  *
33
- * @complexity O(n+m) for primitive values, O(n*m) when a comparator or deep equality is provided
40
+ * @complexity O(n+m) for primitive values, O(n+m) with keyFn, O(n*m) when a comparator or deep equality is provided
34
41
  */
35
42
  export declare function ArrayDifference<T>(array1: readonly T[], array2: readonly T[], options?: TArrayComparisonOptions<T>): T[];
36
43
  //# sourceMappingURL=array-difference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array-difference.d.ts","sourceRoot":"","sources":["../../src/array/array-difference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAG1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAChC,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,OAAO,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAClC,CAAC,EAAE,CA+BL"}
@@ -0,0 +1,70 @@
1
+ import { ObjectEquals } from '../object/equals.js';
2
+ /**
3
+ * Returns elements present in the first array but not in the second (set difference).
4
+ * Optimised O(n+m) using a Set when no custom comparator is provided.
5
+ * Supports custom comparators for advanced comparison logic, deep equality checking, or key extraction.
6
+ *
7
+ * @template T - The type of array elements
8
+ * @param array1 - The source array
9
+ * @param array2 - Elements to exclude
10
+ * @param options - Optional configuration. Choose one strategy: `comparator`, `useDeepEqual`, or `keyFn`.
11
+ * @param options.comparator - Custom function to determine if elements are equal (optional)
12
+ * @param options.useDeepEqual - Use deep equality for comparison (optional)
13
+ * @param options.keyFn - Optional function to extract a primitive key for O(n+m) Set-based lookup. When provided, enables efficient comparison by mapping each item to a key that can be stored in a Set. Example: `{ keyFn: item => item.id }` for objects with a unique id field.
14
+ * @returns Array of elements in `array1` that are not in `array2`. Returns `[]` if `array1` is `null`, `undefined`, or an empty array.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * // Basic difference with primitives
19
+ * ArrayDifference([1, 2, 3, 4], [2, 4]); // [1, 3]
20
+ *
21
+ * // Deep equality comparison with objects
22
+ * const arr1 = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
23
+ * const arr2 = [{ id: 2, name: 'Bob' }, { id: 3, name: 'Charlie' }];
24
+ * ArrayDifference(arr1, arr2, { useDeepEqual: true });
25
+ * // [{ id: 1, name: 'Alice' }]
26
+ *
27
+ * // Custom comparator
28
+ * ArrayDifference(arr1, arr2, {
29
+ * comparator: (a, b) => a.id === b.id
30
+ * });
31
+ * // [{ id: 1, name: 'Alice' }]
32
+ *
33
+ * // Key function for O(n+m) lookup
34
+ * ArrayDifference(arr1, arr2, {
35
+ * keyFn: item => item.id
36
+ * });
37
+ * // [{ id: 1, name: 'Alice' }]
38
+ * ```
39
+ *
40
+ * @complexity O(n+m) for primitive values, O(n+m) with keyFn, O(n*m) when a comparator or deep equality is provided
41
+ */
42
+ export function ArrayDifference(array1, array2, options) {
43
+ if (!array1)
44
+ return [];
45
+ if (!array2 || array2.length === 0)
46
+ return [...array1];
47
+ // Type narrowing: determine which strategy to use
48
+ if (!options) {
49
+ // No options: use reference equality (===)
50
+ const set2 = new Set(array2);
51
+ return array1.filter((item) => !set2.has(item));
52
+ }
53
+ if ('keyFn' in options && options.keyFn !== undefined) {
54
+ // Use key function for O(n+m) Set-based lookup
55
+ const keyFn = options.keyFn;
56
+ const set2 = new Set(array2.map(keyFn));
57
+ return array1.filter((item) => !set2.has(keyFn(item)));
58
+ }
59
+ if ('comparator' in options && options.comparator !== undefined) {
60
+ // Use custom comparator
61
+ return array1.filter((item) => !array2.some((other) => options.comparator(item, other)));
62
+ }
63
+ if (options.useDeepEqual) {
64
+ // Use deep equality
65
+ return array1.filter((item) => !array2.some((other) => ObjectEquals(item, other)));
66
+ }
67
+ // Fallback (should not reach here with proper type narrowing)
68
+ const set2 = new Set(array2);
69
+ return array1.filter((item) => !set2.has(item));
70
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -7,7 +7,7 @@ import type { TPredicate } from './types.js';
7
7
  *
8
8
  * @param array - The array to filter
9
9
  * @param criteria - Either an object with filter criteria or a predicate function
10
- * @returns A new array containing only items that match the criteria
10
+ * @returns A new array containing only items that match the criteria. Returns `[]` if `array` is `null`, `undefined`, or empty.
11
11
  *
12
12
  * @example
13
13
  * // Simple property filtering
@@ -39,7 +39,7 @@ function matchesValue(value, filterValue) {
39
39
  *
40
40
  * @param array - The array to filter
41
41
  * @param criteria - Either an object with filter criteria or a predicate function
42
- * @returns A new array containing only items that match the criteria
42
+ * @returns A new array containing only items that match the criteria. Returns `[]` if `array` is `null`, `undefined`, or empty.
43
43
  *
44
44
  * @example
45
45
  * // Simple property filtering
@@ -83,4 +83,3 @@ export function ArrayFilter(array, criteria) {
83
83
  });
84
84
  });
85
85
  }
86
- //# sourceMappingURL=array-filter.js.map
@@ -4,7 +4,7 @@
4
4
  * @template T - The leaf element type
5
5
  * @param array - The nested array to flatten
6
6
  * @param depth - How many levels deep to flatten (default: `Infinity`)
7
- * @returns Flattened array of `T`
7
+ * @returns Flattened array of `T`. Returns `[]` if `array` is `null` or `undefined`.
8
8
  *
9
9
  * @example
10
10
  * ```typescript
@@ -12,5 +12,5 @@
12
12
  * ArrayFlatten([1, [2, [3]]], 1); // [1, 2, [3]]
13
13
  * ```
14
14
  */
15
- export declare function ArrayFlatten<T = unknown>(array: readonly any[], depth?: number): T[];
15
+ export declare function ArrayFlatten<T = unknown>(array: readonly unknown[], depth?: number): T[];
16
16
  //# sourceMappingURL=array-flatten.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"array-flatten.d.ts","sourceRoot":"","sources":["../../src/array/array-flatten.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,SAAS,GAAG,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,CAGpF"}
1
+ {"version":3,"file":"array-flatten.d.ts","sourceRoot":"","sources":["../../src/array/array-flatten.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,SAAS,OAAO,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,CAGxF"}
@@ -4,7 +4,7 @@
4
4
  * @template T - The leaf element type
5
5
  * @param array - The nested array to flatten
6
6
  * @param depth - How many levels deep to flatten (default: `Infinity`)
7
- * @returns Flattened array of `T`
7
+ * @returns Flattened array of `T`. Returns `[]` if `array` is `null` or `undefined`.
8
8
  *
9
9
  * @example
10
10
  * ```typescript
@@ -17,4 +17,3 @@ export function ArrayFlatten(array, depth) {
17
17
  return [];
18
18
  return array.flat(depth ?? Infinity);
19
19
  }
20
- //# sourceMappingURL=array-flatten.js.map
@@ -8,7 +8,7 @@ import type { TTransform } from './types.js';
8
8
  * @template K - The key type (string, number, or symbol)
9
9
  * @param array - The array to group
10
10
  * @param keyFn - Function that returns the grouping key for each element
11
- * @returns A record where each key maps to an array of matching elements
11
+ * @returns A record where each key maps to an array of matching elements. Returns `{}` if `array` is `null`, `undefined`, or an empty array.
12
12
  *
13
13
  * @example
14
14
  * ```typescript
@@ -1 +1 @@
1
- {"version":3,"file":"array-group-by.d.ts","sourceRoot":"","sources":["../../src/array/array-group-by.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAchI"}
1
+ {"version":3,"file":"array-group-by.d.ts","sourceRoot":"","sources":["../../src/array/array-group-by.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAgBhI"}
@@ -7,7 +7,7 @@
7
7
  * @template K - The key type (string, number, or symbol)
8
8
  * @param array - The array to group
9
9
  * @param keyFn - Function that returns the grouping key for each element
10
- * @returns A record where each key maps to an array of matching elements
10
+ * @returns A record where each key maps to an array of matching elements. Returns `{}` if `array` is `null`, `undefined`, or an empty array.
11
11
  *
12
12
  * @example
13
13
  * ```typescript
@@ -21,16 +21,17 @@
21
21
  */
22
22
  export function ArrayGroupBy(array, keyFn) {
23
23
  // Consistent null-check: early return for null/undefined arrays
24
- if (!array) {
24
+ if (array === null || array === undefined) {
25
25
  return {};
26
26
  }
27
- return array.reduce((acc, item) => {
27
+ // Use imperative loop instead of reduce for slightly better performance on large arrays
28
+ const result = {};
29
+ for (const item of array) {
28
30
  const key = keyFn(item);
29
- if (!acc[key]) {
30
- acc[key] = [];
31
+ if (!result[key]) {
32
+ result[key] = [];
31
33
  }
32
- acc[key].push(item);
33
- return acc;
34
- }, {});
34
+ result[key].push(item);
35
+ }
36
+ return result;
35
37
  }
36
- //# sourceMappingURL=array-group-by.js.map
@@ -2,15 +2,16 @@ import type { TArrayComparisonOptions } from './types.js';
2
2
  /**
3
3
  * Returns the intersection of two arrays (elements present in both)
4
4
  * Optimized O(n+m) complexity using Set-based approach.
5
- * Supports custom comparators for advanced comparison logic, or deep equality checking.
5
+ * Supports custom comparators for advanced comparison logic, deep equality checking, or key extraction.
6
6
  *
7
7
  * @template T - The type of array elements
8
8
  * @param array1 - First array
9
9
  * @param array2 - Second array
10
- * @param options - Optional configuration
10
+ * @param options - Optional configuration. Choose one strategy: `comparator`, `useDeepEqual`, or `keyFn`.
11
11
  * @param options.comparator - Custom function to determine if elements are equal (optional)
12
- * @param options.useDeepEqual - Use deep equality for comparison instead of custom comparator (optional)
13
- * @returns Array containing elements present in both arrays
12
+ * @param options.useDeepEqual - Use deep equality for comparison (optional)
13
+ * @param options.keyFn - Optional function to extract a primitive key for O(n+m) Set-based lookup. When provided, enables efficient comparison by mapping each item to a key that can be stored in a Set. Example: `{ keyFn: item => item.id }` for objects with a unique id field.
14
+ * @returns Array containing elements present in both arrays. Returns `[]` if either `array1` or `array2` is `null`, `undefined`, or an empty array.
14
15
  *
15
16
  * @example
16
17
  * ```typescript
@@ -28,9 +29,15 @@ import type { TArrayComparisonOptions } from './types.js';
28
29
  * comparator: (a, b) => a.id === b.id
29
30
  * });
30
31
  * // [{ id: 2, name: 'Bob' }]
32
+ *
33
+ * // Key function for O(n+m) lookup
34
+ * ArrayIntersection(arr1, arr2, {
35
+ * keyFn: item => item.id
36
+ * });
37
+ * // [{ id: 2, name: 'Bob' }]
31
38
  * ```
32
39
  *
33
- * @complexity O(n+m) where n and m are array lengths
40
+ * @complexity O(n+m) where n and m are array lengths (O(n*m) with custom comparator or deep equality)
34
41
  */
35
42
  export declare function ArrayIntersection<T>(array1: readonly T[], array2: readonly T[], options?: TArrayComparisonOptions<T>): T[];
36
43
  //# sourceMappingURL=array-intersection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array-intersection.d.ts","sourceRoot":"","sources":["../../src/array/array-intersection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAG1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAClC,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,MAAM,EAAE,SAAS,CAAC,EAAE,EACpB,OAAO,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAClC,CAAC,EAAE,CA8CL"}
@@ -0,0 +1,79 @@
1
+ import { ObjectEquals } from '../object/equals.js';
2
+ /**
3
+ * Returns the intersection of two arrays (elements present in both)
4
+ * Optimized O(n+m) complexity using Set-based approach.
5
+ * Supports custom comparators for advanced comparison logic, deep equality checking, or key extraction.
6
+ *
7
+ * @template T - The type of array elements
8
+ * @param array1 - First array
9
+ * @param array2 - Second array
10
+ * @param options - Optional configuration. Choose one strategy: `comparator`, `useDeepEqual`, or `keyFn`.
11
+ * @param options.comparator - Custom function to determine if elements are equal (optional)
12
+ * @param options.useDeepEqual - Use deep equality for comparison (optional)
13
+ * @param options.keyFn - Optional function to extract a primitive key for O(n+m) Set-based lookup. When provided, enables efficient comparison by mapping each item to a key that can be stored in a Set. Example: `{ keyFn: item => item.id }` for objects with a unique id field.
14
+ * @returns Array containing elements present in both arrays. Returns `[]` if either `array1` or `array2` is `null`, `undefined`, or an empty array.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * // Basic intersection with primitives
19
+ * ArrayIntersection([1, 2, 3], [2, 3, 4]); // [2, 3]
20
+ *
21
+ * // Deep equality comparison with objects
22
+ * const arr1 = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
23
+ * const arr2 = [{ id: 2, name: 'Bob' }, { id: 3, name: 'Charlie' }];
24
+ * ArrayIntersection(arr1, arr2, { useDeepEqual: true });
25
+ * // [{ id: 2, name: 'Bob' }]
26
+ *
27
+ * // Custom comparator
28
+ * ArrayIntersection(arr1, arr2, {
29
+ * comparator: (a, b) => a.id === b.id
30
+ * });
31
+ * // [{ id: 2, name: 'Bob' }]
32
+ *
33
+ * // Key function for O(n+m) lookup
34
+ * ArrayIntersection(arr1, arr2, {
35
+ * keyFn: item => item.id
36
+ * });
37
+ * // [{ id: 2, name: 'Bob' }]
38
+ * ```
39
+ *
40
+ * @complexity O(n+m) where n and m are array lengths (O(n*m) with custom comparator or deep equality)
41
+ */
42
+ export function ArrayIntersection(array1, array2, options) {
43
+ if (!array1 || !array2) {
44
+ return [];
45
+ }
46
+ // Type narrowing: determine which strategy to use
47
+ if (!options) {
48
+ // No options: use reference equality (===)
49
+ const set2 = new Set(array2);
50
+ return array1.filter(item => set2.has(item));
51
+ }
52
+ if ('keyFn' in options && options.keyFn !== undefined) {
53
+ // Use key function for O(n+m) Set-based lookup
54
+ const keyFn = options.keyFn;
55
+ const set2 = new Set(array2.map(keyFn));
56
+ return array1.filter(item => set2.has(keyFn(item)));
57
+ }
58
+ if ('comparator' in options && options.comparator !== undefined) {
59
+ // Use custom comparator
60
+ // Optimize by checking smaller array to reduce comparisons from n*m to min(n,m)*max(n,m)
61
+ const [smaller, larger] = array1.length <= array2.length
62
+ ? [array1, array2]
63
+ : [array2, array1];
64
+ return smaller.filter(item => larger.some(otherItem => options.comparator(item, otherItem)));
65
+ }
66
+ if (options.useDeepEqual) {
67
+ // Use deep equality
68
+ // Optimize by checking smaller array
69
+ // PERFORMANCE NOTE: This nested .some() call is O(n*m) where n and m are array lengths.
70
+ // For large arrays using deep equality, this can be 100-1000x slower than necessary.
71
+ const [smaller, larger] = array1.length <= array2.length
72
+ ? [array1, array2]
73
+ : [array2, array1];
74
+ return smaller.filter(item => larger.some(otherItem => ObjectEquals(item, otherItem)));
75
+ }
76
+ // Fallback (should not reach here with proper type narrowing)
77
+ const set2 = new Set(array2);
78
+ return array1.filter(item => set2.has(item));
79
+ }
@@ -7,7 +7,7 @@ import type { TPredicate } from './types.js';
7
7
  * @template T - The type of array elements
8
8
  * @param array - The array to partition
9
9
  * @param predicate - The condition to test each element against
10
- * @returns A tuple `[matches, rest]` where `matches` passed the predicate
10
+ * @returns A tuple `[matches, rest]` where `matches` passed the predicate. Returns `[[], []]` if `array` is `null`, `undefined`, or empty.
11
11
  *
12
12
  * @example
13
13
  * ```typescript
@@ -6,7 +6,7 @@
6
6
  * @template T - The type of array elements
7
7
  * @param array - The array to partition
8
8
  * @param predicate - The condition to test each element against
9
- * @returns A tuple `[matches, rest]` where `matches` passed the predicate
9
+ * @returns A tuple `[matches, rest]` where `matches` passed the predicate. Returns `[[], []]` if `array` is `null`, `undefined`, or empty.
10
10
  *
11
11
  * @example
12
12
  * ```typescript
@@ -18,7 +18,7 @@
18
18
  */
19
19
  export function ArrayPartition(array, predicate) {
20
20
  // Consistent null-check: early return for null/undefined arrays
21
- if (!array)
21
+ if (array === null || array === undefined)
22
22
  return [[], []];
23
23
  const matches = [];
24
24
  const rest = [];
@@ -32,4 +32,3 @@ export function ArrayPartition(array, predicate) {
32
32
  }
33
33
  return [matches, rest];
34
34
  }
35
- //# sourceMappingURL=array-partition.js.map
@@ -4,7 +4,7 @@
4
4
  * @param start - The first value in the range
5
5
  * @param end - The value to stop before (exclusive)
6
6
  * @param step - Increment between values (default: `1`; use negative for descending ranges)
7
- * @returns Array of numbers
7
+ * @returns Array of numbers. Returns `[]` if `step` is 0, or if the range is invalid (e.g., `start >= end` with positive `step`).
8
8
  *
9
9
  * @example
10
10
  * ```typescript
@@ -4,7 +4,7 @@
4
4
  * @param start - The first value in the range
5
5
  * @param end - The value to stop before (exclusive)
6
6
  * @param step - Increment between values (default: `1`; use negative for descending ranges)
7
- * @returns Array of numbers
7
+ * @returns Array of numbers. Returns `[]` if `step` is 0, or if the range is invalid (e.g., `start >= end` with positive `step`).
8
8
  *
9
9
  * @example
10
10
  * ```typescript
@@ -29,4 +29,3 @@ export function ArrayRange(start, end, step = 1) {
29
29
  }
30
30
  return result;
31
31
  }
32
- //# sourceMappingURL=array-range.js.map
@@ -4,7 +4,7 @@
4
4
  * @template T - The type of array elements
5
5
  * @param array - The array to sample from
6
6
  * @param random - Optional custom RNG function (returns number between 0 and 1). Defaults to `Math.random`.
7
- * @returns A random element, or `undefined` if the array is empty
7
+ * @returns A random element, or `undefined` if the array is `null`, `undefined`, or empty
8
8
  *
9
9
  * @example
10
10
  * ```typescript
@@ -21,7 +21,7 @@ export declare function ArraySample<T>(array: readonly T[]): T | undefined;
21
21
  * @param array - The array to sample from
22
22
  * @param n - How many elements to sample
23
23
  * @param random - Optional custom RNG function (returns number between 0 and 1). Defaults to `Math.random`.
24
- * @returns An array of `n` randomly selected elements
24
+ * @returns An array of `n` randomly selected elements. Returns `[]` if `array` is `null`, `undefined`, or empty.
25
25
  *
26
26
  * @example
27
27
  * ```typescript
@@ -1,15 +1,14 @@
1
1
  export function ArraySample(array, n, random) {
2
- const sampleCount = n;
3
2
  const rng = random ?? Math.random;
4
3
  if (!array || array.length === 0) {
5
- return sampleCount !== undefined ? [] : undefined;
4
+ return n !== undefined ? [] : undefined;
6
5
  }
7
- if (sampleCount === undefined) {
6
+ if (n === undefined) {
8
7
  return array[Math.floor(rng() * array.length)];
9
8
  }
10
9
  // Fisher-Yates partial shuffle for O(n) sampling
11
10
  const copy = [...array];
12
- const count = Math.min(sampleCount, copy.length);
11
+ const count = Math.min(n, copy.length);
13
12
  for (let i = 0; i < count; i++) {
14
13
  const j = i + Math.floor(rng() * (copy.length - i));
15
14
  const tmp = copy[j];
@@ -18,4 +17,3 @@ export function ArraySample(array, n, random) {
18
17
  }
19
18
  return copy.slice(0, count);
20
19
  }
21
- //# sourceMappingURL=array-sample.js.map
@@ -4,7 +4,7 @@
4
4
  * @template T - The type of array elements
5
5
  * @param array - The array to shuffle
6
6
  * @param random - Optional custom RNG function (returns number between 0 and 1). Defaults to `Math.random`.
7
- * @returns A new shuffled array (original is not mutated)
7
+ * @returns A new shuffled array (original is not mutated). Returns `[]` if `array` is `null` or `undefined`.
8
8
  *
9
9
  * @remarks Uses `Math.random()` by default — not cryptographically secure. Do not use for
10
10
  * security-sensitive operations.
@@ -4,7 +4,7 @@
4
4
  * @template T - The type of array elements
5
5
  * @param array - The array to shuffle
6
6
  * @param random - Optional custom RNG function (returns number between 0 and 1). Defaults to `Math.random`.
7
- * @returns A new shuffled array (original is not mutated)
7
+ * @returns A new shuffled array (original is not mutated). Returns `[]` if `array` is `null` or `undefined`.
8
8
  *
9
9
  * @remarks Uses `Math.random()` by default — not cryptographically secure. Do not use for
10
10
  * security-sensitive operations.
@@ -28,4 +28,3 @@ export function ArrayShuffle(array, random) {
28
28
  }
29
29
  return result;
30
30
  }
31
- //# sourceMappingURL=array-shuffle.js.map
@@ -6,7 +6,7 @@ import type { TTransform } from './types.js';
6
6
  * @param array - The array to sort
7
7
  * @param keyFn - Function that extracts the sort key from each element
8
8
  * @param direction - Sort direction: `'asc'` (default) or `'desc'`
9
- * @returns A sorted copy of the array
9
+ * @returns A sorted copy of the array. Returns `[]` if `array` is `null` or `undefined`.
10
10
  *
11
11
  * @example
12
12
  * ```typescript
@@ -5,7 +5,7 @@
5
5
  * @param array - The array to sort
6
6
  * @param keyFn - Function that extracts the sort key from each element
7
7
  * @param direction - Sort direction: `'asc'` (default) or `'desc'`
8
- * @returns A sorted copy of the array
8
+ * @returns A sorted copy of the array. Returns `[]` if `array` is `null` or `undefined`.
9
9
  *
10
10
  * @example
11
11
  * ```typescript
@@ -28,4 +28,3 @@ export function ArraySortBy(array, keyFn, direction = 'asc') {
28
28
  return 0;
29
29
  });
30
30
  }
31
- //# sourceMappingURL=array-sort-by.js.map
@@ -3,7 +3,7 @@
3
3
  * The result length is capped at the shortest input array.
4
4
  *
5
5
  * @param arrays - Two or more arrays to zip
6
- * @returns Array of tuples — one tuple per index position
6
+ * @returns Array of tuples — one tuple per index position. Returns `[]` if `arrays` is empty or if any input array is `null` or `undefined`.
7
7
  *
8
8
  * @example
9
9
  * ```typescript