@vinicunca/perkakas 0.1.0 → 0.3.1

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 (605) hide show
  1. package/README.md +9 -0
  2. package/dist/commonjs/aria/index.js +17 -0
  3. package/dist/commonjs/aria/key-codes.js +25 -0
  4. package/dist/commonjs/array/all-pass.js +11 -0
  5. package/dist/commonjs/array/any-pass.js +11 -0
  6. package/dist/commonjs/array/chunk.js +17 -0
  7. package/dist/commonjs/array/compact.js +8 -0
  8. package/dist/commonjs/array/concat.js +11 -0
  9. package/dist/commonjs/array/count-by.js +22 -0
  10. package/dist/commonjs/array/difference-with.js +31 -0
  11. package/dist/commonjs/array/difference.js +32 -0
  12. package/dist/commonjs/array/drop-first-by.js +26 -0
  13. package/dist/commonjs/array/drop-last-while.js +16 -0
  14. package/dist/commonjs/array/drop-last.js +15 -0
  15. package/dist/commonjs/array/drop-while.js +16 -0
  16. package/dist/commonjs/array/drop.js +32 -0
  17. package/dist/commonjs/array/filter.js +41 -0
  18. package/dist/commonjs/array/find-index.js +46 -0
  19. package/dist/commonjs/array/find-last-index.js +24 -0
  20. package/dist/commonjs/array/find-last.js +24 -0
  21. package/dist/commonjs/array/find.js +38 -0
  22. package/dist/commonjs/array/first-by.js +22 -0
  23. package/dist/commonjs/array/first.js +26 -0
  24. package/dist/commonjs/array/flat-map-to-obj.js +25 -0
  25. package/dist/commonjs/array/flat-map.js +33 -0
  26. package/dist/commonjs/array/flatten-deep.js +48 -0
  27. package/dist/commonjs/array/flatten.js +32 -0
  28. package/dist/commonjs/array/for-each.js +40 -0
  29. package/dist/commonjs/array/group-by.js +33 -0
  30. package/dist/commonjs/array/has-at-least.js +11 -0
  31. package/dist/commonjs/array/index-by.js +24 -0
  32. package/dist/commonjs/array/index.js +81 -0
  33. package/dist/commonjs/array/intersection-with.js +31 -0
  34. package/dist/commonjs/array/intersection.js +32 -0
  35. package/dist/commonjs/array/join.js +11 -0
  36. package/dist/commonjs/array/last.js +11 -0
  37. package/dist/commonjs/array/length.js +11 -0
  38. package/dist/commonjs/array/map-to-obj.js +23 -0
  39. package/dist/commonjs/array/map.js +35 -0
  40. package/dist/commonjs/array/max-by.js +28 -0
  41. package/dist/commonjs/array/mean-by.js +26 -0
  42. package/dist/commonjs/array/merge-all.js +7 -0
  43. package/dist/commonjs/array/min-by.js +28 -0
  44. package/dist/commonjs/array/nth-by.js +12 -0
  45. package/dist/commonjs/array/only.js +14 -0
  46. package/dist/commonjs/array/partition.js +24 -0
  47. package/dist/commonjs/array/range.js +15 -0
  48. package/dist/commonjs/array/rank-by.js +17 -0
  49. package/dist/commonjs/array/reduce.js +19 -0
  50. package/dist/commonjs/array/reject.js +41 -0
  51. package/dist/commonjs/array/reverse.js +11 -0
  52. package/dist/commonjs/array/sample.js +34 -0
  53. package/dist/commonjs/array/shuffle.js +18 -0
  54. package/dist/commonjs/array/sort-by.js +52 -0
  55. package/dist/commonjs/array/sort.js +16 -0
  56. package/dist/commonjs/array/splice.js +13 -0
  57. package/dist/commonjs/array/split-at.js +13 -0
  58. package/dist/commonjs/array/split-when.js +17 -0
  59. package/dist/commonjs/array/sum-by.js +24 -0
  60. package/dist/commonjs/array/swap-indices.js +34 -0
  61. package/dist/commonjs/array/take-first-by.js +24 -0
  62. package/dist/commonjs/array/take-while.js +18 -0
  63. package/dist/commonjs/array/take.js +38 -0
  64. package/dist/commonjs/array/uniq-by.js +30 -0
  65. package/dist/commonjs/array/uniq-with.js +33 -0
  66. package/dist/commonjs/array/uniq.js +32 -0
  67. package/dist/commonjs/array/zip-obj.js +16 -0
  68. package/dist/commonjs/array/zip-with.js +23 -0
  69. package/dist/commonjs/array/zip.js +19 -0
  70. package/dist/commonjs/function/conditional.js +34 -0
  71. package/dist/commonjs/function/create-pipe.js +8 -0
  72. package/dist/commonjs/function/debounce.js +88 -0
  73. package/dist/commonjs/function/identity.js +7 -0
  74. package/dist/commonjs/function/index.js +25 -0
  75. package/dist/commonjs/function/noop.js +7 -0
  76. package/dist/commonjs/function/once.js +15 -0
  77. package/dist/commonjs/function/pipe.js +106 -0
  78. package/dist/commonjs/function/purry.js +20 -0
  79. package/dist/commonjs/function/sleep.js +9 -0
  80. package/dist/commonjs/guard/index.js +32 -0
  81. package/dist/commonjs/guard/is-array.js +7 -0
  82. package/dist/commonjs/guard/is-boolean.js +7 -0
  83. package/dist/commonjs/guard/is-date.js +7 -0
  84. package/dist/commonjs/guard/is-defined.js +13 -0
  85. package/dist/commonjs/guard/is-empty.js +19 -0
  86. package/dist/commonjs/guard/is-error.js +7 -0
  87. package/dist/commonjs/guard/is-function.js +7 -0
  88. package/dist/commonjs/guard/is-nil.js +7 -0
  89. package/dist/commonjs/guard/is-non-null.js +7 -0
  90. package/dist/commonjs/guard/is-not.js +9 -0
  91. package/dist/commonjs/guard/is-number.js +7 -0
  92. package/dist/commonjs/guard/is-object.js +11 -0
  93. package/dist/commonjs/guard/is-promise.js +7 -0
  94. package/dist/commonjs/guard/is-string.js +7 -0
  95. package/dist/commonjs/guard/is-symbol.js +7 -0
  96. package/dist/commonjs/guard/is-truthy.js +7 -0
  97. package/dist/commonjs/index.js +26 -0
  98. package/dist/commonjs/number/add.js +11 -0
  99. package/dist/commonjs/number/ceil.js +9 -0
  100. package/dist/commonjs/number/clamp.js +17 -0
  101. package/dist/commonjs/number/divide.js +11 -0
  102. package/dist/commonjs/number/floor.js +9 -0
  103. package/dist/commonjs/number/index.js +24 -0
  104. package/dist/commonjs/number/multiply.js +11 -0
  105. package/dist/commonjs/number/round.js +9 -0
  106. package/dist/commonjs/number/subtract.js +11 -0
  107. package/dist/commonjs/object/add-prop.js +14 -0
  108. package/dist/commonjs/object/clone.js +49 -0
  109. package/dist/commonjs/object/equals.js +71 -0
  110. package/dist/commonjs/object/for-each-obj.js +30 -0
  111. package/dist/commonjs/object/from-pairs.js +14 -0
  112. package/dist/commonjs/object/index.js +39 -0
  113. package/dist/commonjs/object/invert.js +15 -0
  114. package/dist/commonjs/object/keys.js +10 -0
  115. package/dist/commonjs/object/map-keys.js +16 -0
  116. package/dist/commonjs/object/map-values.js +16 -0
  117. package/dist/commonjs/object/merge-deep.js +31 -0
  118. package/dist/commonjs/object/merge.js +11 -0
  119. package/dist/commonjs/object/omit-by.js +20 -0
  120. package/dist/commonjs/object/omit.js +25 -0
  121. package/dist/commonjs/object/path-or.js +18 -0
  122. package/dist/commonjs/object/pick-by.js +20 -0
  123. package/dist/commonjs/object/pick.js +19 -0
  124. package/dist/commonjs/object/prop.js +7 -0
  125. package/dist/commonjs/object/set-path.js +26 -0
  126. package/dist/commonjs/object/set.js +14 -0
  127. package/dist/commonjs/object/swap-props.js +16 -0
  128. package/dist/commonjs/object/to-pairs.js +11 -0
  129. package/dist/commonjs/object/values.js +7 -0
  130. package/dist/commonjs/string/cases-types.js +2 -0
  131. package/dist/commonjs/string/cases.js +107 -0
  132. package/dist/commonjs/string/human-readable-file-size.js +16 -0
  133. package/dist/commonjs/string/index.js +21 -0
  134. package/dist/commonjs/string/random-string.js +10 -0
  135. package/dist/commonjs/string/slugify.js +13 -0
  136. package/dist/commonjs/string/string-to-path.js +18 -0
  137. package/dist/commonjs/type/index.js +17 -0
  138. package/dist/commonjs/type/type.js +13 -0
  139. package/dist/commonjs/utils/heap.js +43 -0
  140. package/dist/commonjs/utils/narrow.js +2 -0
  141. package/dist/commonjs/utils/paths.js +2 -0
  142. package/dist/commonjs/utils/purry-on.js +10 -0
  143. package/dist/commonjs/utils/purry-order-rules.js +66 -0
  144. package/dist/commonjs/utils/quick-select.js +31 -0
  145. package/dist/commonjs/utils/reduce-lazy.js +18 -0
  146. package/dist/commonjs/utils/swap-in-place.js +7 -0
  147. package/dist/commonjs/utils/to-lazy-indexed.js +7 -0
  148. package/dist/commonjs/utils/to-single.js +8 -0
  149. package/dist/commonjs/utils/types.js +2 -0
  150. package/dist/commonjs/utils/with-precision.js +23 -0
  151. package/dist/es/aria/index.js +1 -0
  152. package/dist/es/aria/key-codes.js +22 -0
  153. package/dist/es/array/all-pass.js +7 -0
  154. package/dist/es/array/any-pass.js +7 -0
  155. package/dist/es/array/chunk.js +13 -0
  156. package/dist/es/array/compact.js +4 -0
  157. package/dist/es/array/concat.js +7 -0
  158. package/dist/es/array/count-by.js +18 -0
  159. package/dist/es/array/difference-with.js +27 -0
  160. package/dist/es/array/difference.js +28 -0
  161. package/dist/es/array/drop-first-by.js +22 -0
  162. package/dist/es/array/drop-last-while.js +12 -0
  163. package/dist/es/array/drop-last.js +11 -0
  164. package/dist/es/array/drop-while.js +12 -0
  165. package/dist/es/array/drop.js +28 -0
  166. package/dist/es/array/filter.js +37 -0
  167. package/dist/es/array/find-index.js +42 -0
  168. package/dist/es/array/find-last-index.js +20 -0
  169. package/dist/es/array/find-last.js +20 -0
  170. package/dist/es/array/find.js +34 -0
  171. package/dist/es/array/first-by.js +18 -0
  172. package/dist/es/array/first.js +22 -0
  173. package/dist/es/array/flat-map-to-obj.js +21 -0
  174. package/dist/es/array/flat-map.js +29 -0
  175. package/dist/es/array/flatten-deep.js +44 -0
  176. package/dist/es/array/flatten.js +28 -0
  177. package/dist/es/array/for-each.js +36 -0
  178. package/dist/es/array/group-by.js +29 -0
  179. package/dist/es/array/has-at-least.js +7 -0
  180. package/dist/es/array/index-by.js +20 -0
  181. package/dist/es/array/index.js +65 -0
  182. package/dist/es/array/intersection-with.js +27 -0
  183. package/dist/es/array/intersection.js +28 -0
  184. package/dist/es/array/join.js +7 -0
  185. package/dist/es/array/last.js +7 -0
  186. package/dist/es/array/length.js +7 -0
  187. package/dist/es/array/map-to-obj.js +19 -0
  188. package/dist/es/array/map.js +31 -0
  189. package/dist/es/array/max-by.js +24 -0
  190. package/dist/es/array/mean-by.js +22 -0
  191. package/dist/es/array/merge-all.js +3 -0
  192. package/dist/es/array/min-by.js +24 -0
  193. package/dist/es/array/nth-by.js +8 -0
  194. package/dist/es/array/only.js +10 -0
  195. package/dist/es/array/partition.js +20 -0
  196. package/dist/es/array/range.js +11 -0
  197. package/dist/es/array/rank-by.js +13 -0
  198. package/dist/es/array/reduce.js +15 -0
  199. package/dist/es/array/reject.js +37 -0
  200. package/dist/es/array/reverse.js +7 -0
  201. package/dist/es/array/sample.js +30 -0
  202. package/dist/es/array/shuffle.js +14 -0
  203. package/dist/es/array/sort-by.js +48 -0
  204. package/dist/es/array/sort.js +12 -0
  205. package/dist/es/array/splice.js +9 -0
  206. package/dist/es/array/split-at.js +9 -0
  207. package/dist/es/array/split-when.js +13 -0
  208. package/dist/es/array/sum-by.js +20 -0
  209. package/dist/es/array/swap-indices.js +30 -0
  210. package/dist/es/array/take-first-by.js +20 -0
  211. package/dist/es/array/take-while.js +14 -0
  212. package/dist/es/array/take.js +34 -0
  213. package/dist/es/array/uniq-by.js +26 -0
  214. package/dist/es/array/uniq-with.js +29 -0
  215. package/dist/es/array/uniq.js +28 -0
  216. package/dist/es/array/zip-obj.js +12 -0
  217. package/dist/es/array/zip-with.js +19 -0
  218. package/dist/es/array/zip.js +15 -0
  219. package/dist/es/function/conditional.js +30 -0
  220. package/dist/es/function/create-pipe.js +4 -0
  221. package/dist/es/function/debounce.js +84 -0
  222. package/dist/es/function/identity.js +3 -0
  223. package/dist/es/function/index.js +9 -0
  224. package/dist/es/function/noop.js +3 -0
  225. package/dist/es/function/once.js +11 -0
  226. package/dist/es/function/pipe.js +102 -0
  227. package/dist/es/function/purry.js +16 -0
  228. package/dist/es/function/sleep.js +5 -0
  229. package/dist/es/guard/index.js +16 -0
  230. package/dist/es/guard/is-array.js +3 -0
  231. package/dist/es/guard/is-boolean.js +3 -0
  232. package/dist/es/guard/is-date.js +3 -0
  233. package/dist/es/guard/is-defined.js +9 -0
  234. package/dist/es/guard/is-empty.js +15 -0
  235. package/dist/es/guard/is-error.js +3 -0
  236. package/dist/es/guard/is-function.js +3 -0
  237. package/dist/es/guard/is-nil.js +3 -0
  238. package/dist/es/guard/is-non-null.js +3 -0
  239. package/dist/es/guard/is-not.js +5 -0
  240. package/dist/es/guard/is-number.js +3 -0
  241. package/dist/es/guard/is-object.js +7 -0
  242. package/dist/es/guard/is-promise.js +3 -0
  243. package/dist/es/guard/is-string.js +3 -0
  244. package/dist/es/guard/is-symbol.js +3 -0
  245. package/dist/es/guard/is-truthy.js +3 -0
  246. package/dist/es/index.js +9 -0
  247. package/dist/es/number/add.js +7 -0
  248. package/dist/es/number/ceil.js +5 -0
  249. package/dist/es/number/clamp.js +13 -0
  250. package/dist/es/number/divide.js +7 -0
  251. package/dist/es/number/floor.js +5 -0
  252. package/dist/es/number/index.js +8 -0
  253. package/dist/es/number/multiply.js +7 -0
  254. package/dist/es/number/round.js +5 -0
  255. package/dist/es/number/subtract.js +7 -0
  256. package/dist/es/object/add-prop.js +10 -0
  257. package/dist/es/object/clone.js +45 -0
  258. package/dist/es/object/equals.js +67 -0
  259. package/dist/es/object/for-each-obj.js +26 -0
  260. package/dist/es/object/from-pairs.js +10 -0
  261. package/dist/es/object/index.js +23 -0
  262. package/dist/es/object/invert.js +11 -0
  263. package/dist/es/object/keys.js +6 -0
  264. package/dist/es/object/map-keys.js +12 -0
  265. package/dist/es/object/map-values.js +12 -0
  266. package/dist/es/object/merge-deep.js +27 -0
  267. package/dist/es/object/merge.js +7 -0
  268. package/dist/es/object/omit-by.js +16 -0
  269. package/dist/es/object/omit.js +21 -0
  270. package/dist/es/object/path-or.js +14 -0
  271. package/dist/es/object/pick-by.js +16 -0
  272. package/dist/es/object/pick.js +15 -0
  273. package/dist/es/object/prop.js +3 -0
  274. package/dist/es/object/set-path.js +21 -0
  275. package/dist/es/object/set.js +10 -0
  276. package/dist/es/object/swap-props.js +12 -0
  277. package/dist/es/object/to-pairs.js +7 -0
  278. package/dist/es/object/values.js +3 -0
  279. package/dist/es/string/cases-types.js +1 -0
  280. package/dist/es/string/cases.js +93 -0
  281. package/dist/es/string/human-readable-file-size.js +12 -0
  282. package/dist/es/string/index.js +5 -0
  283. package/dist/es/string/random-string.js +6 -0
  284. package/dist/es/string/slugify.js +9 -0
  285. package/dist/es/string/string-to-path.js +14 -0
  286. package/dist/es/type/index.js +1 -0
  287. package/dist/es/type/type.js +9 -0
  288. package/dist/es/utils/heap.js +38 -0
  289. package/dist/es/utils/narrow.js +1 -0
  290. package/dist/es/utils/paths.js +1 -0
  291. package/dist/es/utils/purry-on.js +6 -0
  292. package/dist/es/utils/purry-order-rules.js +61 -0
  293. package/dist/es/utils/quick-select.js +27 -0
  294. package/dist/es/utils/reduce-lazy.js +14 -0
  295. package/dist/es/utils/swap-in-place.js +3 -0
  296. package/dist/es/utils/to-lazy-indexed.js +3 -0
  297. package/dist/es/utils/to-single.js +4 -0
  298. package/dist/es/utils/types.js +1 -0
  299. package/dist/es/utils/with-precision.js +19 -0
  300. package/dist/metadata.json +48311 -0
  301. package/dist/types/aria/index.d.ts +2 -0
  302. package/dist/types/aria/index.d.ts.map +1 -0
  303. package/dist/types/aria/key-codes.d.ts +26 -0
  304. package/dist/types/aria/key-codes.d.ts.map +1 -0
  305. package/dist/types/array/all-pass.d.ts +32 -0
  306. package/dist/types/array/all-pass.d.ts.map +1 -0
  307. package/dist/types/array/any-pass.d.ts +32 -0
  308. package/dist/types/array/any-pass.d.ts.map +1 -0
  309. package/dist/types/array/chunk.d.ts +29 -0
  310. package/dist/types/array/chunk.d.ts.map +1 -0
  311. package/dist/types/array/compact.d.ts +12 -0
  312. package/dist/types/array/compact.d.ts.map +1 -0
  313. package/dist/types/array/concat.d.ts +24 -0
  314. package/dist/types/array/concat.d.ts.map +1 -0
  315. package/dist/types/array/count-by.d.ts +20 -0
  316. package/dist/types/array/count-by.d.ts.map +1 -0
  317. package/dist/types/array/difference-with.d.ts +48 -0
  318. package/dist/types/array/difference-with.d.ts.map +1 -0
  319. package/dist/types/array/difference.d.ts +35 -0
  320. package/dist/types/array/difference.d.ts.map +1 -0
  321. package/dist/types/array/drop-first-by.d.ts +39 -0
  322. package/dist/types/array/drop-first-by.d.ts.map +1 -0
  323. package/dist/types/array/drop-last-while.d.ts +30 -0
  324. package/dist/types/array/drop-last-while.d.ts.map +1 -0
  325. package/dist/types/array/drop-last.d.ts +25 -0
  326. package/dist/types/array/drop-last.d.ts.map +1 -0
  327. package/dist/types/array/drop-while.d.ts +33 -0
  328. package/dist/types/array/drop-while.d.ts.map +1 -0
  329. package/dist/types/array/drop.d.ts +31 -0
  330. package/dist/types/array/drop.d.ts.map +1 -0
  331. package/dist/types/array/filter.d.ts +49 -0
  332. package/dist/types/array/filter.d.ts.map +1 -0
  333. package/dist/types/array/find-index.d.ts +67 -0
  334. package/dist/types/array/find-index.d.ts.map +1 -0
  335. package/dist/types/array/find-last-index.d.ts +43 -0
  336. package/dist/types/array/find-last-index.d.ts.map +1 -0
  337. package/dist/types/array/find-last.d.ts +45 -0
  338. package/dist/types/array/find-last.d.ts.map +1 -0
  339. package/dist/types/array/find.d.ts +59 -0
  340. package/dist/types/array/find.d.ts.map +1 -0
  341. package/dist/types/array/first-by.d.ts +57 -0
  342. package/dist/types/array/first-by.d.ts.map +1 -0
  343. package/dist/types/array/first.d.ts +35 -0
  344. package/dist/types/array/first.d.ts.map +1 -0
  345. package/dist/types/array/flat-map-to-obj.d.ts +50 -0
  346. package/dist/types/array/flat-map-to-obj.d.ts.map +1 -0
  347. package/dist/types/array/flat-map.d.ts +39 -0
  348. package/dist/types/array/flat-map.d.ts.map +1 -0
  349. package/dist/types/array/flatten-deep.d.ts +26 -0
  350. package/dist/types/array/flatten-deep.d.ts.map +1 -0
  351. package/dist/types/array/flatten.d.ts +23 -0
  352. package/dist/types/array/flatten.d.ts.map +1 -0
  353. package/dist/types/array/for-each.d.ts +57 -0
  354. package/dist/types/array/for-each.d.ts.map +1 -0
  355. package/dist/types/array/group-by.d.ts +36 -0
  356. package/dist/types/array/group-by.d.ts.map +1 -0
  357. package/dist/types/array/has-at-least.d.ts +47 -0
  358. package/dist/types/array/has-at-least.d.ts.map +1 -0
  359. package/dist/types/array/index-by.d.ts +34 -0
  360. package/dist/types/array/index-by.d.ts.map +1 -0
  361. package/dist/types/array/index.d.ts +66 -0
  362. package/dist/types/array/index.d.ts.map +1 -0
  363. package/dist/types/array/intersection-with.d.ts +54 -0
  364. package/dist/types/array/intersection-with.d.ts.map +1 -0
  365. package/dist/types/array/intersection.d.ts +30 -0
  366. package/dist/types/array/intersection.d.ts.map +1 -0
  367. package/dist/types/array/join.d.ts +45 -0
  368. package/dist/types/array/join.d.ts.map +1 -0
  369. package/dist/types/array/last.d.ts +24 -0
  370. package/dist/types/array/last.d.ts.map +1 -0
  371. package/dist/types/array/length.d.ts +14 -0
  372. package/dist/types/array/length.d.ts.map +1 -0
  373. package/dist/types/array/map-to-obj.d.ts +42 -0
  374. package/dist/types/array/map-to-obj.d.ts.map +1 -0
  375. package/dist/types/array/map.d.ts +62 -0
  376. package/dist/types/array/map.d.ts.map +1 -0
  377. package/dist/types/array/max-by.d.ts +39 -0
  378. package/dist/types/array/max-by.d.ts.map +1 -0
  379. package/dist/types/array/mean-by.d.ts +39 -0
  380. package/dist/types/array/mean-by.d.ts.map +1 -0
  381. package/dist/types/array/merge-all.d.ts +16 -0
  382. package/dist/types/array/merge-all.d.ts.map +1 -0
  383. package/dist/types/array/min-by.d.ts +39 -0
  384. package/dist/types/array/min-by.d.ts.map +1 -0
  385. package/dist/types/array/nth-by.d.ts +45 -0
  386. package/dist/types/array/nth-by.d.ts.map +1 -0
  387. package/dist/types/array/only.d.ts +36 -0
  388. package/dist/types/array/only.d.ts.map +1 -0
  389. package/dist/types/array/partition.d.ts +60 -0
  390. package/dist/types/array/partition.d.ts.map +1 -0
  391. package/dist/types/array/range.d.ts +22 -0
  392. package/dist/types/array/range.d.ts.map +1 -0
  393. package/dist/types/array/rank-by.d.ts +41 -0
  394. package/dist/types/array/rank-by.d.ts.map +1 -0
  395. package/dist/types/array/reduce.d.ts +35 -0
  396. package/dist/types/array/reduce.d.ts.map +1 -0
  397. package/dist/types/array/reject.d.ts +42 -0
  398. package/dist/types/array/reject.d.ts.map +1 -0
  399. package/dist/types/array/reverse.d.ts +25 -0
  400. package/dist/types/array/reverse.d.ts.map +1 -0
  401. package/dist/types/array/sample.d.ts +54 -0
  402. package/dist/types/array/sample.d.ts.map +1 -0
  403. package/dist/types/array/shuffle.d.ts +22 -0
  404. package/dist/types/array/shuffle.d.ts.map +1 -0
  405. package/dist/types/array/sort-by.d.ts +99 -0
  406. package/dist/types/array/sort-by.d.ts.map +1 -0
  407. package/dist/types/array/sort.d.ts +52 -0
  408. package/dist/types/array/sort.d.ts.map +1 -0
  409. package/dist/types/array/splice.d.ts +31 -0
  410. package/dist/types/array/splice.d.ts.map +1 -0
  411. package/dist/types/array/split-at.d.ts +26 -0
  412. package/dist/types/array/split-at.d.ts.map +1 -0
  413. package/dist/types/array/split-when.d.ts +24 -0
  414. package/dist/types/array/split-when.d.ts.map +1 -0
  415. package/dist/types/array/sum-by.d.ts +39 -0
  416. package/dist/types/array/sum-by.d.ts.map +1 -0
  417. package/dist/types/array/swap-indices.d.ts +68 -0
  418. package/dist/types/array/swap-indices.d.ts.map +1 -0
  419. package/dist/types/array/take-first-by.d.ts +43 -0
  420. package/dist/types/array/take-first-by.d.ts.map +1 -0
  421. package/dist/types/array/take-while.d.ts +24 -0
  422. package/dist/types/array/take-while.d.ts.map +1 -0
  423. package/dist/types/array/take.d.ts +30 -0
  424. package/dist/types/array/take.d.ts.map +1 -0
  425. package/dist/types/array/uniq-by.d.ts +22 -0
  426. package/dist/types/array/uniq-by.d.ts.map +1 -0
  427. package/dist/types/array/uniq-with.d.ts +44 -0
  428. package/dist/types/array/uniq-with.d.ts.map +1 -0
  429. package/dist/types/array/uniq.d.ts +24 -0
  430. package/dist/types/array/uniq.d.ts.map +1 -0
  431. package/dist/types/array/zip-obj.d.ts +26 -0
  432. package/dist/types/array/zip-obj.d.ts.map +1 -0
  433. package/dist/types/array/zip-with.d.ts +42 -0
  434. package/dist/types/array/zip-with.d.ts.map +1 -0
  435. package/dist/types/array/zip.d.ts +52 -0
  436. package/dist/types/array/zip.d.ts.map +1 -0
  437. package/dist/types/function/conditional.d.ts +108 -0
  438. package/dist/types/function/conditional.d.ts.map +1 -0
  439. package/dist/types/function/create-pipe.d.ts +19 -0
  440. package/dist/types/function/create-pipe.d.ts.map +1 -0
  441. package/dist/types/function/debounce.d.ts +92 -0
  442. package/dist/types/function/debounce.d.ts.map +1 -0
  443. package/dist/types/function/identity.d.ts +10 -0
  444. package/dist/types/function/identity.d.ts.map +1 -0
  445. package/dist/types/function/index.d.ts +10 -0
  446. package/dist/types/function/index.d.ts.map +1 -0
  447. package/dist/types/function/noop.d.ts +10 -0
  448. package/dist/types/function/noop.d.ts.map +1 -0
  449. package/dist/types/function/once.d.ts +13 -0
  450. package/dist/types/function/once.d.ts.map +1 -0
  451. package/dist/types/function/pipe.d.ts +32 -0
  452. package/dist/types/function/pipe.d.ts.map +1 -0
  453. package/dist/types/function/purry.d.ts +32 -0
  454. package/dist/types/function/purry.d.ts.map +1 -0
  455. package/dist/types/function/sleep.d.ts +12 -0
  456. package/dist/types/function/sleep.d.ts.map +1 -0
  457. package/dist/types/guard/index.d.ts +17 -0
  458. package/dist/types/guard/index.d.ts.map +1 -0
  459. package/dist/types/guard/is-array.d.ts +15 -0
  460. package/dist/types/guard/is-array.d.ts.map +1 -0
  461. package/dist/types/guard/is-boolean.d.ts +15 -0
  462. package/dist/types/guard/is-boolean.d.ts.map +1 -0
  463. package/dist/types/guard/is-date.d.ts +13 -0
  464. package/dist/types/guard/is-date.d.ts.map +1 -0
  465. package/dist/types/guard/is-defined.d.ts +22 -0
  466. package/dist/types/guard/is-defined.d.ts.map +1 -0
  467. package/dist/types/guard/is-empty.d.ts +19 -0
  468. package/dist/types/guard/is-empty.d.ts.map +1 -0
  469. package/dist/types/guard/is-error.d.ts +15 -0
  470. package/dist/types/guard/is-error.d.ts.map +1 -0
  471. package/dist/types/guard/is-function.d.ts +15 -0
  472. package/dist/types/guard/is-function.d.ts.map +1 -0
  473. package/dist/types/guard/is-nil.d.ts +14 -0
  474. package/dist/types/guard/is-nil.d.ts.map +1 -0
  475. package/dist/types/guard/is-non-null.d.ts +15 -0
  476. package/dist/types/guard/is-non-null.d.ts.map +1 -0
  477. package/dist/types/guard/is-not.d.ts +15 -0
  478. package/dist/types/guard/is-not.d.ts.map +1 -0
  479. package/dist/types/guard/is-number.d.ts +14 -0
  480. package/dist/types/guard/is-number.d.ts.map +1 -0
  481. package/dist/types/guard/is-object.d.ts +28 -0
  482. package/dist/types/guard/is-object.d.ts.map +1 -0
  483. package/dist/types/guard/is-promise.d.ts +14 -0
  484. package/dist/types/guard/is-promise.d.ts.map +1 -0
  485. package/dist/types/guard/is-string.d.ts +14 -0
  486. package/dist/types/guard/is-string.d.ts.map +1 -0
  487. package/dist/types/guard/is-symbol.d.ts +14 -0
  488. package/dist/types/guard/is-symbol.d.ts.map +1 -0
  489. package/dist/types/guard/is-truthy.d.ts +17 -0
  490. package/dist/types/guard/is-truthy.d.ts.map +1 -0
  491. package/dist/types/index.d.ts +10 -0
  492. package/dist/types/index.d.ts.map +1 -0
  493. package/dist/types/number/add.d.ts +29 -0
  494. package/dist/types/number/add.d.ts.map +1 -0
  495. package/dist/types/number/ceil.d.ts +35 -0
  496. package/dist/types/number/ceil.d.ts.map +1 -0
  497. package/dist/types/number/clamp.d.ts +38 -0
  498. package/dist/types/number/clamp.d.ts.map +1 -0
  499. package/dist/types/number/divide.d.ts +27 -0
  500. package/dist/types/number/divide.d.ts.map +1 -0
  501. package/dist/types/number/floor.d.ts +35 -0
  502. package/dist/types/number/floor.d.ts.map +1 -0
  503. package/dist/types/number/index.d.ts +9 -0
  504. package/dist/types/number/index.d.ts.map +1 -0
  505. package/dist/types/number/multiply.d.ts +27 -0
  506. package/dist/types/number/multiply.d.ts.map +1 -0
  507. package/dist/types/number/round.d.ts +35 -0
  508. package/dist/types/number/round.d.ts.map +1 -0
  509. package/dist/types/number/subtract.d.ts +29 -0
  510. package/dist/types/number/subtract.d.ts.map +1 -0
  511. package/dist/types/object/add-prop.d.ts +30 -0
  512. package/dist/types/object/add-prop.d.ts.map +1 -0
  513. package/dist/types/object/clone.d.ts +10 -0
  514. package/dist/types/object/clone.d.ts.map +1 -0
  515. package/dist/types/object/equals.d.ts +30 -0
  516. package/dist/types/object/equals.d.ts.map +1 -0
  517. package/dist/types/object/for-each-obj.d.ts +44 -0
  518. package/dist/types/object/for-each-obj.d.ts.map +1 -0
  519. package/dist/types/object/from-pairs.d.ts +38 -0
  520. package/dist/types/object/from-pairs.d.ts.map +1 -0
  521. package/dist/types/object/index.d.ts +24 -0
  522. package/dist/types/object/index.d.ts.map +1 -0
  523. package/dist/types/object/invert.d.ts +28 -0
  524. package/dist/types/object/invert.d.ts.map +1 -0
  525. package/dist/types/object/keys.d.ts +34 -0
  526. package/dist/types/object/keys.d.ts.map +1 -0
  527. package/dist/types/object/map-keys.d.ts +24 -0
  528. package/dist/types/object/map-keys.d.ts.map +1 -0
  529. package/dist/types/object/map-values.d.ts +25 -0
  530. package/dist/types/object/map-values.d.ts.map +1 -0
  531. package/dist/types/object/merge-deep.d.ts +32 -0
  532. package/dist/types/object/merge-deep.d.ts.map +1 -0
  533. package/dist/types/object/merge.d.ts +25 -0
  534. package/dist/types/object/merge.d.ts.map +1 -0
  535. package/dist/types/object/omit-by.d.ts +22 -0
  536. package/dist/types/object/omit-by.d.ts.map +1 -0
  537. package/dist/types/object/omit.d.ts +24 -0
  538. package/dist/types/object/omit.d.ts.map +1 -0
  539. package/dist/types/object/path-or.d.ts +76 -0
  540. package/dist/types/object/path-or.d.ts.map +1 -0
  541. package/dist/types/object/pick-by.d.ts +22 -0
  542. package/dist/types/object/pick-by.d.ts.map +1 -0
  543. package/dist/types/object/pick.d.ts +22 -0
  544. package/dist/types/object/pick.d.ts.map +1 -0
  545. package/dist/types/object/prop.d.ts +11 -0
  546. package/dist/types/object/prop.d.ts.map +1 -0
  547. package/dist/types/object/set-path.d.ts +29 -0
  548. package/dist/types/object/set-path.d.ts.map +1 -0
  549. package/dist/types/object/set.d.ts +26 -0
  550. package/dist/types/object/set.d.ts.map +1 -0
  551. package/dist/types/object/swap-props.d.ts +44 -0
  552. package/dist/types/object/swap-props.d.ts.map +1 -0
  553. package/dist/types/object/to-pairs.d.ts +33 -0
  554. package/dist/types/object/to-pairs.d.ts.map +1 -0
  555. package/dist/types/object/values.d.ts +20 -0
  556. package/dist/types/object/values.d.ts.map +1 -0
  557. package/dist/types/string/cases-types.d.ts +36 -0
  558. package/dist/types/string/cases-types.d.ts.map +1 -0
  559. package/dist/types/string/cases.d.ts +22 -0
  560. package/dist/types/string/cases.d.ts.map +1 -0
  561. package/dist/types/string/human-readable-file-size.d.ts +13 -0
  562. package/dist/types/string/human-readable-file-size.d.ts.map +1 -0
  563. package/dist/types/string/index.d.ts +6 -0
  564. package/dist/types/string/index.d.ts.map +1 -0
  565. package/dist/types/string/random-string.d.ts +10 -0
  566. package/dist/types/string/random-string.d.ts.map +1 -0
  567. package/dist/types/string/slugify.d.ts +12 -0
  568. package/dist/types/string/slugify.d.ts.map +1 -0
  569. package/dist/types/string/string-to-path.d.ts +11 -0
  570. package/dist/types/string/string-to-path.d.ts.map +1 -0
  571. package/dist/types/type/index.d.ts +2 -0
  572. package/dist/types/type/index.d.ts.map +1 -0
  573. package/dist/types/type/type.d.ts +19 -0
  574. package/dist/types/type/type.d.ts.map +1 -0
  575. package/dist/types/utils/heap.d.ts +24 -0
  576. package/dist/types/utils/heap.d.ts.map +1 -0
  577. package/dist/types/utils/narrow.d.ts +52 -0
  578. package/dist/types/utils/narrow.d.ts.map +1 -0
  579. package/dist/types/utils/paths.d.ts +9 -0
  580. package/dist/types/utils/paths.d.ts.map +1 -0
  581. package/dist/types/utils/purry-on.d.ts +7 -0
  582. package/dist/types/utils/purry-on.d.ts.map +1 -0
  583. package/dist/types/utils/purry-order-rules.d.ts +52 -0
  584. package/dist/types/utils/purry-order-rules.d.ts.map +1 -0
  585. package/dist/types/utils/quick-select.d.ts +18 -0
  586. package/dist/types/utils/quick-select.d.ts.map +1 -0
  587. package/dist/types/utils/reduce-lazy.d.ts +22 -0
  588. package/dist/types/utils/reduce-lazy.d.ts.map +1 -0
  589. package/dist/types/utils/swap-in-place.d.ts +5 -0
  590. package/dist/types/utils/swap-in-place.d.ts.map +1 -0
  591. package/dist/types/utils/to-lazy-indexed.d.ts +4 -0
  592. package/dist/types/utils/to-lazy-indexed.d.ts.map +1 -0
  593. package/dist/types/utils/to-single.d.ts +4 -0
  594. package/dist/types/utils/to-single.d.ts.map +1 -0
  595. package/dist/types/utils/types.d.ts +32 -0
  596. package/dist/types/utils/types.d.ts.map +1 -0
  597. package/dist/types/utils/with-precision.d.ts +2 -0
  598. package/dist/types/utils/with-precision.d.ts.map +1 -0
  599. package/package.json +35 -24
  600. package/dist/index.cjs +0 -2403
  601. package/dist/index.d.cts +0 -3378
  602. package/dist/index.d.ts +0 -3378
  603. package/dist/index.js +0 -2260
  604. package/dist/index.min.js +0 -2
  605. package/dist/index.min.js.map +0 -7
package/dist/index.js DELETED
@@ -1,2260 +0,0 @@
1
- // src/aria/key-codes.ts
2
- var KEY_CODES = {
3
- ALT: "Alt",
4
- ARROW_DOWN: "ArrowDown",
5
- ARROW_LEFT: "ArrowLeft",
6
- ARROW_RIGHT: "ArrowRight",
7
- ARROW_UP: "ArrowUp",
8
- AT: "@",
9
- BACKSPACE: "Backspace",
10
- CTRL: "Control",
11
- DELETE: "Delete",
12
- END: "End",
13
- ENTER: "Enter",
14
- ESC: "Escape",
15
- HOME: "Home",
16
- KEY_F: "KEY_F",
17
- META: "Meta",
18
- PAGE_DOWN: "PageDown",
19
- PAGE_UP: "PageUp",
20
- SHIFT: "Shift",
21
- SPACE: "Space",
22
- TAB: "Tab"
23
- };
24
-
25
- // src/function/pipe.ts
26
- function pipe(value, ...operations) {
27
- let ret = value;
28
- const lazyOps = operations.map((op) => {
29
- const { lazy, lazyArgs } = op;
30
- if (lazy) {
31
- const fn = lazy(...lazyArgs || []);
32
- fn.indexed = lazy.indexed;
33
- fn.single = lazy.single;
34
- fn.index = 0;
35
- fn.items = [];
36
- return fn;
37
- }
38
- return null;
39
- });
40
- let opIdx = 0;
41
- while (opIdx < operations.length) {
42
- const op = operations[opIdx];
43
- const lazyOp = lazyOps[opIdx];
44
- if (!lazyOp) {
45
- ret = op(ret);
46
- opIdx++;
47
- continue;
48
- }
49
- const lazySeq = [];
50
- for (let j = opIdx; j < operations.length; j++) {
51
- if (lazyOps[j]) {
52
- lazySeq.push(lazyOps[j]);
53
- if (lazyOps[j].single) {
54
- break;
55
- }
56
- } else {
57
- break;
58
- }
59
- }
60
- const acc = [];
61
- for (const item of ret) {
62
- if (_processItem({ acc, item, lazySeq })) {
63
- break;
64
- }
65
- }
66
- const lastLazySeq = lazySeq[lazySeq.length - 1];
67
- if (lastLazySeq.single) {
68
- ret = acc[0];
69
- } else {
70
- ret = acc;
71
- }
72
- opIdx += lazySeq.length;
73
- }
74
- return ret;
75
- }
76
- function _processItem({
77
- acc,
78
- item,
79
- lazySeq
80
- }) {
81
- if (lazySeq.length === 0) {
82
- acc.push(item);
83
- return false;
84
- }
85
- let lazyResult = { done: false, hasNext: false };
86
- let isDone = false;
87
- for (let i = 0; i < lazySeq.length; i++) {
88
- const lazyFn = lazySeq[i];
89
- const indexed = lazyFn.indexed;
90
- const index = lazyFn.index;
91
- const items = lazyFn.items;
92
- items.push(item);
93
- lazyResult = indexed ? lazyFn(item, index, items) : lazyFn(item);
94
- lazyFn.index++;
95
- if (lazyResult.hasNext) {
96
- if (lazyResult.hasMany) {
97
- const nextValues = lazyResult.next;
98
- for (const subItem of nextValues) {
99
- const subResult = _processItem({
100
- acc,
101
- item: subItem,
102
- lazySeq: lazySeq.slice(i + 1)
103
- });
104
- if (subResult) {
105
- return true;
106
- }
107
- }
108
- return false;
109
- } else {
110
- item = lazyResult.next;
111
- }
112
- }
113
- if (!lazyResult.hasNext) {
114
- break;
115
- }
116
- if (lazyResult.done) {
117
- isDone = true;
118
- }
119
- }
120
- if (lazyResult.hasNext) {
121
- acc.push(item);
122
- }
123
- return !!isDone;
124
- }
125
-
126
- // src/function/create-pipe.ts
127
- function createPipe(...operations) {
128
- return (value) => pipe(value, ...operations);
129
- }
130
-
131
- // src/function/identity.ts
132
- function identity(value) {
133
- return value;
134
- }
135
-
136
- // src/function/noop.ts
137
- function noop() {
138
- return void 0;
139
- }
140
-
141
- // src/function/once.ts
142
- function once(fn) {
143
- let called = false;
144
- let ret;
145
- return () => {
146
- if (!called) {
147
- ret = fn();
148
- called = true;
149
- }
150
- return ret;
151
- };
152
- }
153
-
154
- // src/function/debounce.ts
155
- function debounce(func, {
156
- maxWaitMs,
157
- timing = "trailing",
158
- waitMs
159
- }) {
160
- if (maxWaitMs !== void 0 && waitMs !== void 0 && maxWaitMs < waitMs) {
161
- throw new Error(
162
- `debounce: maxWaitMs (${maxWaitMs}) cannot be less than waitMs (${waitMs})`
163
- );
164
- }
165
- let coolDownTimeoutId;
166
- let maxWaitTimeoutId;
167
- let latestCallArgs;
168
- let result;
169
- function handleDebouncedCall(args) {
170
- latestCallArgs = args;
171
- if (maxWaitMs !== void 0 && maxWaitTimeoutId === void 0) {
172
- maxWaitTimeoutId = setTimeout(handleInvoke, maxWaitMs);
173
- }
174
- }
175
- function handleInvoke() {
176
- if (latestCallArgs === void 0) {
177
- return;
178
- }
179
- if (maxWaitTimeoutId !== void 0) {
180
- const timeoutId = maxWaitTimeoutId;
181
- maxWaitTimeoutId = void 0;
182
- clearTimeout(timeoutId);
183
- }
184
- const args = latestCallArgs;
185
- latestCallArgs = void 0;
186
- result = func(...args);
187
- }
188
- function handleCoolDownEnd() {
189
- if (coolDownTimeoutId === void 0) {
190
- return;
191
- }
192
- const timeoutId = coolDownTimeoutId;
193
- coolDownTimeoutId = void 0;
194
- clearTimeout(timeoutId);
195
- if (latestCallArgs !== void 0) {
196
- handleInvoke();
197
- }
198
- }
199
- return {
200
- get cachedValue() {
201
- return result;
202
- },
203
- call: (...args) => {
204
- if (coolDownTimeoutId === void 0) {
205
- if (timing === "trailing") {
206
- handleDebouncedCall(args);
207
- } else {
208
- result = func(...args);
209
- }
210
- } else {
211
- if (timing !== "leading") {
212
- handleDebouncedCall(args);
213
- }
214
- const timeoutId = coolDownTimeoutId;
215
- coolDownTimeoutId = void 0;
216
- clearTimeout(timeoutId);
217
- }
218
- coolDownTimeoutId = setTimeout(
219
- handleCoolDownEnd,
220
- // If waitMs is not defined but maxWaitMs *is* it means the user is only
221
- // interested in the leaky-bucket nature of the debouncer which is
222
- // achieved by setting waitMs === maxWaitMs. If both are not defined we
223
- // default to 0 which would wait until the end of the execution frame.
224
- waitMs ?? maxWaitMs ?? 0
225
- );
226
- return result;
227
- },
228
- cancel: () => {
229
- if (coolDownTimeoutId !== void 0) {
230
- const timeoutId = coolDownTimeoutId;
231
- coolDownTimeoutId = void 0;
232
- clearTimeout(timeoutId);
233
- }
234
- if (maxWaitTimeoutId !== void 0) {
235
- const timeoutId = maxWaitTimeoutId;
236
- maxWaitTimeoutId = void 0;
237
- clearTimeout(timeoutId);
238
- }
239
- latestCallArgs = void 0;
240
- },
241
- flush: () => {
242
- handleCoolDownEnd();
243
- return result;
244
- },
245
- get isPending() {
246
- return coolDownTimeoutId !== void 0;
247
- }
248
- };
249
- }
250
-
251
- // src/function/purry.ts
252
- function purry(fn, args, lazy) {
253
- const diff = fn.length - args.length;
254
- const arrayArgs = Array.from(args);
255
- if (diff === 0) {
256
- return fn(...arrayArgs);
257
- }
258
- if (diff === 1) {
259
- const ret = (data) => fn(data, ...arrayArgs);
260
- if (lazy || fn.lazy) {
261
- ret.lazy = lazy || fn.lazy;
262
- ret.lazyArgs = args;
263
- }
264
- return ret;
265
- }
266
- throw new Error("Wrong number of arguments");
267
- }
268
-
269
- // src/function/sleep.ts
270
- function sleep(timeout) {
271
- return new Promise((resolve) => {
272
- setTimeout(resolve, timeout);
273
- });
274
- }
275
-
276
- // src/array/all-pass.ts
277
- function allPass(...args) {
278
- return purry(_allPass, args);
279
- }
280
- function _allPass(data, fns) {
281
- return fns.every((fn) => fn(data));
282
- }
283
-
284
- // src/array/any-pass.ts
285
- function anyPass(...args) {
286
- return purry(_anyPass, args);
287
- }
288
- function _anyPass(data, fns) {
289
- return fns.some((fn) => fn(data));
290
- }
291
-
292
- // src/array/chunk.ts
293
- function chunk(...args) {
294
- return purry(_chunk, args);
295
- }
296
- function _chunk(array, size) {
297
- const ret = Array.from({
298
- length: Math.ceil(array.length / size)
299
- });
300
- for (let index = 0; index < ret.length; index += 1) {
301
- ret[index] = array.slice(index * size, (index + 1) * size);
302
- }
303
- return ret;
304
- }
305
-
306
- // src/guard/is-array.ts
307
- function isArray(data) {
308
- return Array.isArray(data);
309
- }
310
-
311
- // src/guard/is-boolean.ts
312
- function isBoolean(data) {
313
- return typeof data === "boolean";
314
- }
315
-
316
- // src/guard/is-date.ts
317
- function isDate(data) {
318
- return data instanceof Date;
319
- }
320
-
321
- // src/guard/is-defined.ts
322
- function isDefined(data) {
323
- return typeof data !== "undefined" && data !== null;
324
- }
325
- ((isDefined2) => {
326
- function strict(data) {
327
- return data !== void 0;
328
- }
329
- isDefined2.strict = strict;
330
- })(isDefined || (isDefined = {}));
331
-
332
- // src/base.ts
333
- function toString(value) {
334
- return Object.prototype.toString.call(value);
335
- }
336
-
337
- // src/guard/is-object.ts
338
- function isObject(data) {
339
- return toString(data) === "[object Object]";
340
- }
341
-
342
- // src/guard/is-string.ts
343
- function isString(data) {
344
- return typeof data === "string";
345
- }
346
-
347
- // src/guard/is-empty.ts
348
- function isEmpty(data) {
349
- if (isArray(data) || isString(data)) {
350
- return data.length === 0;
351
- }
352
- if (isObject(data)) {
353
- for (const _ in data) {
354
- return false;
355
- }
356
- return !(data instanceof RegExp);
357
- }
358
- return false;
359
- }
360
-
361
- // src/guard/is-error.ts
362
- function isError(data) {
363
- return data instanceof Error;
364
- }
365
-
366
- // src/guard/is-function.ts
367
- function isFunction(data) {
368
- return typeof data === "function";
369
- }
370
-
371
- // src/guard/is-nil.ts
372
- function isNil(data) {
373
- return data == null;
374
- }
375
-
376
- // src/guard/is-non-null.ts
377
- function isNonNull(data) {
378
- return data !== null;
379
- }
380
-
381
- // src/guard/is-not.ts
382
- function isNot(predicate) {
383
- return (data) => {
384
- return !predicate(data);
385
- };
386
- }
387
-
388
- // src/guard/is-number.ts
389
- function isNumber(data) {
390
- return typeof data === "number" && !Number.isNaN(data);
391
- }
392
-
393
- // src/guard/is-promise.ts
394
- function isPromise(data) {
395
- return data instanceof Promise;
396
- }
397
-
398
- // src/guard/is-truthy.ts
399
- function isTruthy(data) {
400
- return !!data;
401
- }
402
-
403
- // src/array/compact.ts
404
- function compact(items) {
405
- return items.filter(isTruthy);
406
- }
407
-
408
- // src/array/concat.ts
409
- function concat(...args) {
410
- return purry(_concat, args);
411
- }
412
- function _concat(arr1, arr2) {
413
- return arr1.concat(arr2);
414
- }
415
-
416
- // src/array/count-by.ts
417
- function _countBy(indexed) {
418
- return (array, fn) => {
419
- return array.reduce((ret, item, index) => {
420
- const value = indexed ? fn(item, index, array) : fn(item);
421
- return ret + (value ? 1 : 0);
422
- }, 0);
423
- };
424
- }
425
- function countBy(...args) {
426
- return purry(_countBy(false), args);
427
- }
428
- ((countBy2) => {
429
- function indexed(...args) {
430
- return purry(_countBy(true), args);
431
- }
432
- countBy2.indexed = indexed;
433
- })(countBy || (countBy = {}));
434
-
435
- // src/utils/reduce-lazy.ts
436
- function _reduceLazy(array, lazy, indexed) {
437
- const newArray = [];
438
- for (let index = 0; index < array.length; index++) {
439
- const item = array[index];
440
- const result = indexed ? lazy(item, index, array) : lazy(item);
441
- if (result.hasMany === true) {
442
- newArray.push(...result.next);
443
- } else if (result.hasNext) {
444
- newArray.push(result.next);
445
- }
446
- }
447
- return newArray;
448
- }
449
-
450
- // src/array/difference-with.ts
451
- function differenceWith(...args) {
452
- return purry(_differenceWith, args, differenceWith.lazy);
453
- }
454
- function _differenceWith(array, other, isEquals) {
455
- const lazy = differenceWith.lazy(other, isEquals);
456
- return _reduceLazy(array, lazy);
457
- }
458
- ((differenceWith2) => {
459
- function lazy(other, isEquals) {
460
- return (value) => {
461
- if (other.every((otherValue) => !isEquals(value, otherValue))) {
462
- return {
463
- done: false,
464
- hasNext: true,
465
- next: value
466
- };
467
- }
468
- return {
469
- done: false,
470
- hasNext: false
471
- };
472
- };
473
- }
474
- differenceWith2.lazy = lazy;
475
- })(differenceWith || (differenceWith = {}));
476
-
477
- // src/array/difference.ts
478
- function difference(...args) {
479
- return purry(_difference, args, difference.lazy);
480
- }
481
- function _difference(array, other) {
482
- const lazy = difference.lazy(other);
483
- return _reduceLazy(array, lazy);
484
- }
485
- ((difference2) => {
486
- function lazy(other) {
487
- const set2 = new Set(other);
488
- return (value) => {
489
- if (!set2.has(value)) {
490
- return {
491
- done: false,
492
- hasNext: true,
493
- next: value
494
- };
495
- }
496
- return {
497
- done: false,
498
- hasNext: false
499
- };
500
- };
501
- }
502
- difference2.lazy = lazy;
503
- })(difference || (difference = {}));
504
-
505
- // src/array/drop-last.ts
506
- function dropLast(...args) {
507
- return purry(_dropLast, args);
508
- }
509
- function _dropLast(array, n) {
510
- const copy = [...array];
511
- if (n > 0) {
512
- copy.splice(-n);
513
- }
514
- return copy;
515
- }
516
-
517
- // src/array/drop.ts
518
- function drop(...args) {
519
- return purry(_drop, args, drop.lazy);
520
- }
521
- function _drop(array, n) {
522
- return _reduceLazy(array, drop.lazy(n));
523
- }
524
- ((drop2) => {
525
- function lazy(n) {
526
- let left = n;
527
- return (value) => {
528
- if (left > 0) {
529
- left--;
530
- return {
531
- done: false,
532
- hasNext: false
533
- };
534
- }
535
- return {
536
- done: false,
537
- hasNext: true,
538
- next: value
539
- };
540
- };
541
- }
542
- drop2.lazy = lazy;
543
- })(drop || (drop = {}));
544
-
545
- // src/utils/to-lazy-indexed.ts
546
- function toLazyIndexed(fn) {
547
- fn.indexed = true;
548
- return fn;
549
- }
550
-
551
- // src/array/filter.ts
552
- function filter(...args) {
553
- return purry(_filter(false), args, filter.lazy);
554
- }
555
- function _filter(indexed) {
556
- return (array, fn) => {
557
- return _reduceLazy(
558
- array,
559
- indexed ? filter.lazyIndexed(fn) : filter.lazy(fn),
560
- indexed
561
- );
562
- };
563
- }
564
- function _lazy(indexed) {
565
- return (fn) => {
566
- return (value, index, array) => {
567
- const valid = indexed ? fn(value, index, array) : fn(value);
568
- if (valid) {
569
- return {
570
- done: false,
571
- hasNext: true,
572
- next: value
573
- };
574
- }
575
- return {
576
- done: false,
577
- hasNext: false
578
- };
579
- };
580
- };
581
- }
582
- ((filter2) => {
583
- function indexed(...args) {
584
- return purry(_filter(true), args, filter2.lazyIndexed);
585
- }
586
- filter2.indexed = indexed;
587
- filter2.lazy = _lazy(false);
588
- filter2.lazyIndexed = toLazyIndexed(_lazy(true));
589
- })(filter || (filter = {}));
590
-
591
- // src/utils/to-single.ts
592
- function toSingle(fn) {
593
- fn.single = true;
594
- return fn;
595
- }
596
-
597
- // src/array/find-index.ts
598
- function findIndex(...args) {
599
- return purry(_findIndex(false), args, findIndex.lazy);
600
- }
601
- function _findIndex(indexed) {
602
- return (array, fn) => {
603
- if (indexed) {
604
- return array.findIndex(fn);
605
- }
606
- return array.findIndex((x) => fn(x));
607
- };
608
- }
609
- function _lazy2(indexed) {
610
- return (fn) => {
611
- let i = 0;
612
- return (value, index, array) => {
613
- const valid = indexed ? fn(value, index, array) : fn(value);
614
- if (valid) {
615
- return {
616
- done: true,
617
- hasNext: true,
618
- next: i
619
- };
620
- }
621
- i++;
622
- return {
623
- done: false,
624
- hasNext: false
625
- };
626
- };
627
- };
628
- }
629
- ((findIndex2) => {
630
- function indexed(...args) {
631
- return purry(_findIndex(true), args, findIndex2.lazyIndexed);
632
- }
633
- findIndex2.indexed = indexed;
634
- findIndex2.lazy = toSingle(_lazy2(false));
635
- findIndex2.lazyIndexed = toSingle(toLazyIndexed(_lazy2(true)));
636
- })(findIndex || (findIndex = {}));
637
-
638
- // src/array/find-last-index.ts
639
- function findLastIndex(...args) {
640
- return purry(_findLastIndex(false), args);
641
- }
642
- function _findLastIndex(indexed) {
643
- return (array, fn) => {
644
- for (let i = array.length - 1; i >= 0; i--) {
645
- if (indexed ? fn(array[i], i, array) : fn(array[i])) {
646
- return i;
647
- }
648
- }
649
- return -1;
650
- };
651
- }
652
- ((findLastIndex2) => {
653
- function indexed(...args) {
654
- return purry(_findLastIndex(true), args);
655
- }
656
- findLastIndex2.indexed = indexed;
657
- })(findLastIndex || (findLastIndex = {}));
658
-
659
- // src/array/find-last.ts
660
- function findLast(...args) {
661
- return purry(_findLast(false), args);
662
- }
663
- function _findLast(indexed) {
664
- return (array, fn) => {
665
- for (let i = array.length - 1; i >= 0; i--) {
666
- if (indexed ? fn(array[i], i, array) : fn(array[i])) {
667
- return array[i];
668
- }
669
- }
670
- };
671
- }
672
- ((findLast2) => {
673
- function indexed(...args) {
674
- return purry(_findLast(true), args);
675
- }
676
- findLast2.indexed = indexed;
677
- })(findLast || (findLast = {}));
678
-
679
- // src/array/find.ts
680
- function find(...args) {
681
- return purry(_find(false), args, find.lazy);
682
- }
683
- function _find(indexed) {
684
- return (array, fn) => {
685
- if (indexed) {
686
- return array.find(fn);
687
- }
688
- return array.find((x) => fn(x));
689
- };
690
- }
691
- function _lazy3(indexed) {
692
- return (fn) => {
693
- return (value, index, array) => {
694
- const valid = indexed ? fn(value, index, array) : fn(value);
695
- return {
696
- done: valid,
697
- hasNext: valid,
698
- next: value
699
- };
700
- };
701
- };
702
- }
703
- ((find2) => {
704
- function indexed(...args) {
705
- return purry(_find(true), args, find2.lazyIndexed);
706
- }
707
- find2.indexed = indexed;
708
- find2.lazy = toSingle(_lazy3(false));
709
- find2.lazyIndexed = toSingle(toLazyIndexed(_lazy3(true)));
710
- })(find || (find = {}));
711
-
712
- // src/array/first.ts
713
- function first(...args) {
714
- return purry(_first, args, first.lazy);
715
- }
716
- function _first([first2]) {
717
- return first2;
718
- }
719
- ((first2) => {
720
- function lazy() {
721
- return (value) => {
722
- return {
723
- done: true,
724
- hasNext: true,
725
- next: value
726
- };
727
- };
728
- }
729
- first2.lazy = lazy;
730
- ((lazy2) => {
731
- lazy2.single = true;
732
- })(lazy = first2.lazy || (first2.lazy = {}));
733
- })(first || (first = {}));
734
-
735
- // src/array/flat-map-to-obj.ts
736
- function flatMapToObj(...args) {
737
- return purry(_flatMapToObj(false), args);
738
- }
739
- function _flatMapToObj(indexed) {
740
- return (array, fn) => {
741
- return array.reduce((result, element, index) => {
742
- const items = indexed ? fn(element, index, array) : fn(element);
743
- items.forEach(([key, value]) => {
744
- result[key] = value;
745
- });
746
- return result;
747
- }, {});
748
- };
749
- }
750
- ((flatMapToObj2) => {
751
- function indexed(...args) {
752
- return purry(_flatMapToObj(true), args);
753
- }
754
- flatMapToObj2.indexed = indexed;
755
- })(flatMapToObj || (flatMapToObj = {}));
756
-
757
- // src/array/flatten.ts
758
- function flatten(...args) {
759
- return purry(_flatten, args, flatten.lazy);
760
- }
761
- function _flatten(items) {
762
- return _reduceLazy(items, flatten.lazy());
763
- }
764
- ((flatten2) => {
765
- function lazy() {
766
- return (next) => {
767
- if (Array.isArray(next)) {
768
- return {
769
- done: false,
770
- hasMany: true,
771
- hasNext: true,
772
- next
773
- };
774
- }
775
- return {
776
- done: false,
777
- hasNext: true,
778
- next
779
- };
780
- };
781
- }
782
- flatten2.lazy = lazy;
783
- })(flatten || (flatten = {}));
784
-
785
- // src/array/flat-map.ts
786
- function flatMap(...args) {
787
- return purry(_flatMap, args, flatMap.lazy);
788
- }
789
- function _flatMap(array, fn) {
790
- return flatten(array.map((item) => fn(item)));
791
- }
792
- ((flatMap2) => {
793
- function lazy(fn) {
794
- return (value) => {
795
- const next = fn(value);
796
- if (Array.isArray(next)) {
797
- return {
798
- done: false,
799
- hasMany: true,
800
- hasNext: true,
801
- next
802
- };
803
- }
804
- return {
805
- done: false,
806
- hasNext: true,
807
- next
808
- };
809
- };
810
- }
811
- flatMap2.lazy = lazy;
812
- })(flatMap || (flatMap = {}));
813
-
814
- // src/array/flatten-deep.ts
815
- function flattenDeep(...args) {
816
- return purry(_flattenDeep, args, flattenDeep.lazy);
817
- }
818
- function _flattenDeep(items) {
819
- return _reduceLazy(items, flattenDeep.lazy());
820
- }
821
- function _flattenDeepValue(value) {
822
- if (!Array.isArray(value)) {
823
- return value;
824
- }
825
- const ret = [];
826
- value.forEach((item) => {
827
- if (Array.isArray(item)) {
828
- ret.push(...flattenDeep(item));
829
- } else {
830
- ret.push(item);
831
- }
832
- });
833
- return ret;
834
- }
835
- ((flattenDeep2) => {
836
- function lazy() {
837
- return (value) => {
838
- const next = _flattenDeepValue(value);
839
- if (Array.isArray(next)) {
840
- return {
841
- done: false,
842
- hasMany: true,
843
- hasNext: true,
844
- next
845
- };
846
- }
847
- return {
848
- done: false,
849
- hasNext: true,
850
- next
851
- };
852
- };
853
- }
854
- flattenDeep2.lazy = lazy;
855
- })(flattenDeep || (flattenDeep = {}));
856
-
857
- // src/array/for-each.ts
858
- function forEach(...args) {
859
- return purry(_forEach(false), args, forEach.lazy);
860
- }
861
- function _forEach(indexed) {
862
- return (array, fn) => {
863
- return _reduceLazy(
864
- array,
865
- indexed ? forEach.lazyIndexed(fn) : forEach.lazy(fn),
866
- indexed
867
- );
868
- };
869
- }
870
- function _lazy4(indexed) {
871
- return (fn) => {
872
- return (value, index, array) => {
873
- if (indexed) {
874
- fn(value, index, array);
875
- } else {
876
- fn(value);
877
- }
878
- return {
879
- done: false,
880
- hasNext: true,
881
- next: value
882
- };
883
- };
884
- };
885
- }
886
- ((forEach2) => {
887
- function indexed(...args) {
888
- return purry(_forEach(true), args, forEach2.lazyIndexed);
889
- }
890
- forEach2.indexed = indexed;
891
- forEach2.lazy = _lazy4(false);
892
- forEach2.lazyIndexed = toLazyIndexed(_lazy4(true));
893
- })(forEach || (forEach = {}));
894
-
895
- // src/array/group-by.ts
896
- function groupBy(...args) {
897
- return purry(_groupBy(false), args);
898
- }
899
- function _groupBy(indexed) {
900
- return (array, fn) => {
901
- const ret = {};
902
- array.forEach((item, index) => {
903
- const key = indexed ? fn(item, index, array) : fn(item);
904
- if (key !== void 0) {
905
- const actualKey = String(key);
906
- if (!ret[actualKey]) {
907
- ret[actualKey] = [];
908
- }
909
- ret[actualKey].push(item);
910
- }
911
- });
912
- return ret;
913
- };
914
- }
915
- ((groupBy2) => {
916
- function indexed(...args) {
917
- return purry(_groupBy(true), args);
918
- }
919
- groupBy2.indexed = indexed;
920
- groupBy2.strict = groupBy2;
921
- })(groupBy || (groupBy = {}));
922
-
923
- // src/array/index-by.ts
924
- function indexBy(...args) {
925
- return purry(_indexBy(false), args);
926
- }
927
- function _indexBy(indexed) {
928
- return (array, fn) => {
929
- return array.reduce((ret, item, index) => {
930
- const value = indexed ? fn(item, index, array) : fn(item);
931
- const key = String(value);
932
- ret[key] = item;
933
- return ret;
934
- }, {});
935
- };
936
- }
937
- ((indexBy2) => {
938
- function indexed(...args) {
939
- return purry(_indexBy(true), args);
940
- }
941
- indexBy2.indexed = indexed;
942
- })(indexBy || (indexBy = {}));
943
-
944
- // src/array/intersection.ts
945
- function intersection(...args) {
946
- return purry(_intersection, args, intersection.lazy);
947
- }
948
- function _intersection(array, other) {
949
- const lazy = intersection.lazy(other);
950
- return _reduceLazy(array, lazy);
951
- }
952
- ((intersection2) => {
953
- function lazy(other) {
954
- return (value) => {
955
- const set2 = new Set(other);
956
- if (set2.has(value)) {
957
- return {
958
- done: false,
959
- hasNext: true,
960
- next: value
961
- };
962
- }
963
- return {
964
- done: false,
965
- hasNext: false
966
- };
967
- };
968
- }
969
- intersection2.lazy = lazy;
970
- })(intersection || (intersection = {}));
971
-
972
- // src/array/intersection-with.ts
973
- function intersectionWith(...args) {
974
- return purry(_intersectionWith, args, intersectionWith.lazy);
975
- }
976
- function _intersectionWith(array, other, comparator) {
977
- const lazy = intersectionWith.lazy(other, comparator);
978
- return _reduceLazy(array, lazy);
979
- }
980
- ((intersectionWith2) => {
981
- function lazy(other, comparator) {
982
- return (value) => {
983
- if (other.some((otherValue) => comparator(value, otherValue))) {
984
- return {
985
- done: false,
986
- hasNext: true,
987
- next: value
988
- };
989
- }
990
- return {
991
- done: false,
992
- hasNext: false
993
- };
994
- };
995
- }
996
- intersectionWith2.lazy = lazy;
997
- })(intersectionWith || (intersectionWith = {}));
998
-
999
- // src/array/join.ts
1000
- function join(...args) {
1001
- return purry(joinImplementation, args);
1002
- }
1003
- function joinImplementation(data, glue) {
1004
- return data.join(glue);
1005
- }
1006
-
1007
- // src/array/last.ts
1008
- function last(...args) {
1009
- return purry(_last, args);
1010
- }
1011
- function _last(array) {
1012
- return array[array.length - 1];
1013
- }
1014
-
1015
- // src/array/length.ts
1016
- function length(...args) {
1017
- return purry(_length, args);
1018
- }
1019
- function _length(items) {
1020
- return "length" in items ? items.length : Array.from(items).length;
1021
- }
1022
-
1023
- // src/array/map.ts
1024
- function map(...args) {
1025
- return purry(_map(false), args, map.lazy);
1026
- }
1027
- function _map(indexed) {
1028
- return (array, fn) => {
1029
- return _reduceLazy(
1030
- array,
1031
- indexed ? map.lazyIndexed(fn) : map.lazy(fn),
1032
- indexed
1033
- );
1034
- };
1035
- }
1036
- function _lazy5(indexed) {
1037
- return (fn) => {
1038
- return (value, index, array) => {
1039
- return {
1040
- done: false,
1041
- hasNext: true,
1042
- next: indexed ? fn(value, index, array) : fn(value)
1043
- };
1044
- };
1045
- };
1046
- }
1047
- ((map2) => {
1048
- function indexed(...args) {
1049
- return purry(_map(true), args, map2.lazyIndexed);
1050
- }
1051
- map2.indexed = indexed;
1052
- map2.lazy = _lazy5(false);
1053
- map2.lazyIndexed = toLazyIndexed(_lazy5(true));
1054
- map2.strict = map2;
1055
- })(map || (map = {}));
1056
-
1057
- // src/array/map-to-obj.ts
1058
- function mapToObj(...args) {
1059
- return purry(_mapToObj(false), args);
1060
- }
1061
- function _mapToObj(indexed) {
1062
- return (array, fn) => {
1063
- return array.reduce((result, element, index) => {
1064
- const [key, value] = indexed ? fn(element, index, array) : fn(element);
1065
- result[key] = value;
1066
- return result;
1067
- }, {});
1068
- };
1069
- }
1070
- ((mapToObj2) => {
1071
- function indexed(...args) {
1072
- return purry(_mapToObj(true), args);
1073
- }
1074
- mapToObj2.indexed = indexed;
1075
- })(mapToObj || (mapToObj = {}));
1076
-
1077
- // src/array/max-by.ts
1078
- function _maxBy(indexed) {
1079
- return (array, fn) => {
1080
- let ret;
1081
- let retMax;
1082
- array.forEach((item, i) => {
1083
- const max = indexed ? fn(item, i, array) : fn(item);
1084
- if (retMax === void 0 || max > retMax) {
1085
- ret = item;
1086
- retMax = max;
1087
- }
1088
- });
1089
- return ret;
1090
- };
1091
- }
1092
- function maxBy(...args) {
1093
- return purry(_maxBy(false), args);
1094
- }
1095
- ((maxBy2) => {
1096
- function indexed(...args) {
1097
- return purry(_maxBy(true), args);
1098
- }
1099
- maxBy2.indexed = indexed;
1100
- })(maxBy || (maxBy = {}));
1101
-
1102
- // src/array/mean-by.ts
1103
- function _meanBy(indexed) {
1104
- return (array, fn) => {
1105
- if (array.length === 0) {
1106
- return Number.NaN;
1107
- }
1108
- let sum = 0;
1109
- array.forEach((item, i) => {
1110
- sum += indexed ? fn(item, i, array) : fn(item);
1111
- });
1112
- return sum / array.length;
1113
- };
1114
- }
1115
- function meanBy(...args) {
1116
- return purry(_meanBy(false), args);
1117
- }
1118
- ((meanBy2) => {
1119
- function indexed(...args) {
1120
- return purry(_meanBy(true), args);
1121
- }
1122
- meanBy2.indexed = indexed;
1123
- })(meanBy || (meanBy = {}));
1124
-
1125
- // src/array/merge-all.ts
1126
- function mergeAll(items) {
1127
- return items.reduce((acc, x) => ({ ...acc, ...x }), {});
1128
- }
1129
-
1130
- // src/array/min-by.ts
1131
- function _minBy(indexed) {
1132
- return (array, fn) => {
1133
- let ret;
1134
- let retMin;
1135
- array.forEach((item, i) => {
1136
- const min = indexed ? fn(item, i, array) : fn(item);
1137
- if (retMin === void 0 || min < retMin) {
1138
- ret = item;
1139
- retMin = min;
1140
- }
1141
- });
1142
- return ret;
1143
- };
1144
- }
1145
- function minBy(...args) {
1146
- return purry(_minBy(false), args);
1147
- }
1148
- ((minBy2) => {
1149
- function indexed(...args) {
1150
- return purry(_minBy(true), args);
1151
- }
1152
- minBy2.indexed = indexed;
1153
- })(minBy || (minBy = {}));
1154
-
1155
- // src/array/partition.ts
1156
- function partition(...args) {
1157
- return purry(_partition(false), args);
1158
- }
1159
- function _partition(indexed) {
1160
- return (array, fn) => {
1161
- const ret = [[], []];
1162
- array.forEach((item, index) => {
1163
- const matches = indexed ? fn(item, index, array) : fn(item);
1164
- ret[matches ? 0 : 1].push(item);
1165
- });
1166
- return ret;
1167
- };
1168
- }
1169
- ((partition2) => {
1170
- function indexed(...args) {
1171
- return purry(_partition(true), args);
1172
- }
1173
- partition2.indexed = indexed;
1174
- })(partition || (partition = {}));
1175
-
1176
- // src/array/range.ts
1177
- function range(...args) {
1178
- return purry(_range, args);
1179
- }
1180
- function _range(start, end) {
1181
- const ret = [];
1182
- for (let i = start; i < end; i++) {
1183
- ret.push(i);
1184
- }
1185
- return ret;
1186
- }
1187
-
1188
- // src/array/reduce.ts
1189
- function reduce(...args) {
1190
- return purry(_reduce(false), args);
1191
- }
1192
- function _reduce(indexed) {
1193
- return (items, fn, initialValue) => {
1194
- return items.reduce(
1195
- (acc, item, index) => indexed ? fn(acc, item, index, items) : fn(acc, item),
1196
- initialValue
1197
- );
1198
- };
1199
- }
1200
- ((reduce2) => {
1201
- function indexed(...args) {
1202
- return purry(_reduce(true), args);
1203
- }
1204
- reduce2.indexed = indexed;
1205
- })(reduce || (reduce = {}));
1206
-
1207
- // src/array/reject.ts
1208
- function reject(...args) {
1209
- return purry(_reject(false), args, reject.lazy);
1210
- }
1211
- function _reject(indexed) {
1212
- return (array, fn) => {
1213
- return _reduceLazy(
1214
- array,
1215
- indexed ? reject.lazyIndexed(fn) : reject.lazy(fn),
1216
- indexed
1217
- );
1218
- };
1219
- }
1220
- function _lazy6(indexed) {
1221
- return (fn) => {
1222
- return (value, index, array) => {
1223
- const valid = indexed ? fn(value, index, array) : fn(value);
1224
- if (!valid) {
1225
- return {
1226
- done: false,
1227
- hasNext: true,
1228
- next: value
1229
- };
1230
- }
1231
- return {
1232
- done: false,
1233
- hasNext: false
1234
- };
1235
- };
1236
- };
1237
- }
1238
- ((reject2) => {
1239
- function indexed(...args) {
1240
- return purry(_reject(true), args, reject2.lazyIndexed);
1241
- }
1242
- reject2.indexed = indexed;
1243
- reject2.lazy = _lazy6(false);
1244
- reject2.lazyIndexed = toLazyIndexed(_lazy6(true));
1245
- })(reject || (reject = {}));
1246
-
1247
- // src/array/reverse.ts
1248
- function reverse(...args) {
1249
- return purry(_reverse, args);
1250
- }
1251
- function _reverse(array) {
1252
- return array.slice().reverse();
1253
- }
1254
-
1255
- // src/array/sample.ts
1256
- function sample(...args) {
1257
- return purry(sampleImplementation, args);
1258
- }
1259
- function sampleImplementation(data, sampleSize) {
1260
- if (sampleSize < 0) {
1261
- throw new RangeError(`sampleSize must cannot be negative: ${sampleSize}`);
1262
- }
1263
- if (!Number.isInteger(sampleSize)) {
1264
- throw new TypeError(`sampleSize must be an integer: ${sampleSize}`);
1265
- }
1266
- if (sampleSize >= data.length) {
1267
- return data;
1268
- }
1269
- if (sampleSize === 0) {
1270
- return [];
1271
- }
1272
- const actualSampleSize = Math.min(sampleSize, data.length - sampleSize);
1273
- const sampleIndices = /* @__PURE__ */ new Set();
1274
- while (sampleIndices.size < actualSampleSize) {
1275
- const randomIndex = Math.floor(Math.random() * data.length);
1276
- sampleIndices.add(randomIndex);
1277
- }
1278
- if (sampleSize === actualSampleSize) {
1279
- return Array.from(sampleIndices).sort((a, b) => a - b).map((index) => data[index]);
1280
- }
1281
- return data.filter((_, index) => !sampleIndices.has(index));
1282
- }
1283
-
1284
- // src/array/shuffle.ts
1285
- function shuffle(...args) {
1286
- return purry(_shuffle, args);
1287
- }
1288
- function _shuffle(items) {
1289
- const result = items.slice();
1290
- for (let index = 0; index < items.length; index += 1) {
1291
- const rand = index + Math.floor(Math.random() * (items.length - index));
1292
- const value = result[rand];
1293
- result[rand] = result[index];
1294
- result[index] = value;
1295
- }
1296
- return result;
1297
- }
1298
-
1299
- // src/array/sort.ts
1300
- function sort(...args) {
1301
- return purry(_sort, args);
1302
- }
1303
- function _sort(items, cmp) {
1304
- const ret = [...items];
1305
- ret.sort(cmp);
1306
- return ret;
1307
- }
1308
- ((sort2) => {
1309
- sort2.strict = sort2;
1310
- })(sort || (sort = {}));
1311
-
1312
- // src/array/sort-by.ts
1313
- var ALL_DIRECTIONS = ["asc", "desc"];
1314
- var COMPARATOR = {
1315
- asc: (x, y) => x > y,
1316
- desc: (x, y) => x < y
1317
- };
1318
- function sortBy(arrayOrSortRule, ...sortRules) {
1319
- const args = isSortRule(arrayOrSortRule) ? [[arrayOrSortRule, ...sortRules]] : [arrayOrSortRule, sortRules];
1320
- return purry(_sortBy, args);
1321
- }
1322
- function isSortRule(x) {
1323
- if (typeof x === "function") {
1324
- return true;
1325
- }
1326
- const [maybeProjection, maybeDirection, ...rest] = x;
1327
- if (rest.length > 0) {
1328
- return false;
1329
- }
1330
- return typeof maybeProjection === "function" && ALL_DIRECTIONS.includes(maybeDirection);
1331
- }
1332
- function _sortBy(array, sorts) {
1333
- return [...array].sort(comparer(...sorts));
1334
- }
1335
- function comparer(primaryRule, secondaryRule, ...otherRules) {
1336
- const projector = typeof primaryRule === "function" ? primaryRule : primaryRule[0];
1337
- const direction = typeof primaryRule === "function" ? "asc" : primaryRule[1];
1338
- const comparator = COMPARATOR[direction];
1339
- const nextComparer = secondaryRule === void 0 ? void 0 : comparer(secondaryRule, ...otherRules);
1340
- return (a, b) => {
1341
- const projectedA = projector(a);
1342
- const projectedB = projector(b);
1343
- if (comparator(projectedA, projectedB)) {
1344
- return 1;
1345
- }
1346
- if (comparator(projectedB, projectedA)) {
1347
- return -1;
1348
- }
1349
- return nextComparer?.(a, b) ?? 0;
1350
- };
1351
- }
1352
- ((sortBy2) => {
1353
- sortBy2.strict = sortBy2;
1354
- })(sortBy || (sortBy = {}));
1355
-
1356
- // src/array/split-at.ts
1357
- function splitAt(...args) {
1358
- return purry(_splitAt, args);
1359
- }
1360
- function _splitAt(array, index) {
1361
- const copy = [...array];
1362
- const tail = copy.splice(index);
1363
- return [copy, tail];
1364
- }
1365
-
1366
- // src/array/split-when.ts
1367
- function splitWhen(...args) {
1368
- return purry(_splitWhen, args);
1369
- }
1370
- function _splitWhen(array, fn) {
1371
- for (let i = 0; i < array.length; i++) {
1372
- if (fn(array[i])) {
1373
- return splitAt(array, i);
1374
- }
1375
- }
1376
- return [array, []];
1377
- }
1378
-
1379
- // src/array/sum-by.ts
1380
- function _sumBy(indexed) {
1381
- return (array, fn) => {
1382
- let sum = 0;
1383
- array.forEach((item, i) => {
1384
- const summand = indexed ? fn(item, i, array) : fn(item);
1385
- sum += summand;
1386
- });
1387
- return sum;
1388
- };
1389
- }
1390
- function sumBy(...args) {
1391
- return purry(_sumBy(false), args);
1392
- }
1393
- ((sumBy2) => {
1394
- function indexed(...args) {
1395
- return purry(_sumBy(true), args);
1396
- }
1397
- sumBy2.indexed = indexed;
1398
- })(sumBy || (sumBy = {}));
1399
-
1400
- // src/array/swap-indices.ts
1401
- function swapIndices(...args) {
1402
- return purry(_swapIndices, args);
1403
- }
1404
- function _swapIndices(item, index1, index2) {
1405
- return typeof item === "string" ? _swapString(item, index1, index2) : _swapArray(item, index1, index2);
1406
- }
1407
- function _swapArray(item, index1, index2) {
1408
- const result = item.slice();
1409
- if (Number.isNaN(index1) || Number.isNaN(index2)) {
1410
- return result;
1411
- }
1412
- const positiveIndexA = index1 < 0 ? item.length + index1 : index1;
1413
- const positiveIndexB = index2 < 0 ? item.length + index2 : index2;
1414
- if (positiveIndexA < 0 || positiveIndexA > item.length) {
1415
- return result;
1416
- }
1417
- if (positiveIndexB < 0 || positiveIndexB > item.length) {
1418
- return result;
1419
- }
1420
- result[positiveIndexA] = item[positiveIndexB];
1421
- result[positiveIndexB] = item[positiveIndexA];
1422
- return result;
1423
- }
1424
- function _swapString(item, index1, index2) {
1425
- const result = _swapArray(item.split(""), index1, index2);
1426
- return result.join("");
1427
- }
1428
-
1429
- // src/array/take.ts
1430
- function take(...args) {
1431
- return purry(_take, args, take.lazy);
1432
- }
1433
- function _take(array, n) {
1434
- return _reduceLazy(array, take.lazy(n));
1435
- }
1436
- ((take2) => {
1437
- function lazy(n) {
1438
- return (value) => {
1439
- if (n === 0) {
1440
- return {
1441
- done: true,
1442
- hasNext: false
1443
- };
1444
- }
1445
- n--;
1446
- if (n === 0) {
1447
- return {
1448
- done: true,
1449
- hasNext: true,
1450
- next: value
1451
- };
1452
- }
1453
- return {
1454
- done: false,
1455
- hasNext: true,
1456
- next: value
1457
- };
1458
- };
1459
- }
1460
- take2.lazy = lazy;
1461
- })(take || (take = {}));
1462
-
1463
- // src/array/take-while.ts
1464
- function takeWhile(...args) {
1465
- return purry(_takeWhile, args);
1466
- }
1467
- function _takeWhile(array, fn) {
1468
- const ret = [];
1469
- for (const item of array) {
1470
- if (!fn(item)) {
1471
- break;
1472
- }
1473
- ret.push(item);
1474
- }
1475
- return ret;
1476
- }
1477
-
1478
- // src/array/uniq.ts
1479
- function uniq(...args) {
1480
- return purry(_uniq, args, uniq.lazy);
1481
- }
1482
- function _uniq(array) {
1483
- return _reduceLazy(array, uniq.lazy());
1484
- }
1485
- ((uniq2) => {
1486
- function lazy() {
1487
- const set2 = /* @__PURE__ */ new Set();
1488
- return (value) => {
1489
- if (set2.has(value)) {
1490
- return {
1491
- done: false,
1492
- hasNext: false
1493
- };
1494
- }
1495
- set2.add(value);
1496
- return {
1497
- done: false,
1498
- hasNext: true,
1499
- next: value
1500
- };
1501
- };
1502
- }
1503
- uniq2.lazy = lazy;
1504
- })(uniq || (uniq = {}));
1505
-
1506
- // src/array/uniq-by.ts
1507
- function uniqBy(...args) {
1508
- return purry(_uniqBy, args, lazyUniqBy);
1509
- }
1510
- function _uniqBy(array, transformer) {
1511
- return _reduceLazy(array, lazyUniqBy(transformer));
1512
- }
1513
- function lazyUniqBy(transformer) {
1514
- const set2 = /* @__PURE__ */ new Set();
1515
- return (value) => {
1516
- const appliedItem = transformer(value);
1517
- if (set2.has(appliedItem)) {
1518
- return {
1519
- done: false,
1520
- hasNext: false
1521
- };
1522
- }
1523
- set2.add(appliedItem);
1524
- return {
1525
- done: false,
1526
- hasNext: true,
1527
- next: value
1528
- };
1529
- };
1530
- }
1531
-
1532
- // src/array/uniq-with.ts
1533
- function uniqWith(...args) {
1534
- return purry(_uniqWith, args, uniqWith.lazy);
1535
- }
1536
- function _uniqWith(array, isEquals) {
1537
- const lazy = uniqWith.lazy(isEquals);
1538
- return _reduceLazy(array, lazy, true);
1539
- }
1540
- function _lazy7(isEquals) {
1541
- return (value, index, array) => {
1542
- if (array && array.findIndex((otherValue) => isEquals(value, otherValue)) === index) {
1543
- return {
1544
- done: false,
1545
- hasNext: true,
1546
- next: value
1547
- };
1548
- }
1549
- return {
1550
- done: false,
1551
- hasNext: false
1552
- };
1553
- };
1554
- }
1555
- ((uniqWith2) => {
1556
- uniqWith2.lazy = toLazyIndexed(_lazy7);
1557
- })(uniqWith || (uniqWith = {}));
1558
-
1559
- // src/array/zip.ts
1560
- function zip(...args) {
1561
- return purry(_zip, args);
1562
- }
1563
- function _zip(first2, second) {
1564
- const resultLength = first2.length > second.length ? second.length : first2.length;
1565
- const result = [];
1566
- for (let i = 0; i < resultLength; i++) {
1567
- result.push([first2[i], second[i]]);
1568
- }
1569
- return result;
1570
- }
1571
- ((zip2) => {
1572
- zip2.strict = zip2;
1573
- })(zip || (zip = {}));
1574
-
1575
- // src/array/zip-obj.ts
1576
- function zipObj(...args) {
1577
- return purry(_zipObj, args);
1578
- }
1579
- function _zipObj(first2, second) {
1580
- const resultLength = first2.length > second.length ? second.length : first2.length;
1581
- const result = {};
1582
- for (let i = 0; i < resultLength; i++) {
1583
- result[first2[i]] = second[i];
1584
- }
1585
- return result;
1586
- }
1587
-
1588
- // src/array/zip-with.ts
1589
- function zipWith(...args) {
1590
- if (typeof args[0] === "function" && args.length === 1) {
1591
- return function(f, s) {
1592
- return _zipWith(f, s, args[0]);
1593
- };
1594
- }
1595
- if (typeof args[0] === "function" && args.length === 2) {
1596
- return function(f) {
1597
- return _zipWith(f, args[1], args[0]);
1598
- };
1599
- }
1600
- if (args.length === 3) {
1601
- return _zipWith(args[0], args[1], args[2]);
1602
- }
1603
- }
1604
- function _zipWith(first2, second, fn) {
1605
- const resultLength = first2.length > second.length ? second.length : first2.length;
1606
- const result = [];
1607
- for (let i = 0; i < resultLength; i++) {
1608
- result.push(fn(first2[i], second[i]));
1609
- }
1610
- return result;
1611
- }
1612
-
1613
- // src/number/clamp.ts
1614
- function clamp(...args) {
1615
- return purry(_clamp, args);
1616
- }
1617
- function _clamp(value, limits) {
1618
- if (limits.min != null && limits.min > value) {
1619
- return limits.min;
1620
- }
1621
- if (limits.max != null && limits.max < value) {
1622
- return limits.max;
1623
- }
1624
- return value;
1625
- }
1626
-
1627
- // src/object/add-prop.ts
1628
- function addProp(...args) {
1629
- return purry(_addProp, args);
1630
- }
1631
- function _addProp(obj, prop2, value) {
1632
- return {
1633
- ...obj,
1634
- [prop2]: value
1635
- };
1636
- }
1637
-
1638
- // src/type/type.ts
1639
- function type(val) {
1640
- if (val === null) {
1641
- return "Null";
1642
- }
1643
- if (val === void 0) {
1644
- return "Undefined";
1645
- }
1646
- return Object.prototype.toString.call(val).slice(8, -1);
1647
- }
1648
-
1649
- // src/object/clone.ts
1650
- function _cloneRegExp(pattern) {
1651
- return new RegExp(
1652
- pattern.source,
1653
- (pattern.global ? "g" : "") + (pattern.ignoreCase ? "i" : "") + (pattern.multiline ? "m" : "") + (pattern.sticky ? "y" : "") + (pattern.unicode ? "u" : "")
1654
- );
1655
- }
1656
- function _clone(value, refFrom, refTo, deep) {
1657
- function copy(copiedValue) {
1658
- const len = refFrom.length;
1659
- let idx = 0;
1660
- while (idx < len) {
1661
- if (value === refFrom[idx]) {
1662
- return refTo[idx];
1663
- }
1664
- idx += 1;
1665
- }
1666
- refFrom[idx + 1] = value;
1667
- refTo[idx + 1] = copiedValue;
1668
- for (const key in value) {
1669
- copiedValue[key] = deep ? _clone(value[key], refFrom, refTo, true) : value[key];
1670
- }
1671
- return copiedValue;
1672
- }
1673
- switch (type(value)) {
1674
- case "Object":
1675
- return copy({});
1676
- case "Array":
1677
- return copy([]);
1678
- case "Date":
1679
- return new Date(value.valueOf());
1680
- case "RegExp":
1681
- return _cloneRegExp(value);
1682
- default:
1683
- return value;
1684
- }
1685
- }
1686
- function clone(value) {
1687
- return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, [], [], true);
1688
- }
1689
-
1690
- // src/object/equals.ts
1691
- var isArray2 = Array.isArray;
1692
- var keyList = Object.keys;
1693
- function equals(...args) {
1694
- return purry(_equals, args);
1695
- }
1696
- function _equals(a, b) {
1697
- if (a === b) {
1698
- return true;
1699
- }
1700
- if (a && b && typeof a === "object" && typeof b === "object") {
1701
- const arrA = isArray2(a);
1702
- const arrB = isArray2(b);
1703
- let i;
1704
- let length2;
1705
- let key;
1706
- if (arrA && arrB) {
1707
- length2 = a.length;
1708
- if (length2 !== b.length) {
1709
- return false;
1710
- }
1711
- for (i = length2; i-- !== 0; ) {
1712
- if (!equals(a[i], b[i])) {
1713
- return false;
1714
- }
1715
- }
1716
- return true;
1717
- }
1718
- if (arrA !== arrB) {
1719
- return false;
1720
- }
1721
- const dateA = a instanceof Date;
1722
- const dateB = b instanceof Date;
1723
- if (dateA !== dateB) {
1724
- return false;
1725
- }
1726
- if (dateA && dateB) {
1727
- return a.getTime() === b.getTime();
1728
- }
1729
- const regexpA = a instanceof RegExp;
1730
- const regexpB = b instanceof RegExp;
1731
- if (regexpA !== regexpB) {
1732
- return false;
1733
- }
1734
- if (regexpA && regexpB) {
1735
- return a.toString() === b.toString();
1736
- }
1737
- const keys2 = keyList(a);
1738
- length2 = keys2.length;
1739
- if (length2 !== keyList(b).length) {
1740
- return false;
1741
- }
1742
- for (i = length2; i-- !== 0; ) {
1743
- if (!Object.prototype.hasOwnProperty.call(b, keys2[i])) {
1744
- return false;
1745
- }
1746
- }
1747
- for (i = length2; i-- !== 0; ) {
1748
- key = keys2[i];
1749
- if (!equals(a[key], b[key])) {
1750
- return false;
1751
- }
1752
- }
1753
- return true;
1754
- }
1755
- return a !== a && b !== b;
1756
- }
1757
-
1758
- // src/object/for-each-obj.ts
1759
- function forEachObj(...args) {
1760
- return purry(_forEachObj(false), args);
1761
- }
1762
- function _forEachObj(indexed) {
1763
- return (object, fn) => {
1764
- for (const key in object) {
1765
- if (Object.prototype.hasOwnProperty.call(object, key)) {
1766
- const val = object[key];
1767
- if (indexed) {
1768
- fn(val, key, object);
1769
- } else {
1770
- fn(val);
1771
- }
1772
- }
1773
- }
1774
- return object;
1775
- };
1776
- }
1777
- ((forEachObj2) => {
1778
- function indexed(...args) {
1779
- return purry(_forEachObj(true), args);
1780
- }
1781
- forEachObj2.indexed = indexed;
1782
- })(forEachObj || (forEachObj = {}));
1783
-
1784
- // src/object/from-pairs.ts
1785
- function fromPairs(entries) {
1786
- const out = {};
1787
- for (const [key, value] of entries) {
1788
- out[key] = value;
1789
- }
1790
- return out;
1791
- }
1792
- ((fromPairs2) => {
1793
- fromPairs2.strict = fromPairs2;
1794
- })(fromPairs || (fromPairs = {}));
1795
-
1796
- // src/object/invert.ts
1797
- function invert(...args) {
1798
- return purry(_invert, args);
1799
- }
1800
- function _invert(object) {
1801
- const result = {};
1802
- for (const key in object) {
1803
- result[object[key]] = key;
1804
- }
1805
- return result;
1806
- }
1807
-
1808
- // src/object/keys.ts
1809
- function keys(source) {
1810
- return Object.keys(source);
1811
- }
1812
- ((keys2) => {
1813
- keys2.strict = keys2;
1814
- })(keys || (keys = {}));
1815
-
1816
- // src/object/map-keys.ts
1817
- function mapKeys(arg1, arg2) {
1818
- if (arguments.length === 1) {
1819
- return (data) => _mapKeys(data, arg1);
1820
- }
1821
- return _mapKeys(arg1, arg2);
1822
- }
1823
- function _mapKeys(obj, fn) {
1824
- return Object.keys(obj).reduce((acc, key) => {
1825
- acc[fn(key, obj[key])] = obj[key];
1826
- return acc;
1827
- }, {});
1828
- }
1829
-
1830
- // src/object/map-values.ts
1831
- function mapValues(arg1, arg2) {
1832
- if (arguments.length === 1) {
1833
- return (data) => _mapValues(data, arg1);
1834
- }
1835
- return _mapValues(arg1, arg2);
1836
- }
1837
- function _mapValues(obj, fn) {
1838
- return Object.keys(obj).reduce((acc, key) => {
1839
- acc[key] = fn(obj[key], key);
1840
- return acc;
1841
- }, {});
1842
- }
1843
-
1844
- // src/object/merge.ts
1845
- function merge(...args) {
1846
- return purry(_merge, args);
1847
- }
1848
- function _merge(a, b) {
1849
- return Object.assign({}, a, b);
1850
- }
1851
-
1852
- // src/object/merge-deep.ts
1853
- function mergeDeep(...args) {
1854
- return purry(mergeDeepImplementation, args);
1855
- }
1856
- function mergeDeepImplementation(destination, source) {
1857
- const output = { ...destination, ...source };
1858
- for (const key in source) {
1859
- if (!(key in destination)) {
1860
- continue;
1861
- }
1862
- const destinationValue = destination[key];
1863
- if (!isRecord(destinationValue)) {
1864
- continue;
1865
- }
1866
- const sourceValue = source[key];
1867
- if (!isRecord(sourceValue)) {
1868
- continue;
1869
- }
1870
- output[key] = mergeDeepImplementation(destinationValue, sourceValue);
1871
- }
1872
- return output;
1873
- }
1874
- function isRecord(object) {
1875
- return typeof object === "object" && object !== null && Object.getPrototypeOf(object) === Object.prototype;
1876
- }
1877
-
1878
- // src/object/omit.ts
1879
- function omit(...args) {
1880
- return purry(_omit, args);
1881
- }
1882
- function _omit(data, propNames) {
1883
- if (propNames.length === 0) {
1884
- return { ...data };
1885
- }
1886
- if (propNames.length === 1) {
1887
- const [propName] = propNames;
1888
- const {
1889
- [propName]: omitted,
1890
- ...remaining
1891
- } = data;
1892
- return remaining;
1893
- }
1894
- if (!propNames.some((propName) => propName in data)) {
1895
- return { ...data };
1896
- }
1897
- const asSet = new Set(propNames);
1898
- return fromPairs(
1899
- Object.entries(data).filter(([key]) => !asSet.has(key))
1900
- );
1901
- }
1902
-
1903
- // src/object/omit-by.ts
1904
- function omitBy(...args) {
1905
- return purry(_omitBy, args);
1906
- }
1907
- function _omitBy(object, fn) {
1908
- return Object.keys(object).reduce((acc, key) => {
1909
- if (!fn(object[key], key)) {
1910
- acc[key] = object[key];
1911
- }
1912
- return acc;
1913
- }, {});
1914
- }
1915
-
1916
- // src/object/path-or.ts
1917
- function pathOr(...args) {
1918
- return purry(_pathOr, args);
1919
- }
1920
- function _pathOr(object, path, defaultValue) {
1921
- let current = object;
1922
- for (const prop2 of path) {
1923
- if (current == null || current[prop2] == null) {
1924
- return defaultValue;
1925
- }
1926
- current = current[prop2];
1927
- }
1928
- return current;
1929
- }
1930
-
1931
- // src/object/pick.ts
1932
- function pick(...args) {
1933
- return purry(_pick, args);
1934
- }
1935
- function _pick(object, names) {
1936
- if (object == null) {
1937
- return {};
1938
- }
1939
- return names.reduce((acc, name) => {
1940
- if (name in object) {
1941
- acc[name] = object[name];
1942
- }
1943
- return acc;
1944
- }, {});
1945
- }
1946
-
1947
- // src/object/pick-by.ts
1948
- function pickBy(...args) {
1949
- return purry(_pickBy, args);
1950
- }
1951
- function _pickBy(object, fn) {
1952
- if (object == null) {
1953
- return {};
1954
- }
1955
- return Object.keys(object).reduce((acc, key) => {
1956
- if (fn(object[key], key)) {
1957
- acc[key] = object[key];
1958
- }
1959
- return acc;
1960
- }, {});
1961
- }
1962
-
1963
- // src/object/prop.ts
1964
- function prop(propName) {
1965
- return ({ [propName]: value }) => value;
1966
- }
1967
-
1968
- // src/object/set.ts
1969
- function set(...args) {
1970
- return purry(_set, args);
1971
- }
1972
- function _set(obj, prop2, value) {
1973
- return {
1974
- ...obj,
1975
- [prop2]: value
1976
- };
1977
- }
1978
-
1979
- // src/object/set-path.ts
1980
- function setPath(...args) {
1981
- return purry(_setPath, args);
1982
- }
1983
- function _setPath(object, path, defaultValue) {
1984
- if (path.length === 0) {
1985
- return defaultValue;
1986
- }
1987
- if (Array.isArray(object)) {
1988
- return object.map((item, index) => {
1989
- if (index === path[0]) {
1990
- return _setPath(item, path.slice(1), defaultValue);
1991
- }
1992
- return item;
1993
- });
1994
- }
1995
- return {
1996
- ...object,
1997
- [path[0]]: _setPath(object[path[0]], path.slice(1), defaultValue)
1998
- };
1999
- }
2000
-
2001
- // src/object/swap-props.ts
2002
- function swapProps(...args) {
2003
- return purry(_swapProps, args);
2004
- }
2005
- function _swapProps(obj, key1, key2) {
2006
- const { [key1]: value1, [key2]: value2 } = obj;
2007
- return {
2008
- ...obj,
2009
- [key1]: value2,
2010
- [key2]: value1
2011
- };
2012
- }
2013
-
2014
- // src/object/to-pairs.ts
2015
- function toPairs(object) {
2016
- return Object.entries(object);
2017
- }
2018
- ((toPairs2) => {
2019
- function strict(object) {
2020
- return Object.entries(object);
2021
- }
2022
- toPairs2.strict = strict;
2023
- })(toPairs || (toPairs = {}));
2024
-
2025
- // src/object/values.ts
2026
- function values(source) {
2027
- return Object.values(source);
2028
- }
2029
-
2030
- // src/string/cases.ts
2031
- var RE_NUMBER_CHAR = /\d/;
2032
- var STR_SPLITTERS = ["-", "_", "/", "."];
2033
- function isUppercase(char = "") {
2034
- if (RE_NUMBER_CHAR.test(char)) {
2035
- return void 0;
2036
- }
2037
- return char.toUpperCase() === char;
2038
- }
2039
- function splitByCase(string_, separators) {
2040
- const splitters = separators ?? STR_SPLITTERS;
2041
- const parts = [];
2042
- if (!string_ || !isString(string_)) {
2043
- return parts;
2044
- }
2045
- let buff = "";
2046
- let previousUpper;
2047
- let previousSplitter;
2048
- for (const char of string_) {
2049
- const isSplitter = splitters.includes(char);
2050
- if (isSplitter === true) {
2051
- parts.push(buff);
2052
- buff = "";
2053
- previousUpper = void 0;
2054
- continue;
2055
- }
2056
- const isUpper = isUppercase(char);
2057
- if (previousSplitter === false) {
2058
- if (previousUpper === false && isUpper === true) {
2059
- parts.push(buff);
2060
- buff = char;
2061
- previousUpper = isUpper;
2062
- continue;
2063
- }
2064
- if (previousUpper === true && isUpper === false && buff.length > 1) {
2065
- const lastChar = buff[buff.length - 1];
2066
- parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
2067
- buff = lastChar + char;
2068
- previousUpper = isUpper;
2069
- continue;
2070
- }
2071
- }
2072
- buff += char;
2073
- previousUpper = isUpper;
2074
- previousSplitter = isSplitter;
2075
- }
2076
- parts.push(buff);
2077
- return parts;
2078
- }
2079
- function toUpperFirst(string_) {
2080
- return !string_ ? "" : string_[0].toUpperCase() + string_.slice(1);
2081
- }
2082
- function toLowerFirst(string_) {
2083
- return !string_ ? "" : string_[0].toLowerCase() + string_.slice(1);
2084
- }
2085
- function toPascalCase(string_) {
2086
- return !string_ ? "" : (Array.isArray(string_) ? string_ : splitByCase(string_)).map((p) => toUpperFirst(p)).join("");
2087
- }
2088
- function toCamelCase(string_) {
2089
- return toLowerFirst(toPascalCase(string_ || ""));
2090
- }
2091
- function toKebabCase(string_, joiner) {
2092
- return !string_ ? "" : (Array.isArray(string_) ? string_ : splitByCase(string_)).map((p) => p.toLowerCase()).join(joiner ?? "-");
2093
- }
2094
- function toSnakeCase(string_) {
2095
- return toKebabCase(string_ || "", "_");
2096
- }
2097
-
2098
- // src/string/human-readable-file-size.ts
2099
- function humanReadableFileSize(bytes, base = 1e3) {
2100
- if (bytes < base) {
2101
- return `${bytes} B`;
2102
- }
2103
- const prefix = base === 1024 ? ["Ki", "Mi", "Gi"] : ["k", "M", "G"];
2104
- let unit = -1;
2105
- while (Math.abs(bytes) >= base && unit < prefix.length - 1) {
2106
- bytes /= base;
2107
- ++unit;
2108
- }
2109
- return `${bytes.toFixed(1)} ${prefix[unit]}B`;
2110
- }
2111
-
2112
- // src/string/random-string.ts
2113
- function randomString(length2) {
2114
- const characterSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
2115
- const randomChar = () => characterSet[Math.floor(Math.random() * characterSet.length)];
2116
- return range(0, length2).reduce((text) => text + randomChar(), "");
2117
- }
2118
-
2119
- // src/string/slugify.ts
2120
- function slugify(str) {
2121
- return str.normalize("NFD").replace(/[\u0300-\u036F]/g, "").toLowerCase().replace(/[^a-z0-9]/g, " ").trim().replace(/\s+/g, "-");
2122
- }
2123
-
2124
- // src/string/string-to-path.ts
2125
- function stringToPath(path) {
2126
- return _stringToPath(path);
2127
- }
2128
- function _stringToPath(path) {
2129
- if (path.length === 0) {
2130
- return [];
2131
- }
2132
- const match = path.match(/^\[(.+?)\](.*)$/) ?? path.match(/^\.?([^.[\]]+)(.*)$/);
2133
- if (match) {
2134
- const [, key, rest] = match;
2135
- return [key, ..._stringToPath(rest)];
2136
- }
2137
- return [path];
2138
- }
2139
-
2140
- // src/index.ts
2141
- var isBrowser = typeof window !== "undefined";
2142
- export {
2143
- KEY_CODES,
2144
- _setPath,
2145
- addProp,
2146
- allPass,
2147
- anyPass,
2148
- chunk,
2149
- clamp,
2150
- clone,
2151
- compact,
2152
- concat,
2153
- countBy,
2154
- createPipe,
2155
- debounce,
2156
- difference,
2157
- differenceWith,
2158
- drop,
2159
- dropLast,
2160
- equals,
2161
- filter,
2162
- find,
2163
- findIndex,
2164
- findLast,
2165
- findLastIndex,
2166
- first,
2167
- flatMap,
2168
- flatMapToObj,
2169
- flatten,
2170
- flattenDeep,
2171
- forEach,
2172
- forEachObj,
2173
- fromPairs,
2174
- groupBy,
2175
- humanReadableFileSize,
2176
- identity,
2177
- indexBy,
2178
- intersection,
2179
- intersectionWith,
2180
- invert,
2181
- isArray,
2182
- isBoolean,
2183
- isBrowser,
2184
- isDate,
2185
- isDefined,
2186
- isEmpty,
2187
- isError,
2188
- isFunction,
2189
- isNil,
2190
- isNonNull,
2191
- isNot,
2192
- isNumber,
2193
- isObject,
2194
- isPromise,
2195
- isString,
2196
- isTruthy,
2197
- isUppercase,
2198
- join,
2199
- keys,
2200
- last,
2201
- length,
2202
- map,
2203
- mapKeys,
2204
- mapToObj,
2205
- mapValues,
2206
- maxBy,
2207
- meanBy,
2208
- merge,
2209
- mergeAll,
2210
- mergeDeep,
2211
- minBy,
2212
- noop,
2213
- omit,
2214
- omitBy,
2215
- once,
2216
- partition,
2217
- pathOr,
2218
- pick,
2219
- pickBy,
2220
- pipe,
2221
- prop,
2222
- purry,
2223
- randomString,
2224
- range,
2225
- reduce,
2226
- reject,
2227
- reverse,
2228
- sample,
2229
- set,
2230
- setPath,
2231
- shuffle,
2232
- sleep,
2233
- slugify,
2234
- sort,
2235
- sortBy,
2236
- splitAt,
2237
- splitByCase,
2238
- splitWhen,
2239
- stringToPath,
2240
- sumBy,
2241
- swapIndices,
2242
- swapProps,
2243
- take,
2244
- takeWhile,
2245
- toCamelCase,
2246
- toKebabCase,
2247
- toLowerFirst,
2248
- toPairs,
2249
- toPascalCase,
2250
- toSnakeCase,
2251
- toUpperFirst,
2252
- type,
2253
- uniq,
2254
- uniqBy,
2255
- uniqWith,
2256
- values,
2257
- zip,
2258
- zipObj,
2259
- zipWith
2260
- };