@vinicunca/perkakas 0.4.1 → 0.4.3

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 (626) hide show
  1. package/dist/index.cjs +2375 -0
  2. package/dist/index.d.cts +4603 -0
  3. package/dist/index.d.mts +4603 -0
  4. package/dist/index.d.ts +4603 -0
  5. package/dist/index.mjs +2231 -0
  6. package/package.json +17 -7
  7. package/dist/commonjs/aria/index.js +0 -17
  8. package/dist/commonjs/aria/key-codes.js +0 -25
  9. package/dist/commonjs/array/all-pass.js +0 -11
  10. package/dist/commonjs/array/any-pass.js +0 -11
  11. package/dist/commonjs/array/chunk.js +0 -17
  12. package/dist/commonjs/array/concat.js +0 -11
  13. package/dist/commonjs/array/difference-with.js +0 -21
  14. package/dist/commonjs/array/drop-first-by.js +0 -26
  15. package/dist/commonjs/array/drop-last-while.js +0 -16
  16. package/dist/commonjs/array/drop-last.js +0 -15
  17. package/dist/commonjs/array/drop-while.js +0 -16
  18. package/dist/commonjs/array/drop.js +0 -25
  19. package/dist/commonjs/array/filter.js +0 -28
  20. package/dist/commonjs/array/find-index.js +0 -33
  21. package/dist/commonjs/array/find-last-index.js +0 -24
  22. package/dist/commonjs/array/find-last.js +0 -24
  23. package/dist/commonjs/array/find.js +0 -26
  24. package/dist/commonjs/array/first-by.js +0 -22
  25. package/dist/commonjs/array/first.js +0 -20
  26. package/dist/commonjs/array/flat-map-to-obj.js +0 -26
  27. package/dist/commonjs/array/flat-map.js +0 -23
  28. package/dist/commonjs/array/flatten-deep.js +0 -38
  29. package/dist/commonjs/array/flatten.js +0 -20
  30. package/dist/commonjs/array/for-each.js +0 -36
  31. package/dist/commonjs/array/group-by.js +0 -33
  32. package/dist/commonjs/array/has-at-least.js +0 -11
  33. package/dist/commonjs/array/index-by.js +0 -37
  34. package/dist/commonjs/array/index.js +0 -81
  35. package/dist/commonjs/array/intersection-with.js +0 -21
  36. package/dist/commonjs/array/join.js +0 -11
  37. package/dist/commonjs/array/last.js +0 -11
  38. package/dist/commonjs/array/length.js +0 -11
  39. package/dist/commonjs/array/map-to-obj.js +0 -24
  40. package/dist/commonjs/array/map.js +0 -31
  41. package/dist/commonjs/array/max-by.js +0 -28
  42. package/dist/commonjs/array/mean-by.js +0 -26
  43. package/dist/commonjs/array/merge-all.js +0 -11
  44. package/dist/commonjs/array/min-by.js +0 -28
  45. package/dist/commonjs/array/nth-by.js +0 -12
  46. package/dist/commonjs/array/only.js +0 -11
  47. package/dist/commonjs/array/partition.js +0 -24
  48. package/dist/commonjs/array/range.js +0 -15
  49. package/dist/commonjs/array/rank-by.js +0 -17
  50. package/dist/commonjs/array/reduce.js +0 -19
  51. package/dist/commonjs/array/reject.js +0 -28
  52. package/dist/commonjs/array/reverse.js +0 -11
  53. package/dist/commonjs/array/sample.js +0 -34
  54. package/dist/commonjs/array/shuffle.js +0 -18
  55. package/dist/commonjs/array/sort-by.js +0 -14
  56. package/dist/commonjs/array/sort.js +0 -16
  57. package/dist/commonjs/array/sorted-index-by.js +0 -19
  58. package/dist/commonjs/array/sorted-index-with.js +0 -15
  59. package/dist/commonjs/array/sorted-index.js +0 -12
  60. package/dist/commonjs/array/sorted-last-index-by.js +0 -19
  61. package/dist/commonjs/array/sorted-last-index.js +0 -12
  62. package/dist/commonjs/array/splice.js +0 -13
  63. package/dist/commonjs/array/split-at.js +0 -13
  64. package/dist/commonjs/array/split-when.js +0 -17
  65. package/dist/commonjs/array/sum-by.js +0 -24
  66. package/dist/commonjs/array/swap-indices.js +0 -34
  67. package/dist/commonjs/array/take-first-by.js +0 -24
  68. package/dist/commonjs/array/take-while.js +0 -18
  69. package/dist/commonjs/array/take.js +0 -25
  70. package/dist/commonjs/array/uniq-by.js +0 -23
  71. package/dist/commonjs/array/uniq-with.js +0 -23
  72. package/dist/commonjs/array/uniq.js +0 -25
  73. package/dist/commonjs/array/zip-obj.js +0 -16
  74. package/dist/commonjs/array/zip-with.js +0 -23
  75. package/dist/commonjs/array/zip.js +0 -19
  76. package/dist/commonjs/function/conditional.js +0 -34
  77. package/dist/commonjs/function/create-pipe.js +0 -8
  78. package/dist/commonjs/function/debounce.js +0 -88
  79. package/dist/commonjs/function/identity.js +0 -7
  80. package/dist/commonjs/function/index.js +0 -26
  81. package/dist/commonjs/function/noop.js +0 -7
  82. package/dist/commonjs/function/once.js +0 -15
  83. package/dist/commonjs/function/pipe.js +0 -100
  84. package/dist/commonjs/function/purry.js +0 -19
  85. package/dist/commonjs/function/sleep.js +0 -9
  86. package/dist/commonjs/function/times.js +0 -18
  87. package/dist/commonjs/guard/has-sub-object.js +0 -20
  88. package/dist/commonjs/guard/index.js +0 -35
  89. package/dist/commonjs/guard/is-array.js +0 -7
  90. package/dist/commonjs/guard/is-boolean.js +0 -7
  91. package/dist/commonjs/guard/is-date.js +0 -7
  92. package/dist/commonjs/guard/is-deep-equal.js +0 -55
  93. package/dist/commonjs/guard/is-defined.js +0 -13
  94. package/dist/commonjs/guard/is-empty.js +0 -19
  95. package/dist/commonjs/guard/is-error.js +0 -7
  96. package/dist/commonjs/guard/is-function.js +0 -7
  97. package/dist/commonjs/guard/is-included-in.js +0 -11
  98. package/dist/commonjs/guard/is-nil.js +0 -7
  99. package/dist/commonjs/guard/is-non-null.js +0 -7
  100. package/dist/commonjs/guard/is-not.js +0 -7
  101. package/dist/commonjs/guard/is-number.js +0 -7
  102. package/dist/commonjs/guard/is-object.js +0 -11
  103. package/dist/commonjs/guard/is-promise.js +0 -7
  104. package/dist/commonjs/guard/is-string.js +0 -7
  105. package/dist/commonjs/guard/is-symbol.js +0 -7
  106. package/dist/commonjs/guard/is-truthy.js +0 -7
  107. package/dist/commonjs/index.js +0 -26
  108. package/dist/commonjs/number/add.js +0 -11
  109. package/dist/commonjs/number/ceil.js +0 -9
  110. package/dist/commonjs/number/clamp.js +0 -17
  111. package/dist/commonjs/number/divide.js +0 -11
  112. package/dist/commonjs/number/floor.js +0 -9
  113. package/dist/commonjs/number/index.js +0 -24
  114. package/dist/commonjs/number/multiply.js +0 -11
  115. package/dist/commonjs/number/round.js +0 -9
  116. package/dist/commonjs/number/subtract.js +0 -11
  117. package/dist/commonjs/object/add-prop.js +0 -14
  118. package/dist/commonjs/object/clone.js +0 -49
  119. package/dist/commonjs/object/for-each-obj.js +0 -30
  120. package/dist/commonjs/object/from-keys.js +0 -15
  121. package/dist/commonjs/object/from-pairs.js +0 -18
  122. package/dist/commonjs/object/index.js +0 -39
  123. package/dist/commonjs/object/invert.js +0 -17
  124. package/dist/commonjs/object/keys.js +0 -11
  125. package/dist/commonjs/object/map-keys.js +0 -16
  126. package/dist/commonjs/object/map-values.js +0 -16
  127. package/dist/commonjs/object/merge-deep.js +0 -31
  128. package/dist/commonjs/object/merge.js +0 -11
  129. package/dist/commonjs/object/omit-by.js +0 -22
  130. package/dist/commonjs/object/omit.js +0 -25
  131. package/dist/commonjs/object/path-or.js +0 -18
  132. package/dist/commonjs/object/pick-by.js +0 -22
  133. package/dist/commonjs/object/pick.js +0 -17
  134. package/dist/commonjs/object/prop.js +0 -7
  135. package/dist/commonjs/object/set-path.js +0 -25
  136. package/dist/commonjs/object/set.js +0 -14
  137. package/dist/commonjs/object/swap-props.js +0 -16
  138. package/dist/commonjs/object/to-pairs.js +0 -11
  139. package/dist/commonjs/object/values.js +0 -7
  140. package/dist/commonjs/string/cases-types.js +0 -2
  141. package/dist/commonjs/string/cases.js +0 -107
  142. package/dist/commonjs/string/human-readable-file-size.js +0 -16
  143. package/dist/commonjs/string/index.js +0 -21
  144. package/dist/commonjs/string/random-string.js +0 -16
  145. package/dist/commonjs/string/slugify.js +0 -13
  146. package/dist/commonjs/string/string-to-path.js +0 -18
  147. package/dist/commonjs/type/index.js +0 -17
  148. package/dist/commonjs/type/type.js +0 -13
  149. package/dist/commonjs/utils/binary-search-cutoff-index.js +0 -19
  150. package/dist/commonjs/utils/heap.js +0 -43
  151. package/dist/commonjs/utils/narrow.js +0 -2
  152. package/dist/commonjs/utils/paths.js +0 -2
  153. package/dist/commonjs/utils/purry-on.js +0 -10
  154. package/dist/commonjs/utils/purry-order-rules.js +0 -66
  155. package/dist/commonjs/utils/quick-select.js +0 -31
  156. package/dist/commonjs/utils/reduce-lazy.js +0 -21
  157. package/dist/commonjs/utils/swap-in-place.js +0 -7
  158. package/dist/commonjs/utils/to-lazy-indexed.js +0 -7
  159. package/dist/commonjs/utils/to-single.js +0 -7
  160. package/dist/commonjs/utils/types.js +0 -2
  161. package/dist/commonjs/utils/with-precision.js +0 -23
  162. package/dist/es/aria/index.js +0 -1
  163. package/dist/es/aria/key-codes.js +0 -22
  164. package/dist/es/array/all-pass.js +0 -7
  165. package/dist/es/array/any-pass.js +0 -7
  166. package/dist/es/array/chunk.js +0 -13
  167. package/dist/es/array/concat.js +0 -7
  168. package/dist/es/array/difference-with.js +0 -17
  169. package/dist/es/array/drop-first-by.js +0 -22
  170. package/dist/es/array/drop-last-while.js +0 -12
  171. package/dist/es/array/drop-last.js +0 -11
  172. package/dist/es/array/drop-while.js +0 -12
  173. package/dist/es/array/drop.js +0 -21
  174. package/dist/es/array/filter.js +0 -24
  175. package/dist/es/array/find-index.js +0 -29
  176. package/dist/es/array/find-last-index.js +0 -20
  177. package/dist/es/array/find-last.js +0 -20
  178. package/dist/es/array/find.js +0 -22
  179. package/dist/es/array/first-by.js +0 -18
  180. package/dist/es/array/first.js +0 -16
  181. package/dist/es/array/flat-map-to-obj.js +0 -22
  182. package/dist/es/array/flat-map.js +0 -19
  183. package/dist/es/array/flatten-deep.js +0 -34
  184. package/dist/es/array/flatten.js +0 -16
  185. package/dist/es/array/for-each.js +0 -32
  186. package/dist/es/array/group-by.js +0 -29
  187. package/dist/es/array/has-at-least.js +0 -7
  188. package/dist/es/array/index-by.js +0 -33
  189. package/dist/es/array/index.js +0 -65
  190. package/dist/es/array/intersection-with.js +0 -17
  191. package/dist/es/array/join.js +0 -7
  192. package/dist/es/array/last.js +0 -7
  193. package/dist/es/array/length.js +0 -7
  194. package/dist/es/array/map-to-obj.js +0 -20
  195. package/dist/es/array/map.js +0 -27
  196. package/dist/es/array/max-by.js +0 -24
  197. package/dist/es/array/mean-by.js +0 -22
  198. package/dist/es/array/merge-all.js +0 -7
  199. package/dist/es/array/min-by.js +0 -24
  200. package/dist/es/array/nth-by.js +0 -8
  201. package/dist/es/array/only.js +0 -7
  202. package/dist/es/array/partition.js +0 -20
  203. package/dist/es/array/range.js +0 -11
  204. package/dist/es/array/rank-by.js +0 -13
  205. package/dist/es/array/reduce.js +0 -15
  206. package/dist/es/array/reject.js +0 -24
  207. package/dist/es/array/reverse.js +0 -7
  208. package/dist/es/array/sample.js +0 -30
  209. package/dist/es/array/shuffle.js +0 -14
  210. package/dist/es/array/sort-by.js +0 -10
  211. package/dist/es/array/sort.js +0 -12
  212. package/dist/es/array/sorted-index-by.js +0 -15
  213. package/dist/es/array/sorted-index-with.js +0 -11
  214. package/dist/es/array/sorted-index.js +0 -8
  215. package/dist/es/array/sorted-last-index-by.js +0 -15
  216. package/dist/es/array/sorted-last-index.js +0 -8
  217. package/dist/es/array/splice.js +0 -9
  218. package/dist/es/array/split-at.js +0 -9
  219. package/dist/es/array/split-when.js +0 -13
  220. package/dist/es/array/sum-by.js +0 -20
  221. package/dist/es/array/swap-indices.js +0 -30
  222. package/dist/es/array/take-first-by.js +0 -20
  223. package/dist/es/array/take-while.js +0 -14
  224. package/dist/es/array/take.js +0 -21
  225. package/dist/es/array/uniq-by.js +0 -19
  226. package/dist/es/array/uniq-with.js +0 -19
  227. package/dist/es/array/uniq.js +0 -21
  228. package/dist/es/array/zip-obj.js +0 -12
  229. package/dist/es/array/zip-with.js +0 -19
  230. package/dist/es/array/zip.js +0 -15
  231. package/dist/es/function/conditional.js +0 -30
  232. package/dist/es/function/create-pipe.js +0 -4
  233. package/dist/es/function/debounce.js +0 -84
  234. package/dist/es/function/identity.js +0 -3
  235. package/dist/es/function/index.js +0 -10
  236. package/dist/es/function/noop.js +0 -3
  237. package/dist/es/function/once.js +0 -11
  238. package/dist/es/function/pipe.js +0 -96
  239. package/dist/es/function/purry.js +0 -15
  240. package/dist/es/function/sleep.js +0 -5
  241. package/dist/es/function/times.js +0 -14
  242. package/dist/es/guard/has-sub-object.js +0 -16
  243. package/dist/es/guard/index.js +0 -19
  244. package/dist/es/guard/is-array.js +0 -3
  245. package/dist/es/guard/is-boolean.js +0 -3
  246. package/dist/es/guard/is-date.js +0 -3
  247. package/dist/es/guard/is-deep-equal.js +0 -51
  248. package/dist/es/guard/is-defined.js +0 -9
  249. package/dist/es/guard/is-empty.js +0 -15
  250. package/dist/es/guard/is-error.js +0 -3
  251. package/dist/es/guard/is-function.js +0 -3
  252. package/dist/es/guard/is-included-in.js +0 -7
  253. package/dist/es/guard/is-nil.js +0 -3
  254. package/dist/es/guard/is-non-null.js +0 -3
  255. package/dist/es/guard/is-not.js +0 -3
  256. package/dist/es/guard/is-number.js +0 -3
  257. package/dist/es/guard/is-object.js +0 -7
  258. package/dist/es/guard/is-promise.js +0 -3
  259. package/dist/es/guard/is-string.js +0 -3
  260. package/dist/es/guard/is-symbol.js +0 -3
  261. package/dist/es/guard/is-truthy.js +0 -3
  262. package/dist/es/index.js +0 -9
  263. package/dist/es/number/add.js +0 -7
  264. package/dist/es/number/ceil.js +0 -5
  265. package/dist/es/number/clamp.js +0 -13
  266. package/dist/es/number/divide.js +0 -7
  267. package/dist/es/number/floor.js +0 -5
  268. package/dist/es/number/index.js +0 -8
  269. package/dist/es/number/multiply.js +0 -7
  270. package/dist/es/number/round.js +0 -5
  271. package/dist/es/number/subtract.js +0 -7
  272. package/dist/es/object/add-prop.js +0 -10
  273. package/dist/es/object/clone.js +0 -45
  274. package/dist/es/object/for-each-obj.js +0 -26
  275. package/dist/es/object/from-keys.js +0 -11
  276. package/dist/es/object/from-pairs.js +0 -14
  277. package/dist/es/object/index.js +0 -23
  278. package/dist/es/object/invert.js +0 -13
  279. package/dist/es/object/keys.js +0 -7
  280. package/dist/es/object/map-keys.js +0 -12
  281. package/dist/es/object/map-values.js +0 -12
  282. package/dist/es/object/merge-deep.js +0 -27
  283. package/dist/es/object/merge.js +0 -7
  284. package/dist/es/object/omit-by.js +0 -18
  285. package/dist/es/object/omit.js +0 -21
  286. package/dist/es/object/path-or.js +0 -14
  287. package/dist/es/object/pick-by.js +0 -18
  288. package/dist/es/object/pick.js +0 -13
  289. package/dist/es/object/prop.js +0 -3
  290. package/dist/es/object/set-path.js +0 -20
  291. package/dist/es/object/set.js +0 -10
  292. package/dist/es/object/swap-props.js +0 -12
  293. package/dist/es/object/to-pairs.js +0 -7
  294. package/dist/es/object/values.js +0 -3
  295. package/dist/es/string/cases-types.js +0 -1
  296. package/dist/es/string/cases.js +0 -93
  297. package/dist/es/string/human-readable-file-size.js +0 -12
  298. package/dist/es/string/index.js +0 -5
  299. package/dist/es/string/random-string.js +0 -12
  300. package/dist/es/string/slugify.js +0 -9
  301. package/dist/es/string/string-to-path.js +0 -14
  302. package/dist/es/type/index.js +0 -1
  303. package/dist/es/type/type.js +0 -9
  304. package/dist/es/utils/binary-search-cutoff-index.js +0 -15
  305. package/dist/es/utils/heap.js +0 -38
  306. package/dist/es/utils/narrow.js +0 -1
  307. package/dist/es/utils/paths.js +0 -1
  308. package/dist/es/utils/purry-on.js +0 -6
  309. package/dist/es/utils/purry-order-rules.js +0 -61
  310. package/dist/es/utils/quick-select.js +0 -27
  311. package/dist/es/utils/reduce-lazy.js +0 -17
  312. package/dist/es/utils/swap-in-place.js +0 -3
  313. package/dist/es/utils/to-lazy-indexed.js +0 -3
  314. package/dist/es/utils/to-single.js +0 -3
  315. package/dist/es/utils/types.js +0 -1
  316. package/dist/es/utils/with-precision.js +0 -19
  317. package/dist/types/aria/index.d.ts +0 -2
  318. package/dist/types/aria/index.d.ts.map +0 -1
  319. package/dist/types/aria/key-codes.d.ts +0 -26
  320. package/dist/types/aria/key-codes.d.ts.map +0 -1
  321. package/dist/types/array/all-pass.d.ts +0 -32
  322. package/dist/types/array/all-pass.d.ts.map +0 -1
  323. package/dist/types/array/any-pass.d.ts +0 -32
  324. package/dist/types/array/any-pass.d.ts.map +0 -1
  325. package/dist/types/array/chunk.d.ts +0 -29
  326. package/dist/types/array/chunk.d.ts.map +0 -1
  327. package/dist/types/array/concat.d.ts +0 -24
  328. package/dist/types/array/concat.d.ts.map +0 -1
  329. package/dist/types/array/difference-with.d.ts +0 -48
  330. package/dist/types/array/difference-with.d.ts.map +0 -1
  331. package/dist/types/array/drop-first-by.d.ts +0 -38
  332. package/dist/types/array/drop-first-by.d.ts.map +0 -1
  333. package/dist/types/array/drop-last-while.d.ts +0 -30
  334. package/dist/types/array/drop-last-while.d.ts.map +0 -1
  335. package/dist/types/array/drop-last.d.ts +0 -26
  336. package/dist/types/array/drop-last.d.ts.map +0 -1
  337. package/dist/types/array/drop-while.d.ts +0 -33
  338. package/dist/types/array/drop-while.d.ts.map +0 -1
  339. package/dist/types/array/drop.d.ts +0 -32
  340. package/dist/types/array/drop.d.ts.map +0 -1
  341. package/dist/types/array/filter.d.ts +0 -63
  342. package/dist/types/array/filter.d.ts.map +0 -1
  343. package/dist/types/array/find-index.d.ts +0 -54
  344. package/dist/types/array/find-index.d.ts.map +0 -1
  345. package/dist/types/array/find-last-index.d.ts +0 -45
  346. package/dist/types/array/find-last-index.d.ts.map +0 -1
  347. package/dist/types/array/find-last.d.ts +0 -45
  348. package/dist/types/array/find-last.d.ts.map +0 -1
  349. package/dist/types/array/find.d.ts +0 -52
  350. package/dist/types/array/find.d.ts.map +0 -1
  351. package/dist/types/array/first-by.d.ts +0 -56
  352. package/dist/types/array/first-by.d.ts.map +0 -1
  353. package/dist/types/array/first.d.ts +0 -32
  354. package/dist/types/array/first.d.ts.map +0 -1
  355. package/dist/types/array/flat-map-to-obj.d.ts +0 -50
  356. package/dist/types/array/flat-map-to-obj.d.ts.map +0 -1
  357. package/dist/types/array/flat-map.d.ts +0 -32
  358. package/dist/types/array/flat-map.d.ts.map +0 -1
  359. package/dist/types/array/flatten-deep.d.ts +0 -37
  360. package/dist/types/array/flatten-deep.d.ts.map +0 -1
  361. package/dist/types/array/flatten.d.ts +0 -39
  362. package/dist/types/array/flatten.d.ts.map +0 -1
  363. package/dist/types/array/for-each.d.ts +0 -57
  364. package/dist/types/array/for-each.d.ts.map +0 -1
  365. package/dist/types/array/group-by.d.ts +0 -37
  366. package/dist/types/array/group-by.d.ts.map +0 -1
  367. package/dist/types/array/has-at-least.d.ts +0 -46
  368. package/dist/types/array/has-at-least.d.ts.map +0 -1
  369. package/dist/types/array/index-by.d.ts +0 -52
  370. package/dist/types/array/index-by.d.ts.map +0 -1
  371. package/dist/types/array/index.d.ts +0 -66
  372. package/dist/types/array/index.d.ts.map +0 -1
  373. package/dist/types/array/intersection-with.d.ts +0 -54
  374. package/dist/types/array/intersection-with.d.ts.map +0 -1
  375. package/dist/types/array/join.d.ts +0 -45
  376. package/dist/types/array/join.d.ts.map +0 -1
  377. package/dist/types/array/last.d.ts +0 -34
  378. package/dist/types/array/last.d.ts.map +0 -1
  379. package/dist/types/array/length.d.ts +0 -15
  380. package/dist/types/array/length.d.ts.map +0 -1
  381. package/dist/types/array/map-to-obj.d.ts +0 -42
  382. package/dist/types/array/map-to-obj.d.ts.map +0 -1
  383. package/dist/types/array/map.d.ts +0 -62
  384. package/dist/types/array/map.d.ts.map +0 -1
  385. package/dist/types/array/max-by.d.ts +0 -39
  386. package/dist/types/array/max-by.d.ts.map +0 -1
  387. package/dist/types/array/mean-by.d.ts +0 -39
  388. package/dist/types/array/mean-by.d.ts.map +0 -1
  389. package/dist/types/array/merge-all.d.ts +0 -16
  390. package/dist/types/array/merge-all.d.ts.map +0 -1
  391. package/dist/types/array/min-by.d.ts +0 -39
  392. package/dist/types/array/min-by.d.ts.map +0 -1
  393. package/dist/types/array/nth-by.d.ts +0 -44
  394. package/dist/types/array/nth-by.d.ts.map +0 -1
  395. package/dist/types/array/only.d.ts +0 -37
  396. package/dist/types/array/only.d.ts.map +0 -1
  397. package/dist/types/array/partition.d.ts +0 -60
  398. package/dist/types/array/partition.d.ts.map +0 -1
  399. package/dist/types/array/range.d.ts +0 -22
  400. package/dist/types/array/range.d.ts.map +0 -1
  401. package/dist/types/array/rank-by.d.ts +0 -40
  402. package/dist/types/array/rank-by.d.ts.map +0 -1
  403. package/dist/types/array/reduce.d.ts +0 -37
  404. package/dist/types/array/reduce.d.ts.map +0 -1
  405. package/dist/types/array/reject.d.ts +0 -42
  406. package/dist/types/array/reject.d.ts.map +0 -1
  407. package/dist/types/array/reverse.d.ts +0 -27
  408. package/dist/types/array/reverse.d.ts.map +0 -1
  409. package/dist/types/array/sample.d.ts +0 -54
  410. package/dist/types/array/sample.d.ts.map +0 -1
  411. package/dist/types/array/shuffle.d.ts +0 -22
  412. package/dist/types/array/shuffle.d.ts.map +0 -1
  413. package/dist/types/array/sort-by.d.ts +0 -98
  414. package/dist/types/array/sort-by.d.ts.map +0 -1
  415. package/dist/types/array/sort.d.ts +0 -52
  416. package/dist/types/array/sort.d.ts.map +0 -1
  417. package/dist/types/array/sorted-index-by.d.ts +0 -62
  418. package/dist/types/array/sorted-index-by.d.ts.map +0 -1
  419. package/dist/types/array/sorted-index-with.d.ts +0 -64
  420. package/dist/types/array/sorted-index-with.d.ts.map +0 -1
  421. package/dist/types/array/sorted-index.d.ts +0 -46
  422. package/dist/types/array/sorted-index.d.ts.map +0 -1
  423. package/dist/types/array/sorted-last-index-by.d.ts +0 -62
  424. package/dist/types/array/sorted-last-index-by.d.ts.map +0 -1
  425. package/dist/types/array/sorted-last-index.d.ts +0 -46
  426. package/dist/types/array/sorted-last-index.d.ts.map +0 -1
  427. package/dist/types/array/splice.d.ts +0 -32
  428. package/dist/types/array/splice.d.ts.map +0 -1
  429. package/dist/types/array/split-at.d.ts +0 -28
  430. package/dist/types/array/split-at.d.ts.map +0 -1
  431. package/dist/types/array/split-when.d.ts +0 -24
  432. package/dist/types/array/split-when.d.ts.map +0 -1
  433. package/dist/types/array/sum-by.d.ts +0 -39
  434. package/dist/types/array/sum-by.d.ts.map +0 -1
  435. package/dist/types/array/swap-indices.d.ts +0 -68
  436. package/dist/types/array/swap-indices.d.ts.map +0 -1
  437. package/dist/types/array/take-first-by.d.ts +0 -42
  438. package/dist/types/array/take-first-by.d.ts.map +0 -1
  439. package/dist/types/array/take-while.d.ts +0 -24
  440. package/dist/types/array/take-while.d.ts.map +0 -1
  441. package/dist/types/array/take.d.ts +0 -30
  442. package/dist/types/array/take.d.ts.map +0 -1
  443. package/dist/types/array/uniq-by.d.ts +0 -22
  444. package/dist/types/array/uniq-by.d.ts.map +0 -1
  445. package/dist/types/array/uniq-with.d.ts +0 -44
  446. package/dist/types/array/uniq-with.d.ts.map +0 -1
  447. package/dist/types/array/uniq.d.ts +0 -35
  448. package/dist/types/array/uniq.d.ts.map +0 -1
  449. package/dist/types/array/zip-obj.d.ts +0 -26
  450. package/dist/types/array/zip-obj.d.ts.map +0 -1
  451. package/dist/types/array/zip-with.d.ts +0 -42
  452. package/dist/types/array/zip-with.d.ts.map +0 -1
  453. package/dist/types/array/zip.d.ts +0 -52
  454. package/dist/types/array/zip.d.ts.map +0 -1
  455. package/dist/types/function/conditional.d.ts +0 -107
  456. package/dist/types/function/conditional.d.ts.map +0 -1
  457. package/dist/types/function/create-pipe.d.ts +0 -19
  458. package/dist/types/function/create-pipe.d.ts.map +0 -1
  459. package/dist/types/function/debounce.d.ts +0 -92
  460. package/dist/types/function/debounce.d.ts.map +0 -1
  461. package/dist/types/function/identity.d.ts +0 -10
  462. package/dist/types/function/identity.d.ts.map +0 -1
  463. package/dist/types/function/index.d.ts +0 -11
  464. package/dist/types/function/index.d.ts.map +0 -1
  465. package/dist/types/function/noop.d.ts +0 -10
  466. package/dist/types/function/noop.d.ts.map +0 -1
  467. package/dist/types/function/once.d.ts +0 -13
  468. package/dist/types/function/once.d.ts.map +0 -1
  469. package/dist/types/function/pipe.d.ts +0 -53
  470. package/dist/types/function/pipe.d.ts.map +0 -1
  471. package/dist/types/function/purry.d.ts +0 -48
  472. package/dist/types/function/purry.d.ts.map +0 -1
  473. package/dist/types/function/sleep.d.ts +0 -12
  474. package/dist/types/function/sleep.d.ts.map +0 -1
  475. package/dist/types/function/times.d.ts +0 -28
  476. package/dist/types/function/times.d.ts.map +0 -1
  477. package/dist/types/guard/has-sub-object.d.ts +0 -35
  478. package/dist/types/guard/has-sub-object.d.ts.map +0 -1
  479. package/dist/types/guard/index.d.ts +0 -20
  480. package/dist/types/guard/index.d.ts.map +0 -1
  481. package/dist/types/guard/is-array.d.ts +0 -15
  482. package/dist/types/guard/is-array.d.ts.map +0 -1
  483. package/dist/types/guard/is-boolean.d.ts +0 -15
  484. package/dist/types/guard/is-boolean.d.ts.map +0 -1
  485. package/dist/types/guard/is-date.d.ts +0 -13
  486. package/dist/types/guard/is-date.d.ts.map +0 -1
  487. package/dist/types/guard/is-deep-equal.d.ts +0 -50
  488. package/dist/types/guard/is-deep-equal.d.ts.map +0 -1
  489. package/dist/types/guard/is-defined.d.ts +0 -22
  490. package/dist/types/guard/is-defined.d.ts.map +0 -1
  491. package/dist/types/guard/is-empty.d.ts +0 -30
  492. package/dist/types/guard/is-empty.d.ts.map +0 -1
  493. package/dist/types/guard/is-error.d.ts +0 -15
  494. package/dist/types/guard/is-error.d.ts.map +0 -1
  495. package/dist/types/guard/is-function.d.ts +0 -15
  496. package/dist/types/guard/is-function.d.ts.map +0 -1
  497. package/dist/types/guard/is-included-in.d.ts +0 -54
  498. package/dist/types/guard/is-included-in.d.ts.map +0 -1
  499. package/dist/types/guard/is-nil.d.ts +0 -14
  500. package/dist/types/guard/is-nil.d.ts.map +0 -1
  501. package/dist/types/guard/is-non-null.d.ts +0 -15
  502. package/dist/types/guard/is-non-null.d.ts.map +0 -1
  503. package/dist/types/guard/is-not.d.ts +0 -15
  504. package/dist/types/guard/is-not.d.ts.map +0 -1
  505. package/dist/types/guard/is-number.d.ts +0 -14
  506. package/dist/types/guard/is-number.d.ts.map +0 -1
  507. package/dist/types/guard/is-object.d.ts +0 -28
  508. package/dist/types/guard/is-object.d.ts.map +0 -1
  509. package/dist/types/guard/is-promise.d.ts +0 -14
  510. package/dist/types/guard/is-promise.d.ts.map +0 -1
  511. package/dist/types/guard/is-string.d.ts +0 -14
  512. package/dist/types/guard/is-string.d.ts.map +0 -1
  513. package/dist/types/guard/is-symbol.d.ts +0 -14
  514. package/dist/types/guard/is-symbol.d.ts.map +0 -1
  515. package/dist/types/guard/is-truthy.d.ts +0 -17
  516. package/dist/types/guard/is-truthy.d.ts.map +0 -1
  517. package/dist/types/index.d.ts +0 -10
  518. package/dist/types/index.d.ts.map +0 -1
  519. package/dist/types/number/add.d.ts +0 -28
  520. package/dist/types/number/add.d.ts.map +0 -1
  521. package/dist/types/number/ceil.d.ts +0 -36
  522. package/dist/types/number/ceil.d.ts.map +0 -1
  523. package/dist/types/number/clamp.d.ts +0 -37
  524. package/dist/types/number/clamp.d.ts.map +0 -1
  525. package/dist/types/number/divide.d.ts +0 -26
  526. package/dist/types/number/divide.d.ts.map +0 -1
  527. package/dist/types/number/floor.d.ts +0 -36
  528. package/dist/types/number/floor.d.ts.map +0 -1
  529. package/dist/types/number/index.d.ts +0 -9
  530. package/dist/types/number/index.d.ts.map +0 -1
  531. package/dist/types/number/multiply.d.ts +0 -28
  532. package/dist/types/number/multiply.d.ts.map +0 -1
  533. package/dist/types/number/round.d.ts +0 -36
  534. package/dist/types/number/round.d.ts.map +0 -1
  535. package/dist/types/number/subtract.d.ts +0 -30
  536. package/dist/types/number/subtract.d.ts.map +0 -1
  537. package/dist/types/object/add-prop.d.ts +0 -30
  538. package/dist/types/object/add-prop.d.ts.map +0 -1
  539. package/dist/types/object/clone.d.ts +0 -10
  540. package/dist/types/object/clone.d.ts.map +0 -1
  541. package/dist/types/object/for-each-obj.d.ts +0 -44
  542. package/dist/types/object/for-each-obj.d.ts.map +0 -1
  543. package/dist/types/object/from-keys.d.ts +0 -42
  544. package/dist/types/object/from-keys.d.ts.map +0 -1
  545. package/dist/types/object/from-pairs.d.ts +0 -47
  546. package/dist/types/object/from-pairs.d.ts.map +0 -1
  547. package/dist/types/object/index.d.ts +0 -24
  548. package/dist/types/object/index.d.ts.map +0 -1
  549. package/dist/types/object/invert.d.ts +0 -30
  550. package/dist/types/object/invert.d.ts.map +0 -1
  551. package/dist/types/object/keys.d.ts +0 -39
  552. package/dist/types/object/keys.d.ts.map +0 -1
  553. package/dist/types/object/map-keys.d.ts +0 -24
  554. package/dist/types/object/map-keys.d.ts.map +0 -1
  555. package/dist/types/object/map-values.d.ts +0 -25
  556. package/dist/types/object/map-values.d.ts.map +0 -1
  557. package/dist/types/object/merge-deep.d.ts +0 -32
  558. package/dist/types/object/merge-deep.d.ts.map +0 -1
  559. package/dist/types/object/merge.d.ts +0 -52
  560. package/dist/types/object/merge.d.ts.map +0 -1
  561. package/dist/types/object/omit-by.d.ts +0 -22
  562. package/dist/types/object/omit-by.d.ts.map +0 -1
  563. package/dist/types/object/omit.d.ts +0 -24
  564. package/dist/types/object/omit.d.ts.map +0 -1
  565. package/dist/types/object/path-or.d.ts +0 -78
  566. package/dist/types/object/path-or.d.ts.map +0 -1
  567. package/dist/types/object/pick-by.d.ts +0 -24
  568. package/dist/types/object/pick-by.d.ts.map +0 -1
  569. package/dist/types/object/pick.d.ts +0 -22
  570. package/dist/types/object/pick.d.ts.map +0 -1
  571. package/dist/types/object/prop.d.ts +0 -11
  572. package/dist/types/object/prop.d.ts.map +0 -1
  573. package/dist/types/object/set-path.d.ts +0 -31
  574. package/dist/types/object/set-path.d.ts.map +0 -1
  575. package/dist/types/object/set.d.ts +0 -26
  576. package/dist/types/object/set.d.ts.map +0 -1
  577. package/dist/types/object/swap-props.d.ts +0 -44
  578. package/dist/types/object/swap-props.d.ts.map +0 -1
  579. package/dist/types/object/to-pairs.d.ts +0 -33
  580. package/dist/types/object/to-pairs.d.ts.map +0 -1
  581. package/dist/types/object/values.d.ts +0 -21
  582. package/dist/types/object/values.d.ts.map +0 -1
  583. package/dist/types/string/cases-types.d.ts +0 -36
  584. package/dist/types/string/cases-types.d.ts.map +0 -1
  585. package/dist/types/string/cases.d.ts +0 -22
  586. package/dist/types/string/cases.d.ts.map +0 -1
  587. package/dist/types/string/human-readable-file-size.d.ts +0 -13
  588. package/dist/types/string/human-readable-file-size.d.ts.map +0 -1
  589. package/dist/types/string/index.d.ts +0 -6
  590. package/dist/types/string/index.d.ts.map +0 -1
  591. package/dist/types/string/random-string.d.ts +0 -15
  592. package/dist/types/string/random-string.d.ts.map +0 -1
  593. package/dist/types/string/slugify.d.ts +0 -12
  594. package/dist/types/string/slugify.d.ts.map +0 -1
  595. package/dist/types/string/string-to-path.d.ts +0 -11
  596. package/dist/types/string/string-to-path.d.ts.map +0 -1
  597. package/dist/types/type/index.d.ts +0 -2
  598. package/dist/types/type/index.d.ts.map +0 -1
  599. package/dist/types/type/type.d.ts +0 -19
  600. package/dist/types/type/type.d.ts.map +0 -1
  601. package/dist/types/utils/binary-search-cutoff-index.d.ts +0 -2
  602. package/dist/types/utils/binary-search-cutoff-index.d.ts.map +0 -1
  603. package/dist/types/utils/heap.d.ts +0 -24
  604. package/dist/types/utils/heap.d.ts.map +0 -1
  605. package/dist/types/utils/narrow.d.ts +0 -52
  606. package/dist/types/utils/narrow.d.ts.map +0 -1
  607. package/dist/types/utils/paths.d.ts +0 -9
  608. package/dist/types/utils/paths.d.ts.map +0 -1
  609. package/dist/types/utils/purry-on.d.ts +0 -7
  610. package/dist/types/utils/purry-on.d.ts.map +0 -1
  611. package/dist/types/utils/purry-order-rules.d.ts +0 -52
  612. package/dist/types/utils/purry-order-rules.d.ts.map +0 -1
  613. package/dist/types/utils/quick-select.d.ts +0 -18
  614. package/dist/types/utils/quick-select.d.ts.map +0 -1
  615. package/dist/types/utils/reduce-lazy.d.ts +0 -3
  616. package/dist/types/utils/reduce-lazy.d.ts.map +0 -1
  617. package/dist/types/utils/swap-in-place.d.ts +0 -5
  618. package/dist/types/utils/swap-in-place.d.ts.map +0 -1
  619. package/dist/types/utils/to-lazy-indexed.d.ts +0 -4
  620. package/dist/types/utils/to-lazy-indexed.d.ts.map +0 -1
  621. package/dist/types/utils/to-single.d.ts +0 -6
  622. package/dist/types/utils/to-single.d.ts.map +0 -1
  623. package/dist/types/utils/types.d.ts +0 -32
  624. package/dist/types/utils/types.d.ts.map +0 -1
  625. package/dist/types/utils/with-precision.d.ts +0 -2
  626. package/dist/types/utils/with-precision.d.ts.map +0 -1
@@ -0,0 +1,4603 @@
1
+ import { IsAny, ReadonlyTuple, Simplify, Merge, MergeDeep } from 'type-fest';
2
+
3
+ /**
4
+ * Using event.code is not predictable since each machine may have different output
5
+ */
6
+ declare const KEY_CODES: {
7
+ readonly ALT: "Alt";
8
+ readonly ARROW_DOWN: "ArrowDown";
9
+ readonly ARROW_LEFT: "ArrowLeft";
10
+ readonly ARROW_RIGHT: "ArrowRight";
11
+ readonly ARROW_UP: "ArrowUp";
12
+ readonly AT: "@";
13
+ readonly BACKSPACE: "Backspace";
14
+ readonly CTRL: "Control";
15
+ readonly DELETE: "Delete";
16
+ readonly END: "End";
17
+ readonly ENTER: "Enter";
18
+ readonly ESC: "Escape";
19
+ readonly HOME: "Home";
20
+ readonly KEY_F: "KEY_F";
21
+ readonly META: "Meta";
22
+ readonly PAGE_DOWN: "PageDown";
23
+ readonly PAGE_UP: "PageUp";
24
+ readonly SHIFT: "Shift";
25
+ readonly SPACE: "Space";
26
+ readonly TAB: "Tab";
27
+ };
28
+
29
+ /**
30
+ * Determines whether all predicates returns true for the input data.
31
+ * @param data The input data for predicates.
32
+ * @param fns The list of predicates.
33
+ * @signature
34
+ * P.allPass(data, fns)
35
+ * @example
36
+ * const isDivisibleBy3 = (x: number) => x % 3 === 0
37
+ * const isDivisibleBy4 = (x: number) => x % 4 === 0
38
+ * const fns = [isDivisibleBy3, isDivisibleBy4]
39
+ * P.allPass(12, fns) // => true
40
+ * P.allPass(8, fns) // => false
41
+ * @dataFirst
42
+ * @category Array
43
+ */
44
+ declare function allPass<T>(data: T, fns: ReadonlyArray<(data: T) => boolean>): boolean;
45
+ /**
46
+ * Determines whether all predicates returns true for the input data.
47
+ * @param fns The list of predicates.
48
+ * @signature
49
+ * P.allPass(fns)(data)
50
+ * @example
51
+ * const isDivisibleBy3 = (x: number) => x % 3 === 0
52
+ * const isDivisibleBy4 = (x: number) => x % 4 === 0
53
+ * const fns = [isDivisibleBy3, isDivisibleBy4]
54
+ * P.allPass(fns)(12) // => true
55
+ * P.allPass(fns)(8) // => false
56
+ * @dataLast
57
+ * @category Array
58
+ */
59
+ declare function allPass<T>(fns: ReadonlyArray<(data: T) => boolean>): (data: T) => boolean;
60
+
61
+ /**
62
+ * Determines whether any predicate returns true for the input data.
63
+ * @param data The input data for predicates.
64
+ * @param fns The list of predicates.
65
+ * @signature
66
+ * P.anyPass(data, fns)
67
+ * @example
68
+ * const isDivisibleBy3 = (x: number) => x % 3 === 0
69
+ * const isDivisibleBy4 = (x: number) => x % 4 === 0
70
+ * const fns = [isDivisibleBy3, isDivisibleBy4]
71
+ * P.anyPass(8, fns) // => true
72
+ * P.anyPass(11, fns) // => false
73
+ * @dataFirst
74
+ * @category Array
75
+ */
76
+ declare function anyPass<T>(data: T, fns: ReadonlyArray<(data: T) => boolean>): boolean;
77
+ /**
78
+ * Determines whether any predicate returns true for the input data.
79
+ * @param fns The list of predicates.
80
+ * @signature
81
+ * P.anyPass(fns)(data)
82
+ * @example
83
+ * const isDivisibleBy3 = (x: number) => x % 3 === 0
84
+ * const isDivisibleBy4 = (x: number) => x % 4 === 0
85
+ * const fns = [isDivisibleBy3, isDivisibleBy4]
86
+ * P.anyPass(fns)(8) // => true
87
+ * P.anyPass(fns)(11) // => false
88
+ * @dataLast
89
+ * @category Array
90
+ */
91
+ declare function anyPass<T>(fns: ReadonlyArray<(data: T) => boolean>): (data: T) => boolean;
92
+
93
+ type Pred<T, K> = (input: T) => K;
94
+ type PredIndexed<T, K> = (input: T, index: number, array: ReadonlyArray<T>) => K;
95
+ type PredIndexedOptional<T, K> = (input: T, index?: number, array?: ReadonlyArray<T>) => K;
96
+ type NonEmptyArray<T> = [T, ...Array<T>];
97
+ /**
98
+ * This should only be used for defining generics which extend any kind of JS
99
+ * array under the hood, this includes arrays *AND* tuples (of the form [x, y],
100
+ * and of the form [x, ...y[]], etc...), and their readonly equivalent. This
101
+ * allows us to be more inclusive to what functions can process.
102
+ *
103
+ * @example map<T extends ArrayLike>(items: T) { ... }
104
+ *
105
+ * We would've named this `ArrayLike`, but that's already used by typescript...
106
+ *
107
+ * @see This was inspired by the type-definition of Promise.all (https://github.com/microsoft/TypeScript/blob/1df5717b120cddd325deab8b0f2b2c3eecaf2b01/src/lib/es2015.promise.d.ts#L21)
108
+ */
109
+ type IterableContainer<T = unknown> = ReadonlyArray<T> | readonly [];
110
+ type ObjectKeys$1<T extends object> = `${Exclude<keyof T, symbol>}`;
111
+ /**
112
+ * An extension of Extract for type predicates which falls back to the base
113
+ * in order to narrow the `unknown` case.
114
+ * @example
115
+ * function isMyType<T>(data: T | MyType): data is NarrowedTo<T, MyType> { ... }
116
+ */
117
+ type NarrowedTo<T, Base> = Extract<T, Base> extends never ? Base : IsAny<T> extends true ? Base : Extract<T, Base>;
118
+
119
+ type Chunked<T extends IterableContainer> = T[number] extends never ? [] : T extends readonly [...Array<unknown>, unknown] | readonly [unknown, ...Array<unknown>] ? NonEmptyArray<NonEmptyArray<T[number]>> : Array<NonEmptyArray<T[number]>>;
120
+ /**
121
+ * Split an array into groups the length of `size`. If `array` can't be split evenly, the final chunk will be the remaining elements.
122
+ * @param array the array
123
+ * @param size the length of the chunk
124
+ * @signature
125
+ * P.chunk(array, size)
126
+ * @example
127
+ * P.chunk(['a', 'b', 'c', 'd'], 2) // => [['a', 'b'], ['c', 'd']]
128
+ * P.chunk(['a', 'b', 'c', 'd'], 3) // => [['a', 'b', 'c'], ['d']]
129
+ * @dataFirst
130
+ * @category Array
131
+ */
132
+ declare function chunk<T extends IterableContainer>(array: T, size: number): Chunked<T>;
133
+ /**
134
+ * Split an array into groups the length of `size`. If `array` can't be split evenly, the final chunk will be the remaining elements.
135
+ * @param size the length of the chunk
136
+ * @signature
137
+ * P.chunk(size)(array)
138
+ * @example
139
+ * P.chunk(2)(['a', 'b', 'c', 'd']) // => [['a', 'b'], ['c', 'd']]
140
+ * P.chunk(3)(['a', 'b', 'c', 'd']) // => [['a', 'b', 'c'], ['d']]
141
+ * @dataLast
142
+ * @category Array
143
+ */
144
+ declare function chunk<T extends IterableContainer>(size: number): (array: T) => Chunked<T>;
145
+
146
+ /**
147
+ * Combines two arrays.
148
+ * @param arr1 the first array
149
+ * @param arr2 the second array
150
+ * @signature
151
+ * P.concat(arr1, arr2);
152
+ * @example
153
+ * P.concat([1, 2, 3], ['a']) // [1, 2, 3, 'a']
154
+ * @dataFirst
155
+ * @category Array
156
+ */
157
+ declare function concat<T, K>(arr1: ReadonlyArray<T>, arr2: ReadonlyArray<K>): Array<K | T>;
158
+ /**
159
+ * Combines two arrays.
160
+ * @param arr2 the second array
161
+ * @signature
162
+ * P.concat(arr2)(arr1);
163
+ * @example
164
+ * P.concat(['a'])([1, 2, 3]) // [1, 2, 3, 'a']
165
+ * @dataLast
166
+ * @category Array
167
+ */
168
+ declare function concat<T, K>(arr2: ReadonlyArray<K>): (arr1: ReadonlyArray<T>) => Array<K | T>;
169
+
170
+ type LazyEvaluator<T = unknown, R = T> = (item: T, index?: number, data?: ReadonlyArray<T>) => LazyResult<R>;
171
+ type LazyResult<T> = LazyEmpty | LazyMany<T> | LazyNext<T>;
172
+ interface LazyEmpty {
173
+ done: boolean;
174
+ hasMany?: false | undefined;
175
+ hasNext: false;
176
+ next?: undefined;
177
+ }
178
+ interface LazyNext<T> {
179
+ done: boolean;
180
+ hasMany?: false | undefined;
181
+ hasNext: true;
182
+ next: T;
183
+ }
184
+ interface LazyMany<T> {
185
+ done: boolean;
186
+ hasMany: true;
187
+ hasNext: true;
188
+ next: Array<T>;
189
+ }
190
+ /**
191
+ * Perform left-to-right function composition.
192
+ * @param value The initial value.
193
+ * @param arguments the list of operations to apply.
194
+ * @signature P.pipe(data, op1, op2, op3)
195
+ * @example
196
+ * P.pipe(
197
+ * [1, 2, 3, 4],
198
+ * P.map(x => x * 2),
199
+ * arr => [arr[0] + arr[1], arr[2] + arr[3]],
200
+ * ) // => [6, 14]
201
+ *
202
+ *
203
+ * @dataFirst
204
+ * @category Function
205
+ */
206
+ declare function pipe<A, B>(value: A, op1: (input: A) => B): B;
207
+ declare function pipe<A, B, C>(value: A, op1: (input: A) => B, op2: (input: B) => C): C;
208
+ declare function pipe<A, B, C, D>(value: A, op1: (input: A) => B, op2: (input: B) => C, op3: (input: C) => D): D;
209
+ declare function pipe<A, B, C, D, E>(value: A, op1: (input: A) => B, op2: (input: B) => C, op3: (input: C) => D, op4: (input: D) => E): E;
210
+ declare function pipe<A, B, C, D, E, F>(value: A, op1: (input: A) => B, op2: (input: B) => C, op3: (input: C) => D, op4: (input: D) => E, op5: (input: E) => F): F;
211
+ declare function pipe<A, B, C, D, E, F, G>(value: A, op1: (input: A) => B, op2: (input: B) => C, op3: (input: C) => D, op4: (input: D) => E, op5: (input: E) => F, op6: (input: F) => G): G;
212
+ declare function pipe<A, B, C, D, E, F, G, H>(value: A, op1: (input: A) => B, op2: (input: B) => C, op3: (input: C) => D, op4: (input: D) => E, op5: (input: E) => F, op6: (input: F) => G, op7: (input: G) => H): H;
213
+ declare function pipe<A, B, C, D, E, F, G, H, I>(value: A, op1: (input: A) => B, op2: (input: B) => C, op3: (input: C) => D, op4: (input: D) => E, op5: (input: E) => F, op6: (input: F) => G, op7: (input: G) => H, op8: (input: H) => I): I;
214
+ declare function pipe<A, B, C, D, E, F, G, H, I, J>(value: A, op1: (input: A) => B, op2: (input: B) => C, op3: (input: C) => D, op4: (input: D) => E, op5: (input: E) => F, op6: (input: F) => G, op7: (input: G) => H, op8: (input: H) => I, op9: (input: I) => J): J;
215
+ declare function pipe<A, B, C, D, E, F, G, H, I, J, K>(value: A, op01: (input: A) => B, op02: (input: B) => C, op03: (input: C) => D, op04: (input: D) => E, op05: (input: E) => F, op06: (input: F) => G, op07: (input: G) => H, op08: (input: H) => I, op09: (input: I) => J, op10: (input: J) => K): K;
216
+ declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L>(value: A, op01: (input: A) => B, op02: (input: B) => C, op03: (input: C) => D, op04: (input: D) => E, op05: (input: E) => F, op06: (input: F) => G, op07: (input: G) => H, op08: (input: H) => I, op09: (input: I) => J, op10: (input: J) => K, op11: (input: K) => L): L;
217
+ declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M>(value: A, op01: (input: A) => B, op02: (input: B) => C, op03: (input: C) => D, op04: (input: D) => E, op05: (input: E) => F, op06: (input: F) => G, op07: (input: G) => H, op08: (input: H) => I, op09: (input: I) => J, op10: (input: J) => K, op11: (input: K) => L, op12: (input: L) => M): M;
218
+ declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N>(value: A, op01: (input: A) => B, op02: (input: B) => C, op03: (input: C) => D, op04: (input: D) => E, op05: (input: E) => F, op06: (input: F) => G, op07: (input: G) => H, op08: (input: H) => I, op09: (input: I) => J, op10: (input: J) => K, op11: (input: K) => L, op12: (input: L) => M, op13: (input: M) => N): N;
219
+ declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(value: A, op01: (input: A) => B, op02: (input: B) => C, op03: (input: C) => D, op04: (input: D) => E, op05: (input: E) => F, op06: (input: F) => G, op07: (input: G) => H, op08: (input: H) => I, op09: (input: I) => J, op10: (input: J) => K, op11: (input: K) => L, op12: (input: L) => M, op13: (input: M) => N, op14: (input: N) => O): O;
220
+ declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(value: A, op01: (input: A) => B, op02: (input: B) => C, op03: (input: C) => D, op04: (input: D) => E, op05: (input: E) => F, op06: (input: F) => G, op07: (input: G) => H, op08: (input: H) => I, op09: (input: I) => J, op10: (input: J) => K, op11: (input: K) => L, op12: (input: L) => M, op13: (input: M) => N, op14: (input: N) => O, op15: (input: O) => P): P;
221
+
222
+ type IsEquals$1<TFirst, TSecond> = (a: TFirst, b: TSecond) => boolean;
223
+ /**
224
+ * Excludes the values from `other` array.
225
+ * Elements are compared by custom comparator isEquals.
226
+ * @param array the source array
227
+ * @param other the values to exclude
228
+ * @param isEquals the comparator
229
+ * @signature
230
+ * P.differenceWith(array, other, isEquals)
231
+ * @example
232
+ * P.differenceWith(
233
+ * [{a: 1}, {a: 2}, {a: 3}, {a: 4}],
234
+ * [{a: 2}, {a: 5}, {a: 3}],
235
+ * P.isDeepEqual,
236
+ * ) // => [{a: 1}, {a: 4}]
237
+ * @dataFirst
238
+ * @category Array
239
+ * @pipeable
240
+ */
241
+ declare function differenceWith<TFirst, TSecond>(array: ReadonlyArray<TFirst>, other: ReadonlyArray<TSecond>, isEquals: IsEquals$1<TFirst, TSecond>): Array<TFirst>;
242
+ /**
243
+ * Excludes the values from `other` array.
244
+ * Elements are compared by custom comparator isEquals.
245
+ * @param other the values to exclude
246
+ * @param isEquals the comparator
247
+ * @signature
248
+ * P.differenceWith(other, isEquals)(array)
249
+ * @example
250
+ * P.differenceWith(
251
+ * [{a: 2}, {a: 5}, {a: 3}],
252
+ * P.isDeepEqual,
253
+ * )([{a: 1}, {a: 2}, {a: 3}, {a: 4}]) // => [{a: 1}, {a: 4}]
254
+ * P.pipe(
255
+ * [{a: 1}, {a: 2}, {a: 3}, {a: 4}, {a: 5}, {a: 6}], // only 4 iterations
256
+ * P.differenceWith([{a: 2}, {a: 3}], P.isDeepEqual),
257
+ * P.take(2),
258
+ * ) // => [{a: 1}, {a: 4}]
259
+ * @dataLast
260
+ * @category Array
261
+ * @pipeable
262
+ */
263
+ declare function differenceWith<TFirst, TSecond>(other: ReadonlyArray<TSecond>, isEquals: IsEquals$1<TFirst, TSecond>): (array: ReadonlyArray<TFirst>) => Array<TFirst>;
264
+ declare namespace differenceWith {
265
+ function lazy<TFirst, TSecond>(other: ReadonlyArray<TSecond>, isEquals: IsEquals$1<TFirst, TSecond>): LazyEvaluator<TFirst>;
266
+ }
267
+
268
+ /**
269
+ * Removes last `n` elements from the `array`.
270
+ *
271
+ * @param array the target array
272
+ * @param n the number of elements to skip
273
+ * @signature
274
+ * P.dropLast(array, n)
275
+ * @example
276
+ * P.dropLast([1, 2, 3, 4, 5], 2) // => [1, 2, 3]
277
+ * @dataFirst
278
+ * @category Array
279
+ */
280
+ declare function dropLast<T>(array: ReadonlyArray<T>, n: number): Array<T>;
281
+ /**
282
+ * Removes last `n` elements from the `array`.
283
+ *
284
+ * @param n the number of elements to skip
285
+ * @signature
286
+ * P.dropLast(n)(array)
287
+ * @example
288
+ * P.dropLast(2)([1, 2, 3, 4, 5]) // => [1, 2, 3]
289
+ * @dataLast
290
+ * @category Array
291
+ */
292
+ declare function dropLast<T>(n: number): (array: ReadonlyArray<T>) => Array<T>;
293
+
294
+ /**
295
+ * Removes first `n` elements from the `array`.
296
+ *
297
+ * @param array the target array
298
+ * @param n the number of elements to skip
299
+ * @signature
300
+ * P.drop(array, n)
301
+ * @example
302
+ * P.drop([1, 2, 3, 4, 5], 2) // => [3, 4, 5]
303
+ * @dataFirst
304
+ * @pipeable
305
+ * @category Array
306
+ */
307
+ declare function drop<T>(array: ReadonlyArray<T>, n: number): Array<T>;
308
+ /**
309
+ * Removes first `n` elements from the `array`.
310
+ *
311
+ * @param n the number of elements to skip
312
+ * @signature
313
+ * P.drop(n)(array)
314
+ * @example
315
+ * P.drop(2)([1, 2, 3, 4, 5]) // => [3, 4, 5]
316
+ * @dataLast
317
+ * @pipeable
318
+ * @category Array
319
+ */
320
+ declare function drop<T>(n: number): (array: ReadonlyArray<T>) => Array<T>;
321
+ declare namespace drop {
322
+ function lazy<T>(n: number): LazyEvaluator<T>;
323
+ }
324
+
325
+ declare const COMPARATORS: {
326
+ readonly asc: <T>(x: T, y: T) => boolean;
327
+ readonly desc: <T_1>(x: T_1, y: T_1) => boolean;
328
+ };
329
+ /**
330
+ * An order rule defines a projection/extractor that returns a comparable from
331
+ * the data being compared. It would be run on each item being compared, and a
332
+ * comparator would then be used on the results to determine the order.
333
+ *
334
+ * There are 2 forms of the order rule, a simple one which only provides the
335
+ * projection function and assumes ordering is ascending, and a 2-tuple where
336
+ * the first element is the projection function and the second is the direction;
337
+ * this allows changing the direction without defining a more complex projection
338
+ * to simply negate the value (e.g. `(x) => -x`).
339
+ *
340
+ * We rely on the javascript implementation of `<` and `>` for comparison, which
341
+ * will attempt to transform both operands into a primitive comparable value via
342
+ * the built in `valueOf` function (and then `toString`). It's up to the caller
343
+ * to make sure that the projection is returning a value that makes sense for
344
+ * this logic.
345
+ *
346
+ * It's important to note that there is no built-in caching/memoization of
347
+ * projection function and therefore no guarantee that it would only be called
348
+ * once.
349
+ */
350
+ type OrderRule<T> = Projection<T> | readonly [projection: Projection<T>, direction: keyof typeof COMPARATORS];
351
+ type Projection<T> = (x: T) => Comparable;
352
+ type Comparable = {
353
+ [Symbol.toPrimitive]: (hint: string) => ComparablePrimitive;
354
+ } | {
355
+ toString: () => string;
356
+ } | {
357
+ valueOf: () => ComparablePrimitive;
358
+ } | ComparablePrimitive;
359
+ type ComparablePrimitive = boolean | number | string;
360
+
361
+ /**
362
+ * Drop the first `n` items from `data` based on the provided ordering criteria.
363
+ * This allows you to avoid sorting the array before dropping the items.
364
+ * The complexity of this function is *O(Nlogn)* where `N` is the length of the array.
365
+ *
366
+ * For the opposite operation (to keep `n` elements) see `takeFirstBy`.
367
+ *
368
+ * @params data - the input array
369
+ * @params n - the number of items to drop. If `n` is non-positive no items would be dropped and a *clone* of the input would be returned, if `n` is bigger then data.length no items would be returned.
370
+ * @param rules - A variadic array of order rules defining the sorting criteria. Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, "desc"]` for descending order.
371
+ * @returns a subset of the input array.
372
+ * @signature
373
+ * P.dropFirstBy(data, n, ...rules);
374
+ * @example
375
+ * P.dropFirstBy(['aa', 'aaaa', 'a', 'aaa'], 2, x => x.length); // => ['aaa', 'aaaa']
376
+ * @dataFirst
377
+ * @category Array
378
+ */
379
+ declare function dropFirstBy<T>(data: ReadonlyArray<T>, n: number, ...rules: Readonly<NonEmptyArray<OrderRule<T>>>): Array<T>;
380
+ /**
381
+ * Drop the first `n` items from `data` based on the provided ordering criteria. This allows you to avoid sorting the array before dropping the items. The complexity of this function is *O(Nlogn)* where `N` is the length of the array.
382
+ *
383
+ * For the opposite operation (to keep `n` elements) see `takeFirstBy`.
384
+ *
385
+ * @params n - the number of items to drop. If `n` is non-positive no items would be dropped and a *clone* of the input would be returned, if `n` is bigger then data.length no items would be returned.
386
+ * @param rules - A variadic array of order rules defining the sorting criteria. Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, "desc"]` for descending order.
387
+ * @returns a subset of the input array.
388
+ * @signature
389
+ * P.dropFirstBy(n, ...rules)(data);
390
+ * @example
391
+ * P.pipe(['aa', 'aaaa', 'a', 'aaa'], P.dropFirstBy(2, x => x.length)); // => ['aaa', 'aaaa']
392
+ * @dataLast
393
+ * @category Array
394
+ */
395
+ declare function dropFirstBy<T>(n: number, ...rules: Readonly<NonEmptyArray<OrderRule<T>>>): (data: ReadonlyArray<T>) => Array<T>;
396
+
397
+ /**
398
+ * Removes elements from the end of the array until the predicate returns false.
399
+ *
400
+ * The predicate is applied to each element in the array starting from the end and moving towards the beginning, until the predicate returns false. The returned array includes elements from the beginning of the array, up to and including the element that produced false for the predicate.
401
+ *
402
+ * @param data the array
403
+ * @param predicate the predicate
404
+ * @signature
405
+ * P.dropLastWhile(data, predicate)
406
+ * @example
407
+ * P.dropLastWhile([1, 2, 10, 3, 4], x => x < 10) // => [1, 2, 10]
408
+ * @dataFirst
409
+ * @category Array
410
+ */
411
+ declare function dropLastWhile<T>(data: ReadonlyArray<T>, predicate: (item: T) => boolean): Array<T>;
412
+ /**
413
+ * Removes elements from the end of the array until the predicate returns false.
414
+ *
415
+ * The predicate is applied to each element in the array starting from the end and moving towards the beginning, until the predicate returns false. The returned array includes elements from the beginning of the array, up to and including the element that produced false for the predicate.
416
+ *
417
+ * @param predicate the predicate
418
+ * @signature
419
+ * P.dropLastWhile(predicate)(data)
420
+ * @example
421
+ * P.pipe([1, 2, 10, 3, 4], P.dropLastWhile(x => x < 10)) // => [1, 2, 10]
422
+ * @dataLast
423
+ * @category Array
424
+ */
425
+ declare function dropLastWhile<T>(predicate: (item: T) => boolean): (data: ReadonlyArray<T>) => Array<T>;
426
+
427
+ /**
428
+ * Removes elements from the beginning of the array until the predicate returns false.
429
+ *
430
+ * The predicate is applied to each element in the array,
431
+ * until the predicate returns false.
432
+ * The returned array includes the rest of the elements,
433
+ * starting with the element that produced false for the predicate.
434
+ *
435
+ * @param data the array
436
+ * @param predicate the predicate
437
+ * @signature
438
+ * P.dropWhile(data, predicate)
439
+ * @example
440
+ * P.dropWhile([1, 2, 10, 3, 4], x => x < 10) // => [10, 3, 4]
441
+ * @dataFirst
442
+ * @category Array
443
+ */
444
+ declare function dropWhile<T>(data: ReadonlyArray<T>, predicate: (item: T) => boolean): Array<T>;
445
+ /**
446
+ * Removes elements from the beginning of the array until the predicate returns false.
447
+ *
448
+ * The predicate is applied to each element in the array, until the predicate returns false. The returned array includes the rest of the elements, starting with the element that produced false for the predicate.
449
+ *
450
+ * @param predicate the predicate
451
+ * @signature
452
+ * P.dropWhile(predicate)(data)
453
+ * @example
454
+ * P.pipe([1, 2, 10, 3, 4], P.dropWhile(x => x < 10)) // => [10, 3, 4]
455
+ * @dataLast
456
+ * @category Array
457
+ */
458
+ declare function dropWhile<T>(predicate: (item: T) => boolean): (data: ReadonlyArray<T>) => Array<T>;
459
+
460
+ /**
461
+ * Filter the elements of an array that meet the condition specified in a callback function.
462
+ *
463
+ * @param array The array to filter.
464
+ * @param fn the callback function.
465
+ * @signature
466
+ * P.filter(array, fn)
467
+ * P.filter.indexed(array, fn)
468
+ * @example
469
+ * P.filter([1, 2, 3], x => x % 2 === 1) // => [1, 3]
470
+ * P.filter.indexed([1, 2, 3], (x, i, array) => x % 2 === 1) // => [1, 3]
471
+ * // Excludes the values from `other` array
472
+ * P.filter(array, P.isNot(P.isIncludedIn(other)))
473
+ * // Returns a list of elements that exist in both array.
474
+ * P.filter(array, P.isIncludedIn(other))
475
+ * @dataFirst
476
+ * @indexed
477
+ * @pipeable
478
+ * @category Array
479
+ */
480
+ declare function filter<T, S extends T>(array: ReadonlyArray<T>, fn: (value: T) => value is S): Array<S>;
481
+ declare function filter<T>(array: ReadonlyArray<T>, fn: Pred<T, boolean>): Array<T>;
482
+ /**
483
+ * Filter the elements of an array that meet the condition specified in a callback function.
484
+ *
485
+ * @param fn the callback function.
486
+ * @signature
487
+ * P.filter(fn)(array)
488
+ * P.filter.indexed(fn)(array)
489
+ * @example
490
+ * P.pipe([1, 2, 3], P.filter(x => x % 2 === 1)) // => [1, 3]
491
+ * P.pipe([1, 2, 3], P.filter.indexed((x, i) => x % 2 === 1)) // => [1, 3]
492
+ * // Filter out all falsy values
493
+ * P.filter(P.isTruthy)
494
+ * // Counts how many values of the collection pass the specified predicate
495
+ * P.filter(fn).length
496
+ * // Excludes the values from `other` array
497
+ * P.filter(P.isNot(P.isIncludedIn(other)))
498
+ * // Returns a list of elements that exist in both array.
499
+ * P.filter(P.isIncludedIn(other))
500
+ * @dataLast
501
+ * @indexed
502
+ * @pipeable
503
+ * @category Array
504
+ */
505
+ declare function filter<T, S extends T>(fn: (input: T) => input is S): (array: ReadonlyArray<T>) => Array<S>;
506
+ declare function filter<T>(fn: Pred<T, boolean>): (array: ReadonlyArray<T>) => Array<T>;
507
+ declare namespace filter {
508
+ function indexed<T, S extends T>(array: ReadonlyArray<T>, fn: (input: T, index: number, array: ReadonlyArray<T>) => input is S): Array<S>;
509
+ function indexed<T>(array: ReadonlyArray<T>, fn: PredIndexed<T, boolean>): Array<T>;
510
+ /**
511
+ * @dataLast
512
+ */
513
+ function indexed<T, S extends T>(fn: (input: T, index: number, array: ReadonlyArray<T>) => input is S): (array: ReadonlyArray<T>) => Array<S>;
514
+ function indexed<T>(fn: PredIndexed<T, boolean>): (array: ReadonlyArray<T>) => Array<T>;
515
+ const lazy: <T>(fn: PredIndexedOptional<T, boolean>) => LazyEvaluator<T>;
516
+ const lazyIndexed: (<T>(fn: PredIndexedOptional<T, boolean>) => LazyEvaluator<T>) & {
517
+ readonly indexed: true;
518
+ };
519
+ }
520
+
521
+ /**
522
+ * Returns the index of the first element in the array where predicate is true, and -1 otherwise.
523
+ *
524
+ * @param items the array
525
+ * @param fn the predicate
526
+ * @signature
527
+ * P.findIndex(items, fn)
528
+ * P.findIndex.indexed(items, fn)
529
+ * @example
530
+ * P.findIndex([1, 3, 4, 6], n => n % 2 === 0) // => 2
531
+ * P.findIndex.indexed([1, 3, 4, 6], (n, i) => n % 2 === 0) // => 2
532
+ * @dataFirst
533
+ * @indexed
534
+ * @pipeable
535
+ * @category Array
536
+ */
537
+ declare function findIndex<T>(items: ReadonlyArray<T>, fn: Pred<T, boolean>): number;
538
+ /**
539
+ * Returns the index of the first element in the array where predicate is true, and -1 otherwise.
540
+ *
541
+ * @param fn the predicate
542
+ * @signature
543
+ * P.findIndex(fn)(items)
544
+ * P.findIndex.indexed(fn)(items)
545
+ * @example
546
+ * P.pipe(
547
+ * [1, 3, 4, 6],
548
+ * P.findIndex(n => n % 2 === 0)
549
+ * ) // => 2
550
+ * P.pipe(
551
+ * [1, 3, 4, 6],
552
+ * P.findIndex.indexed((n, i) => n % 2 === 0)
553
+ * ) // => 2
554
+ * @dataLast
555
+ * @indexed
556
+ * @pipeable
557
+ * @category Array
558
+ */
559
+ declare function findIndex<T>(fn: Pred<T, boolean>): (items: ReadonlyArray<T>) => number;
560
+ declare namespace findIndex {
561
+ function indexed<T>(array: ReadonlyArray<T>, fn: PredIndexed<T, boolean>): number;
562
+ function indexed<T>(fn: PredIndexed<T, boolean>): (array: ReadonlyArray<T>) => number;
563
+ const lazy: (<T>(fn: PredIndexedOptional<T, boolean>) => LazyEvaluator<T, number>) & {
564
+ readonly single: true;
565
+ };
566
+ const lazyIndexed: (<T>(fn: PredIndexedOptional<T, boolean>) => LazyEvaluator<T, number>) & {
567
+ readonly indexed: true;
568
+ } & {
569
+ readonly single: true;
570
+ };
571
+ }
572
+
573
+ /**
574
+ * Returns the index of the last element in the array where predicate is true, and -1 otherwise.
575
+ *
576
+ * @param array the array
577
+ * @param fn the predicate
578
+ * @signature
579
+ * P.findLastIndex(items, fn)
580
+ * P.findLastIndex.indexed(items, fn)
581
+ * @example
582
+ * P.findLastIndex([1, 3, 4, 6], n => n % 2 === 1) // => 1
583
+ * P.findLastIndex.indexed([1, 3, 4, 6], (n, i) => n % 2 === 1) // => 1
584
+ * @dataFirst
585
+ * @indexed
586
+ * @pipeable
587
+ * @category Array
588
+ */
589
+ declare function findLastIndex<T>(array: ReadonlyArray<T>, fn: Pred<T, boolean>): number;
590
+ /**
591
+ * Returns the index of the last element in the array where predicate is true, and -1 otherwise.
592
+ *
593
+ * @param fn the predicate
594
+ * @signature
595
+ * P.findLastIndex(fn)(items)
596
+ * P.findLastIndex.indexed(fn)(items)
597
+ * @example
598
+ * P.pipe(
599
+ * [1, 3, 4, 6],
600
+ * P.findLastIndex(n => n % 2 === 1)
601
+ * ) // => 1
602
+ * P.pipe(
603
+ * [1, 3, 4, 6],
604
+ * P.findLastIndex.indexed((n, i) => n % 2 === 1)
605
+ * ) // => 1
606
+ * @dataLast
607
+ * @indexed
608
+ * @pipeable
609
+ * @category Array
610
+ */
611
+ declare function findLastIndex<T>(fn: Pred<T, boolean>): (array: ReadonlyArray<T>) => number;
612
+ declare namespace findLastIndex {
613
+ function indexed<T>(array: ReadonlyArray<T>, fn: PredIndexed<T, boolean>): number;
614
+ function indexed<T>(fn: PredIndexed<T, boolean>): (array: ReadonlyArray<T>) => number;
615
+ }
616
+
617
+ /**
618
+ * Returns the value of the last element in the array where predicate is true, and undefined
619
+ * otherwise.
620
+ * @param array the array
621
+ * @param fn the predicate
622
+ * @signature
623
+ * P.findLast(items, fn)
624
+ * P.findLast.indexed(items, fn)
625
+ * @example
626
+ * P.findLast([1, 3, 4, 6], n => n % 2 === 1) // => 3
627
+ * P.findLast.indexed([1, 3, 4, 6], (n, i) => n % 2 === 1) // => 3
628
+ * @dataFirst
629
+ * @indexed
630
+ * @pipeable
631
+ * @category Array
632
+ */
633
+ declare function findLast<T>(array: ReadonlyArray<T>, fn: Pred<T, boolean>): T | undefined;
634
+ /**
635
+ * Returns the value of the last element in the array where predicate is true, and undefined
636
+ * otherwise.
637
+ * @param fn the predicate
638
+ * @signature
639
+ * P.findLast(fn)(items)
640
+ * P.findLast.indexed(fn)(items)
641
+ * @example
642
+ * P.pipe(
643
+ * [1, 3, 4, 6],
644
+ * P.findLast(n => n % 2 === 1)
645
+ * ) // => 3
646
+ * P.pipe(
647
+ * [1, 3, 4, 6],
648
+ * P.findLast.indexed((n, i) => n % 2 === 1)
649
+ * ) // => 3
650
+ * @dataLast
651
+ * @indexed
652
+ * @pipeable
653
+ * @category Array
654
+ */
655
+ declare function findLast<T = never>(fn: Pred<T, boolean>): (array: ReadonlyArray<T>) => T | undefined;
656
+ declare namespace findLast {
657
+ function indexed<T>(array: ReadonlyArray<T>, fn: PredIndexed<T, boolean>): T | undefined;
658
+ function indexed<T>(fn: PredIndexed<T, boolean>): (array: ReadonlyArray<T>) => T | undefined;
659
+ }
660
+
661
+ /**
662
+ * Returns the value of the first element in the array where predicate is true, and undefined otherwise.
663
+ * @param items the array
664
+ * @param fn the predicate
665
+ * @signature
666
+ * P.find(items, fn)
667
+ * P.find.indexed(items, fn)
668
+ * @example
669
+ * P.find([1, 3, 4, 6], n => n % 2 === 0) // => 4
670
+ * P.find.indexed([1, 3, 4, 6], (n, i) => n % 2 === 0) // => 4
671
+ * @dataFirst
672
+ * @indexed
673
+ * @pipeable
674
+ * @category Array
675
+ */
676
+ declare function find<T>(items: ReadonlyArray<T>, fn: Pred<T, boolean>): T | undefined;
677
+ /**
678
+ * Returns the value of the first element in the array where predicate is true, and undefined otherwise.
679
+ * @param fn the predicate
680
+ * @signature
681
+ * P.find(fn)(items)
682
+ * P.find.indexed(fn)(items)
683
+ * @example
684
+ * P.pipe(
685
+ * [1, 3, 4, 6],
686
+ * P.find(n => n % 2 === 0)
687
+ * ) // => 4
688
+ * P.pipe(
689
+ * [1, 3, 4, 6],
690
+ * P.find.indexed((n, i) => n % 2 === 0)
691
+ * ) // => 4
692
+ * @dataLast
693
+ * @indexed
694
+ * @pipeable
695
+ * @category Array
696
+ */
697
+ declare function find<T = never>(fn: Pred<T, boolean>): (array: ReadonlyArray<T>) => T | undefined;
698
+ declare namespace find {
699
+ function indexed<T>(array: ReadonlyArray<T>, fn: PredIndexed<T, boolean>): T | undefined;
700
+ function indexed<T>(fn: PredIndexed<T, boolean>): (array: ReadonlyArray<T>) => T | undefined;
701
+ const lazy: (<T>(fn: PredIndexedOptional<T, boolean>) => LazyEvaluator<T>) & {
702
+ readonly single: true;
703
+ };
704
+ const lazyIndexed: (<T>(fn: PredIndexedOptional<T, boolean>) => LazyEvaluator<T>) & {
705
+ readonly indexed: true;
706
+ } & {
707
+ readonly single: true;
708
+ };
709
+ }
710
+
711
+ type FirstOut<T extends IterableContainer> = T extends [] ? undefined : T extends readonly [unknown, ...Array<unknown>] ? T[0] : T extends readonly [...infer Pre, infer Last] ? Last | Pre[0] : T[0] | undefined;
712
+ /**
713
+ * Gets the first element of `array`.
714
+ * Note: In `pipe`, use `first()` form instead of `first`. Otherwise, the inferred type is lost.
715
+ * @param array the array
716
+ * @signature
717
+ * P.first(array)
718
+ * @example
719
+ * P.first([1, 2, 3]) // => 1
720
+ * P.first([]) // => undefined
721
+ * P.pipe(
722
+ * [1, 2, 4, 8, 16],
723
+ * P.filter(x => x > 3),
724
+ * P.first(),
725
+ * x => x + 1
726
+ * ); // => 5
727
+ *
728
+ * @category Array
729
+ * @pipeable
730
+ */
731
+ declare function first<T extends IterableContainer>(array: Readonly<T>): FirstOut<T>;
732
+ declare function first<T extends IterableContainer>(): (array: Readonly<T>) => FirstOut<T>;
733
+ declare namespace first {
734
+ function lazy<T>(): LazyEvaluator<T>;
735
+ namespace lazy {
736
+ const single = true;
737
+ }
738
+ }
739
+
740
+ type FirstBy<T extends IterableContainer> = (T extends readonly [unknown, ...ReadonlyArray<unknown>] ? never : T extends readonly [...ReadonlyArray<unknown>, unknown] ? never : undefined) | T[number];
741
+ /**
742
+ * Find the first element in the array that adheres to the order rules provided. This is a superset of what a typical `maxBy` or `minBy` function would do as it allows defining "tie-breaker" rules when values are equal, and allows comparing items using any logic. This function is equivalent to calling `P.first(P.sortBy(...))` but runs at *O(n)* instead of *O(nlogn)*.
743
+ *
744
+ * Use `nthBy` if you need an element other that the first, or `takeFirstBy` if you more than just the first element.
745
+ *
746
+ * @param rules - A variadic array of order rules defining the sorting criteria. Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, "desc"]` for descending ordeP.
747
+ * @returns the first element by the order criteria, or `undefined` if the array
748
+ * is empty. (The function provides strong typing if the input type assures the
749
+ * array isn't empty).
750
+ * @signature
751
+ * P.firstBy(...rules)(data);
752
+ * @example
753
+ * const max = P.pipe([1,2,3], P.firstBy([P.identity, "desc"])); // => 3;
754
+ * const min = P.pipe([1,2,3], P.firstBy([1,2,3])); // => 1;
755
+ *
756
+ * const data = [{ a: "a" }, { a: "aa" }, { a: "aaa" }] as const;
757
+ * const maxBy = P.pipe(data, P.firstBy([(item) => item.a.length, "desc"])); // => { a: "aaa" };
758
+ * const minBy = P.pipe(data, P.firstBy((item) => item.a.length)); // => { a: "a" };
759
+ *
760
+ * const data = [{type: "cat", size: 1}, {type: "cat", size: 2}, {type: "dog", size: 3}] as const;
761
+ * const multi = P.pipe(data, P.firstBy(P.prop('type'), [P.prop('size'), 'desc'])); // => {type: "cat", size: 2}
762
+ * @dataLast
763
+ * @category Array
764
+ */
765
+ declare function firstBy<T extends IterableContainer>(...rules: Readonly<NonEmptyArray<OrderRule<T[number]>>>): (data: T) => FirstBy<T>;
766
+ /**
767
+ * Find the first element in the array that adheres to the order rules provided. This is a superset of what a typical `maxBy` or `minBy` function would do as it allows defining "tie-breaker" rules when values are equal, and allows comparing items using any logic. This function is equivalent to calling `P.first(P.sortBy(...))` but runs at *O(n)* instead of *O(nlogn)*.
768
+ *
769
+ * Use `nthBy` if you need an element other that the first, or `takeFirstBy` if you more than just the first element.
770
+ *
771
+ * @param data an array of items
772
+ * @param rules - A variadic array of order rules defining the sorting criteria. Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, "desc"]` for descending ordeP.
773
+ * @returns the first element by the order criteria, or `undefined` if the array
774
+ * is empty. (The function provides strong typing if the input type assures the
775
+ * array isn't empty).
776
+ * @signature
777
+ * P.firstBy(data, ...rules);
778
+ * @example
779
+ * const max = P.firstBy([1,2,3], [P.identity, "desc"]); // => 3;
780
+ * const min = P.firstBy([1,2,3], P.identity); // => 1;
781
+ *
782
+ * const data = [{ a: "a" }, { a: "aa" }, { a: "aaa" }] as const;
783
+ * const maxBy = P.firstBy(data, [(item) => item.a.length, "desc"]); // => { a: "aaa" };
784
+ * const minBy = P.firstBy(data, (item) => item.a.length); // => { a: "a" };
785
+ *
786
+ * const data = [{type: "cat", size: 1}, {type: "cat", size: 2}, {type: "dog", size: 3}] as const;
787
+ * const multi = P.firstBy(data, P.prop('type'), [P.prop('size'), 'desc']); // => {type: "cat", size: 2}
788
+ * @dataFirst
789
+ * @category Array
790
+ */
791
+ declare function firstBy<T extends IterableContainer>(data: T, ...rules: Readonly<NonEmptyArray<OrderRule<T[number]>>>): FirstBy<T>;
792
+
793
+ /**
794
+ * Map each element of an array into an object using a defined callback function and flatten the result.
795
+ * @param array The array to map.
796
+ * @param fn The mapping function, which should return an Array of key-value pairs, similar to Object.fromEntries
797
+ * @returns The new mapped object.
798
+ * @signature
799
+ * P.flatMapToObj(array, fn)
800
+ * P.flatMapToObj.indexed(array, fn)
801
+ * @example
802
+ * P.flatMapToObj([1, 2, 3], (x) =>
803
+ * x % 2 === 1 ? [[String(x), x]] : []
804
+ * ) // => {1: 1, 3: 3}
805
+ * P.flatMapToObj.indexed(['a', 'b'], (x, i) => [
806
+ * [x, i],
807
+ * [x + x, i + i],
808
+ * ]) // => {a: 0, aa: 0, b: 1, bb: 2}
809
+ * @dataFirst
810
+ * @indexed
811
+ * @category Array
812
+ */
813
+ declare function flatMapToObj<T, K extends PropertyKey, V>(array: ReadonlyArray<T>, fn: (element: T) => Array<[K, V]>): Record<K, V>;
814
+ /**
815
+ * Map each element of an array into an object using a defined callback function and flatten the result.
816
+ * @param fn The mapping function, which should return an Array of key-value pairs, similar to Object.fromEntries
817
+ * @returns The new mapped object.
818
+ * @signature
819
+ * P.flatMapToObj(fn)(array)
820
+ * P.flatMapToObj(fn)(array)
821
+ * @example
822
+ * P.pipe(
823
+ * [1, 2, 3],
824
+ * P.flatMapToObj(x => (x % 2 === 1 ? [[String(x), x]] : []))
825
+ * ) // => {1: 1, 3: 3}
826
+ * P.pipe(
827
+ * ['a', 'b'],
828
+ * P.flatMapToObj.indexed((x, i) => [
829
+ * [x, i],
830
+ * [x + x, i + i],
831
+ * ])
832
+ * ) // => {a: 0, aa: 0, b: 1, bb: 2}
833
+ * @dataLast
834
+ * @indexed
835
+ * @category Array
836
+ */
837
+ declare function flatMapToObj<T, K extends PropertyKey, V>(fn: (element: T) => Array<[K, V]>): (array: ReadonlyArray<T>) => Record<K, V>;
838
+ declare namespace flatMapToObj {
839
+ function indexed<T, K extends PropertyKey, V>(array: ReadonlyArray<T>, fn: (element: T, index: number, array: ReadonlyArray<T>) => Array<[K, V]>): Record<K, V>;
840
+ function indexed<T, K extends PropertyKey, V>(fn: (element: T, index: number, array: ReadonlyArray<T>) => Array<[K, V]>): (array: ReadonlyArray<T>) => Record<K, V>;
841
+ }
842
+
843
+ /**
844
+ * Map each element of an array using a defined callback function and flatten the mapped result.
845
+ *
846
+ * @param array The array to map.
847
+ * @param fn The function mapper.
848
+ * @signature
849
+ * P.flatMap(array, fn)
850
+ * @example
851
+ * P.flatMap([1, 2, 3], x => [x, x * 10]) // => [1, 10, 2, 20, 3, 30]
852
+ * @dataFirst
853
+ * @pipeable
854
+ * @category Array
855
+ */
856
+ declare function flatMap<T, K>(array: ReadonlyArray<T>, fn: (input: T) => K | ReadonlyArray<K>): Array<K>;
857
+ /**
858
+ * Map each element of an array using a defined callback function and flatten the mapped result.
859
+ *
860
+ * @param fn The function mapper.
861
+ * @signature
862
+ * P.flatMap(fn)(array)
863
+ * @example
864
+ * P.pipe([1, 2, 3], P.flatMap(x => [x, x * 10])) // => [1, 10, 2, 20, 3, 30]
865
+ * @dataLast
866
+ * @pipeable
867
+ * @category Array
868
+ */
869
+ declare function flatMap<T, K>(fn: (input: T) => K | ReadonlyArray<K>): (array: ReadonlyArray<T>) => Array<K>;
870
+ declare namespace flatMap {
871
+ function lazy<T, K>(fn: (input: T) => K | ReadonlyArray<K>): LazyEvaluator<T, K>;
872
+ }
873
+
874
+ type FlattenDeep<T> = T extends ReadonlyArray<infer K> ? FlattenDeep2<K> : T;
875
+ type FlattenDeep2<T> = T extends ReadonlyArray<infer K> ? FlattenDeep3<K> : T;
876
+ type FlattenDeep3<T> = T extends ReadonlyArray<infer K> ? FlattenDeep4<K> : T;
877
+ type FlattenDeep4<T> = T extends ReadonlyArray<infer K> ? K : T;
878
+ /**
879
+ * Recursively flattens `array`.
880
+ *
881
+ * @param items the target array
882
+ * @signature
883
+ * P.flattenDeep(array)
884
+ * @example
885
+ * P.flattenDeep([[1, 2], [[3], [4, 5]]]) // => [1, 2, 3, 4, 5]
886
+ * @pipeable
887
+ * @category Array
888
+ */
889
+ declare function flattenDeep<T>(items: ReadonlyArray<T>): Array<FlattenDeep<T>>;
890
+ /**
891
+ * Recursively flattens `array`.
892
+ *
893
+ * @signature
894
+ * P.flattenDeep()(array)
895
+ * @example
896
+ * P.pipe(
897
+ * [[1, 2], [[3], [4, 5]]],
898
+ * P.flattenDeep(),
899
+ * ); // => [1, 2, 3, 4, 5]
900
+ * @dataLast
901
+ * @pipeable
902
+ * @category Array
903
+ */
904
+ declare function flattenDeep<T>(): (items: ReadonlyArray<T>) => Array<FlattenDeep<T>>;
905
+ declare namespace flattenDeep {
906
+ function lazy<T>(): LazyEvaluator<T, any>;
907
+ }
908
+
909
+ type Flatten<T> = T extends ReadonlyArray<infer K> ? K : T;
910
+ /**
911
+ * Flattens `array` a single level deep.
912
+ *
913
+ * @param items the target array
914
+ * @signature
915
+ * P.flatten(array)
916
+ * @example
917
+ * P.flatten([[1, 2], [3], [4, 5]]) // => [1, 2, 3, 4, 5]
918
+ * P.pipe(
919
+ * [[1, 2], [3], [4, 5]],
920
+ * P.flatten(),
921
+ * ); // => [1, 2, 3, 4, 5]
922
+ * @dataFirst
923
+ * @pipeable
924
+ * @category Array
925
+ */
926
+ declare function flatten<T>(items: ReadonlyArray<T>): Array<Flatten<T>>;
927
+ /**
928
+ * Flattens `array` a single level deep.
929
+ *
930
+ * @signature
931
+ * P.flatten()(array)
932
+ * @example
933
+ * P.pipe(
934
+ * [[1, 2], [3], [4, 5]],
935
+ * P.flatten(),
936
+ * ); // => [1, 2, 3, 4, 5]
937
+ * @dataLast
938
+ * @pipeable
939
+ * @category Array
940
+ */
941
+ declare function flatten<T>(): (items: ReadonlyArray<T>) => Array<Flatten<T>>;
942
+ declare namespace flatten {
943
+ function lazy<T>(): LazyEvaluator<T, Flatten<T>>;
944
+ }
945
+
946
+ /**
947
+ * Iterate an array using a defined callback function. The original array is returned instead of `void`.
948
+ * @param array The array.
949
+ * @param fn The callback function.
950
+ * @returns The original array
951
+ * @signature
952
+ * P.forEach(array, fn)
953
+ * P.forEach.indexed(array, fn)
954
+ * @example
955
+ * P.forEach([1, 2, 3], x => {
956
+ * console.log(x)
957
+ * }) // => [1, 2, 3]
958
+ * P.forEach.indexed([1, 2, 3], (x, i) => {
959
+ * console.log(x, i)
960
+ * }) // => [1, 2, 3]
961
+ * @dataFirst
962
+ * @indexed
963
+ * @pipeable
964
+ * @category Array
965
+ */
966
+ declare function forEach<T>(array: ReadonlyArray<T>, fn: Pred<T, void>): Array<T>;
967
+ /**
968
+ * Iterate an array using a defined callback function. The original array is returned instead of `void`.
969
+ * @param fn the function mapper
970
+ * @signature
971
+ * P.forEach(fn)(array)
972
+ * P.forEach.indexed(fn)(array)
973
+ * @example
974
+ * P.pipe(
975
+ * [1, 2, 3],
976
+ * P.forEach(x => {
977
+ * console.log(x)
978
+ * })
979
+ * ) // => [1, 2, 3]
980
+ * P.pipe(
981
+ * [1, 2, 3],
982
+ * P.forEach.indexed((x, i) => {
983
+ * console.log(x, i)
984
+ * })
985
+ * ) // => [1, 2, 3]
986
+ * @dataLast
987
+ * @indexed
988
+ * @pipeable
989
+ * @category Array
990
+ */
991
+ declare function forEach<T>(fn: Pred<T, void>): (array: ReadonlyArray<T>) => Array<T>;
992
+ declare namespace forEach {
993
+ function indexed<T>(array: ReadonlyArray<T>, fn: PredIndexed<T, void>): Array<T>;
994
+ function indexed<T>(fn: PredIndexed<T, void>): (array: ReadonlyArray<T>) => Array<T>;
995
+ const lazy: <T>(fn: PredIndexedOptional<T, void>) => LazyEvaluator<T>;
996
+ const lazyIndexed: (<T>(fn: PredIndexedOptional<T, void>) => LazyEvaluator<T>) & {
997
+ readonly indexed: true;
998
+ };
999
+ }
1000
+
1001
+ interface Strict$7 {
1002
+ <Value, Key extends PropertyKey = PropertyKey>(items: ReadonlyArray<Value>, fn: (item: Value) => Key | undefined): StrictOut$2<Value, Key>;
1003
+ <Value, Key extends PropertyKey = PropertyKey>(fn: (item: Value) => Key | undefined): (items: ReadonlyArray<Value>) => StrictOut$2<Value, Key>;
1004
+ readonly indexed: {
1005
+ <Value, Key extends PropertyKey = PropertyKey>(fn: PredIndexed<Value, Key | undefined>): (items: ReadonlyArray<Value>) => StrictOut$2<Value, Key>;
1006
+ <Value, Key extends PropertyKey = PropertyKey>(items: ReadonlyArray<Value>, fn: PredIndexed<Value, Key | undefined>): StrictOut$2<Value, Key>;
1007
+ };
1008
+ }
1009
+ type StrictOut$2<Value, Key extends PropertyKey = PropertyKey> = string extends Key ? Record<Key, NonEmptyArray<Value>> : number extends Key ? Record<Key, NonEmptyArray<Value>> : symbol extends Key ? Record<Key, NonEmptyArray<Value>> : Partial<Record<Key, NonEmptyArray<Value>>>;
1010
+ /**
1011
+ * Splits a collection into sets, grouped by the result of running each value through `fn`.
1012
+ *
1013
+ * @param items the items to group
1014
+ * @param fn the grouping function. When `undefined` is returned the item would
1015
+ * be skipped and not grouped under any key.
1016
+ * @signature
1017
+ * P.groupBy(array, fn)
1018
+ * P.groupBy.strict(array, fn)
1019
+ * @example
1020
+ * P.groupBy(['one', 'two', 'three'], x => x.length) // => {3: ['one', 'two'], 5: ['three']}
1021
+ * P.groupBy.strict([{a: 'cat'}, {a: 'dog'}] as const, prop('a')) // => {cat: [{a: 'cat'}], dog: [{a: 'dog'}]} typed Partial<Record<'cat' | 'dog', NonEmptyArray<{a: 'cat' | 'dog'}>>>
1022
+ * P.groupBy([0, 1], x => x % 2 === 0 ? 'even' : undefined) // => {even: [0]}
1023
+ * @dataFirst
1024
+ * @indexed
1025
+ * @strict
1026
+ * @category Array
1027
+ */
1028
+ declare function groupBy<T>(items: ReadonlyArray<T>, fn: (item: T) => PropertyKey | undefined): Record<PropertyKey, NonEmptyArray<T>>;
1029
+ declare function groupBy<T>(fn: (item: T) => PropertyKey | undefined): (array: ReadonlyArray<T>) => Record<PropertyKey, NonEmptyArray<T>>;
1030
+ declare namespace groupBy {
1031
+ function indexed<T>(array: ReadonlyArray<T>, fn: PredIndexed<T, PropertyKey | undefined>): Record<string, NonEmptyArray<T>>;
1032
+ function indexed<T>(fn: PredIndexed<T, PropertyKey | undefined>): (array: ReadonlyArray<T>) => Record<string, NonEmptyArray<T>>;
1033
+ const strict: Strict$7;
1034
+ }
1035
+
1036
+ type ArrayMinN<T, N extends number> = number extends N ? Array<T> : N extends 0 ? Array<T> : [...ReadonlyTuple<T, N>, ...Array<T>];
1037
+ /**
1038
+ * Checks if the given array has at least the defined number of elements, and
1039
+ * refines the output type accordingly so that those indices are defined when
1040
+ * accessing the array even when using typescript's 'noUncheckedIndexAccess'.
1041
+ *
1042
+ * @param data the input array
1043
+ * @param minimum the minimum number of elements the array must have
1044
+ * @return true if the array's length is *at least* `minimum`.
1045
+ * @signature
1046
+ * P.hasAtLeast(data, minimum)
1047
+ * @example
1048
+ * P.hasAtLeast([], 4); // => false
1049
+ *
1050
+ * const data: number[] = [1,2,3,4];
1051
+ * P.hasAtLeast(data, 1); // => true
1052
+ * data[0]; // 1, with type `number`
1053
+ * @dataFirst
1054
+ * @category Array
1055
+ */
1056
+ declare function hasAtLeast<T, N extends number>(data: ReadonlyArray<T>, minimum: N): data is ArrayMinN<T, N>;
1057
+ /**
1058
+ * Checks if the given array has at least the defined number of elements, and
1059
+ * refines the output type accordingly so that those indices are defined when
1060
+ * accessing the array even when using typescript's 'noUncheckedIndexAccess'.
1061
+ *
1062
+ * @param minimum the minimum number of elements the array must have
1063
+ * @return true if the array's length is *at least* `minimum`.
1064
+ * @signature
1065
+ * P.hasAtLeast(minimum)(data)
1066
+ * @example
1067
+ * P.pipe([], P.hasAtLeast(4)); // => false
1068
+ *
1069
+ * const data = [[1,2], [3], [4,5]];
1070
+ * P.pipe(
1071
+ * data,
1072
+ * P.filter(P.hasAtLeast(2)),
1073
+ * P.map(([, second]) => second),
1074
+ * ); // => [2,5], with type `number[]`
1075
+ * @dataLast
1076
+ * @category Array
1077
+ */
1078
+ declare function hasAtLeast<N extends number>(minimum: N): <T>(data: ReadonlyArray<T>) => data is ArrayMinN<T, N>;
1079
+
1080
+ declare function indexByStrict<K extends PropertyKey, T>(array: ReadonlyArray<T>, fn: (item: T) => K): Partial<Record<K, T>>;
1081
+ declare function indexByStrict<K extends PropertyKey, T>(fn: (item: T) => K): (array: ReadonlyArray<T>) => Partial<Record<K, T>>;
1082
+ /**
1083
+ * Converts a list of objects into an object indexing the objects by the given key (casted to a string).
1084
+ * Use the strict version to maintain the given key's type, so long as it is a valid `PropertyKey`.
1085
+ *
1086
+ * @param array the array
1087
+ * @param fn the indexing function
1088
+ * @signature
1089
+ * P.indexBy(array, fn)
1090
+ * P.indexBy.strict(array, fn)
1091
+ * @example
1092
+ * P.indexBy(['one', 'two', 'three'], x => x.length) // => {"3": 'two', "5": 'three'}
1093
+ * P.indexBy.strict(['one', 'two', 'three'], x => x.length) // => {3: 'two', 5: 'three'}
1094
+ * @dataFirst
1095
+ * @indexed
1096
+ * @category Array
1097
+ * @strict
1098
+ */
1099
+ declare function indexBy<T>(array: ReadonlyArray<T>, fn: (item: T) => unknown): Record<string, T>;
1100
+ /**
1101
+ * Converts a list of objects into an object indexing the objects by the given key.
1102
+ * (casted to a string). Use the strict version to maintain the given key's type, so
1103
+ * long as it is a valid `PropertyKey`.
1104
+ *
1105
+ * @param fn the indexing function
1106
+ * @signature
1107
+ * P.indexBy(fn)(array)
1108
+ * P.indexBy.strict(fn)(array)
1109
+ * @example
1110
+ * P.pipe(
1111
+ * ['one', 'two', 'three'],
1112
+ * P.indexBy(x => x.length)
1113
+ * ) // => {"3": 'two', "5": 'three'}
1114
+ * P.pipe(
1115
+ * ['one', 'two', 'three'],
1116
+ * P.indexBy.strict(x => x.length)
1117
+ * ) // => {3: 'two', 5: 'three'}
1118
+ * @dataLast
1119
+ * @indexed
1120
+ * @category Array
1121
+ * @strict
1122
+ */
1123
+ declare function indexBy<T>(fn: (item: T) => unknown): (array: ReadonlyArray<T>) => Record<string, T>;
1124
+ declare namespace indexBy {
1125
+ function indexed<T>(array: ReadonlyArray<T>, fn: PredIndexed<T, unknown>): Record<string, T>;
1126
+ function indexed<T>(fn: PredIndexed<T, unknown>): (array: ReadonlyArray<T>) => Record<string, T>;
1127
+ const strict: typeof indexByStrict;
1128
+ }
1129
+
1130
+ type Comparator<TFirst, TSecond> = (a: TFirst, b: TSecond) => boolean;
1131
+ /**
1132
+ * Returns a list of intersecting values based on a custom
1133
+ * comparator function that compares elements of both arrays.
1134
+ * @param array the source array
1135
+ * @param other the second array
1136
+ * @param comparator the custom comparator
1137
+ * @signature
1138
+ * P.intersectionWith(array, other, comparator)
1139
+ * @example
1140
+ * P.intersectionWith(
1141
+ * [
1142
+ * { id: 1, name: 'Ryan' },
1143
+ * { id: 3, name: 'Emma' },
1144
+ * ],
1145
+ * [3, 5],
1146
+ * (a, b) => a.id === b,
1147
+ * ) // => [{ id: 3, name: 'Emma' }]
1148
+ * @dataFirst
1149
+ * @category Array
1150
+ * @pipeable
1151
+ */
1152
+ declare function intersectionWith<TFirst, TSecond>(array: ReadonlyArray<TFirst>, other: ReadonlyArray<TSecond>, comparator: Comparator<TFirst, TSecond>): Array<TFirst>;
1153
+ /**
1154
+ * Returns a list of intersecting values based on a custom
1155
+ * comparator function that compares elements of both arrays.
1156
+ * @param other the second array
1157
+ * @param comparator the custom comparator
1158
+ * @signature
1159
+ * P.intersectionWith(other, comparator)(array)
1160
+ * @example
1161
+ * P.intersectionWith(
1162
+ * [3, 5],
1163
+ * (a, b) => a.id === b
1164
+ * )([
1165
+ * { id: 1, name: 'Ryan' },
1166
+ * { id: 3, name: 'Emma' },
1167
+ * ]); // => [{ id: 3, name: 'Emma' }]
1168
+ * @dataLast
1169
+ * @category Array
1170
+ * @pipeable
1171
+ */
1172
+ declare function intersectionWith<TFirst, TSecond>(other: ReadonlyArray<TSecond>,
1173
+ /**
1174
+ * type inference doesn't work properly for the comparator's first parameter
1175
+ * in data last variant
1176
+ */
1177
+ comparator: Comparator<TFirst, TSecond>): (array: ReadonlyArray<TFirst>) => Array<TFirst>;
1178
+ declare namespace intersectionWith {
1179
+ function lazy<TFirst, TSecond>(other: ReadonlyArray<TSecond>, comparator: Comparator<TFirst, TSecond>): LazyEvaluator<TFirst>;
1180
+ }
1181
+
1182
+ type Joinable = bigint | boolean | null | number | string | undefined;
1183
+ type Joined<T extends IterableContainer, Glue extends string> = T[number] extends never ? '' : T extends readonly [Joinable?] ? `${NullishCoalesce<T[0], ''>}` : T extends readonly [infer First, ...infer Tail] ? `${NullishCoalesce<First, ''>}${Glue}${Joined<Tail, Glue>}` : T extends readonly [...infer Head, infer Last] ? `${Joined<Head, Glue>}${Glue}${NullishCoalesce<Last, ''>}` : string;
1184
+ type NullishCoalesce<T, Fallback> = T extends Joinable ? T extends null | undefined ? Fallback | NonNullable<T> : T : never;
1185
+ /**
1186
+ * Joins the elements of the array by: casting them to a string and
1187
+ * concatenating them one to the other, with the provided glue string in between
1188
+ * every two elements.
1189
+ *
1190
+ * When called on a tuple and with stricter item types (union of literal values,
1191
+ * the result is strictly typed to the tuples shape and it's item types).
1192
+ *
1193
+ * @param data The array to join
1194
+ * @param glue The string to put in between every two elements
1195
+ * @signature
1196
+ * P.join(data, glue)
1197
+ * @example
1198
+ * P.join([1,2,3], ",") // => "1,2,3" (typed `string`)
1199
+ * P.join(['a','b','c'], "") // => "abc" (typed `string`)
1200
+ * P.join(['hello', 'world'] as const, " ") // => "hello world" (typed `hello world`)
1201
+ * @dataFirst
1202
+ * @category Array
1203
+ */
1204
+ declare function join<T extends [] | ReadonlyArray<Joinable>, Glue extends string>(data: T, glue: Glue): Joined<T, Glue>;
1205
+ /**
1206
+ * Joins the elements of the array by: casting them to a string and
1207
+ * concatenating them one to the other, with the provided glue string in between
1208
+ * every two elements.
1209
+ *
1210
+ * When called on a tuple and with stricter item types (union of literal values,
1211
+ * the result is strictly typed to the tuples shape and it's item types).
1212
+ *
1213
+ * @param glue The string to put in between every two elements
1214
+ * @signature
1215
+ * P.join(glue)(data)
1216
+ * @example
1217
+ * P.pipe([1,2,3], P.join(",")) // => "1,2,3" (typed `string`)
1218
+ * P.pipe(['a','b','c'], P.join("")) // => "abc" (typed `string`)
1219
+ * P.pipe(['hello', 'world'] as const, P.join(" ")) // => "hello world" (typed `hello world`)
1220
+ * @dataLast
1221
+ * @category Array
1222
+ */
1223
+ declare function join<T extends [] | ReadonlyArray<Joinable>, Glue extends string>(glue: Glue): (data: T) => Joined<T, Glue>;
1224
+
1225
+ /**
1226
+ * Gets the last element of `array`.
1227
+ *
1228
+ * @param array the array
1229
+ * @signature
1230
+ * P.last(array)
1231
+ * @example
1232
+ * P.last([1, 2, 3]) // => 3
1233
+ * P.last([]) // => undefined
1234
+ * @category Array
1235
+ * @pipeable
1236
+ * @dataFirst
1237
+ */
1238
+ declare function last<T>(array: Readonly<NonEmptyArray<T>>): T;
1239
+ declare function last<T>(array: ReadonlyArray<T>): T | undefined;
1240
+ /**
1241
+ * Gets the last element of `array`.
1242
+ *
1243
+ * @signature
1244
+ * P.last()(array)
1245
+ * @example
1246
+ * P.pipe(
1247
+ * [1, 2, 4, 8, 16],
1248
+ * P.filter(x => x > 3),
1249
+ * P.last(),
1250
+ * x => x + 1
1251
+ * ); // => 17
1252
+ * @category Array
1253
+ * @pipeable
1254
+ * @dataLast
1255
+ */
1256
+ declare function last<T>(): (array: ReadonlyArray<T>) => T | undefined;
1257
+
1258
+ type Enumerable<T> = ArrayLike<T> | Iterable<T>;
1259
+ /**
1260
+ * Counts values of the collection or iterable.
1261
+ *
1262
+ * @param items The input data.
1263
+ * @signature
1264
+ * P.length(array)
1265
+ * @example
1266
+ * P.length([1, 2, 3]) // => 3
1267
+ * @category Array
1268
+ */
1269
+ declare function length<T>(items: Enumerable<T>): number;
1270
+ declare function length<T>(): (items: Enumerable<T>) => number;
1271
+
1272
+ interface Strict$6 {
1273
+ <T extends IterableContainer, K>(items: T, mapper: Pred<T[number], K>): StrictOut$1<T, K>;
1274
+ <T extends IterableContainer, K>(mapper: Pred<T[number], K>): (items: T) => StrictOut$1<T, K>;
1275
+ readonly indexed: {
1276
+ <T extends IterableContainer, K>(items: T, mapper: PredIndexed<T[number], K>): StrictOut$1<T, K>;
1277
+ <T extends IterableContainer, K>(mapper: PredIndexed<T[number], K>): (items: T) => StrictOut$1<T, K>;
1278
+ };
1279
+ }
1280
+ type StrictOut$1<T extends IterableContainer, K> = {
1281
+ -readonly [P in keyof T]: K;
1282
+ };
1283
+ /**
1284
+ * Map each element of an array using a defined callback function. If the input
1285
+ * array is a tuple use the `strict` variant to maintain it's shape.
1286
+ * @param array The array to map.
1287
+ * @param fn The function mapper.
1288
+ * @returns The new mapped array.
1289
+ * @signature
1290
+ * P.map(array, fn)
1291
+ * P.map.indexed(array, fn)
1292
+ * P.map.strict(array, fn)
1293
+ * P.map.strict.indexed(array, fn)
1294
+ * @example
1295
+ * P.map([1, 2, 3], x => x * 2) // => [2, 4, 6], typed number[]
1296
+ * P.map.indexed([0, 0, 0], (x, i) => i) // => [0, 1, 2], typed number[]
1297
+ * P.map.strict([0, 0] as const, x => x + 1) // => [1, 1], typed [number, number]
1298
+ * P.map.strict.indexed([0, 0] as const, (x, i) => x + i) // => [0, 1], typed [number, number]
1299
+ * @dataFirst
1300
+ * @indexed
1301
+ * @pipeable
1302
+ * @strict
1303
+ * @category Array
1304
+ */
1305
+ declare function map<T, K>(array: ReadonlyArray<T>, fn: Pred<T, K>): Array<K>;
1306
+ /**
1307
+ * Map each value of an object using a defined callback function.
1308
+ * @param fn the function mapper
1309
+ * @signature
1310
+ * P.map(fn)(array)
1311
+ * P.map.indexed(fn)(array)
1312
+ * @example
1313
+ * P.pipe([0, 1, 2], P.map(x => x * 2)) // => [0, 2, 4]
1314
+ * P.pipe([0, 0, 0], P.map.indexed((x, i) => i)) // => [0, 1, 2]
1315
+ * @dataLast
1316
+ * @indexed
1317
+ * @pipeable
1318
+ * @category Array
1319
+ */
1320
+ declare function map<T, K>(fn: Pred<T, K>): (array: ReadonlyArray<T>) => Array<K>;
1321
+ declare namespace map {
1322
+ function indexed<T, K>(array: ReadonlyArray<T>, fn: PredIndexed<T, K>): Array<K>;
1323
+ function indexed<T, K>(fn: PredIndexed<T, K>): (array: ReadonlyArray<T>) => Array<K>;
1324
+ const lazy: <T, K>(fn: PredIndexedOptional<T, K>) => LazyEvaluator<T, K>;
1325
+ const lazyIndexed: (<T, K>(fn: PredIndexedOptional<T, K>) => LazyEvaluator<T, K>) & {
1326
+ readonly indexed: true;
1327
+ };
1328
+ const strict: Strict$6;
1329
+ }
1330
+
1331
+ /**
1332
+ * Map each element of an array into an object using a defined callback function.
1333
+ * @param array The array to map.
1334
+ * @param fn The mapping function, which should return a tuple of [key, value], similar to Object.fromEntries
1335
+ * @returns The new mapped object.
1336
+ * @signature
1337
+ * P.mapToObj(array, fn)
1338
+ * P.mapToObj.indexed(array, fn)
1339
+ * @example
1340
+ * P.mapToObj([1, 2, 3], x => [String(x), x * 2]) // => {1: 2, 2: 4, 3: 6}
1341
+ * P.mapToObj.indexed([0, 0, 0], (x, i) => [i, i]) // => {0: 0, 1: 1, 2: 2}
1342
+ * @dataFirst
1343
+ * @indexed
1344
+ * @category Array
1345
+ */
1346
+ declare function mapToObj<T, K extends PropertyKey, V>(array: ReadonlyArray<T>, fn: (element: T) => [K, V]): Record<K, V>;
1347
+ /**
1348
+ * Map each element of an array into an object using a defined callback function.
1349
+ * @param fn The mapping function, which should return a tuple of [key, value], similar to Object.fromEntries
1350
+ * @returns The new mapped object.
1351
+ * @signature
1352
+ * P.mapToObj(fn)(array)
1353
+ * P.mapToObj.indexed(fn)(array)
1354
+ * @example
1355
+ * P.pipe(
1356
+ * [1, 2, 3],
1357
+ * P.mapToObj(x => [String(x), x * 2])
1358
+ * ) // => {1: 2, 2: 4, 3: 6}
1359
+ * P.pipe(
1360
+ * [0, 0, 0],
1361
+ * P.mapToObj.indexed((x, i) => [i, i])
1362
+ * ) // => {0: 0, 1: 1, 2: 2}
1363
+ * @dataLast
1364
+ * @indexed
1365
+ * @category Array
1366
+ */
1367
+ declare function mapToObj<T, K extends PropertyKey, V>(fn: (element: T) => [K, V]): (array: ReadonlyArray<T>) => Record<K, V>;
1368
+ declare namespace mapToObj {
1369
+ function indexed<T, K extends PropertyKey, V>(array: ReadonlyArray<T>, fn: (element: T, index: number, array: ReadonlyArray<T>) => [K, V]): Record<K, V>;
1370
+ function indexed<T, K extends PropertyKey, V>(fn: (element: T, index: number, array: ReadonlyArray<T>) => [K, V]): (array: ReadonlyArray<T>) => Record<K, V>;
1371
+ }
1372
+
1373
+ /**
1374
+ * Returns the max element using the provided predicate.
1375
+ * @param fn the predicate
1376
+ * @signature
1377
+ * P.maxBy(fn)(array)
1378
+ * P.maxBy.indexed(fn)(array)
1379
+ * @example
1380
+ * P.pipe(
1381
+ * [{a: 5}, {a: 1}, {a: 3}],
1382
+ * P.maxBy(x => x.a)
1383
+ * ) // { a: 5 }
1384
+ * @dataLast
1385
+ * @indexed
1386
+ * @category Array
1387
+ */
1388
+ declare function maxBy<T>(fn: (item: T) => number): (items: ReadonlyArray<T>) => T | undefined;
1389
+ /**
1390
+ * Returns the max element using the provided predicate.
1391
+ * @param items the array
1392
+ * @param fn the predicate
1393
+ * @signature
1394
+ * P.maxBy(array, fn)
1395
+ * P.maxBy.indexed(array, fn)
1396
+ * @example
1397
+ * P.maxBy(
1398
+ * [{a: 5}, {a: 1}, {a: 3}],
1399
+ * x => x.a
1400
+ * ) // { a: 5 }
1401
+ * @dataFirst
1402
+ * @indexed
1403
+ * @category Array
1404
+ */
1405
+ declare function maxBy<T>(items: ReadonlyArray<T>, fn: (item: T) => number): T | undefined;
1406
+ declare namespace maxBy {
1407
+ function indexed<T>(array: ReadonlyArray<T>, fn: PredIndexed<T, number>): T | undefined;
1408
+ function indexed<T>(fn: PredIndexed<T, number>): (array: ReadonlyArray<T>) => T | undefined;
1409
+ }
1410
+
1411
+ /**
1412
+ * Returns the mean of the elements of an array using the provided predicate.
1413
+ * @param fn predicate function
1414
+ * @signature
1415
+ * P.meanBy(fn)(array)
1416
+ * P.meanBy.indexed(fn)(array)
1417
+ * @example
1418
+ * P.pipe(
1419
+ * [{a: 5}, {a: 1}, {a: 3}],
1420
+ * P.meanBy(x => x.a)
1421
+ * ) // 3
1422
+ * @dataLast
1423
+ * @indexed
1424
+ * @category Array
1425
+ */
1426
+ declare function meanBy<T>(fn: (item: T) => number): (items: ReadonlyArray<T>) => number;
1427
+ /**
1428
+ * Returns the mean of the elements of an array using the provided predicate.
1429
+ * @param items the array
1430
+ * @param fn predicate function
1431
+ * @signature
1432
+ * P.meanBy(array, fn)
1433
+ * P.meanBy.indexed(array, fn)
1434
+ * @example
1435
+ * P.meanBy(
1436
+ * [{a: 5}, {a: 1}, {a: 3}],
1437
+ * x => x.a
1438
+ * ) // 3
1439
+ * @dataFirst
1440
+ * @indexed
1441
+ * @category Array
1442
+ */
1443
+ declare function meanBy<T>(items: ReadonlyArray<T>, fn: (item: T) => number): number;
1444
+ declare namespace meanBy {
1445
+ function indexed<T>(array: ReadonlyArray<T>, fn: PredIndexed<T, number>): number;
1446
+ function indexed<T>(fn: PredIndexed<T, number>): (array: ReadonlyArray<T>) => number;
1447
+ }
1448
+
1449
+ /**
1450
+ * Merges a list of objects into a single object.
1451
+ * @param array the array of objects
1452
+ * @signature
1453
+ * P.mergeAll(objects)
1454
+ * @example
1455
+ * P.mergeAll([{ a: 1, b: 1 }, { b: 2, c: 3 }, { d: 10 }]) // => { a: 1, b: 2, c: 3, d: 10 }
1456
+ * @category Array
1457
+ */
1458
+ declare function mergeAll<A>(array: readonly [A]): A;
1459
+ declare function mergeAll<A, B>(array: readonly [A, B]): A & B;
1460
+ declare function mergeAll<A, B, C>(array: readonly [A, B, C]): A & B & C;
1461
+ declare function mergeAll<A, B, C, D>(array: readonly [A, B, C, D]): A & B & C & D;
1462
+ declare function mergeAll<A, B, C, D, E>(array: readonly [A, B, C, D, E]): A & B & C & D & E;
1463
+ declare function mergeAll(array: ReadonlyArray<object>): object;
1464
+
1465
+ /**
1466
+ * Returns the min element using the provided predicate.
1467
+ * @param fn the predicate
1468
+ * @signature
1469
+ * P.minBy(fn)(array)
1470
+ * P.minBy.indexed(fn)(array)
1471
+ * @example
1472
+ * P.pipe(
1473
+ * [{a: 5}, {a: 1}, {a: 3}],
1474
+ * P.minBy(x => x.a)
1475
+ * ) // { a: 1 }
1476
+ * @dataLast
1477
+ * @indexed
1478
+ * @category Array
1479
+ */
1480
+ declare function minBy<T>(fn: (item: T) => number): (items: ReadonlyArray<T>) => T | undefined;
1481
+ /**
1482
+ * Returns the min element using the provided predicate.
1483
+ * @param items the array
1484
+ * @param fn the predicate
1485
+ * @signature
1486
+ * P.minBy(array, fn)
1487
+ * P.minBy.indexed(array, fn)
1488
+ * @example
1489
+ * P.minBy(
1490
+ * [{a: 5}, {a: 1}, {a: 3}],
1491
+ * x => x.a
1492
+ * ) // { a: 1 }
1493
+ * @dataFirst
1494
+ * @indexed
1495
+ * @category Array
1496
+ */
1497
+ declare function minBy<T>(items: ReadonlyArray<T>, fn: (item: T) => number): T | undefined;
1498
+ declare namespace minBy {
1499
+ function indexed<T>(array: ReadonlyArray<T>, fn: PredIndexed<T, number>): T | undefined;
1500
+ function indexed<T>(fn: PredIndexed<T, number>): (array: ReadonlyArray<T>) => T | undefined;
1501
+ }
1502
+
1503
+ /**
1504
+ * Retrieves the element that would be at the given index if the array were sorted according to specified rules.
1505
+ * This function uses the *QuickSelect* algorithm running at an average complexity of *O(n)*.
1506
+ * Semantically it is equivalent to `sortBy(data, ...rules).at(index)` which would run at *O(nlogn)*.
1507
+ *
1508
+ * See also `firstBy` which provides an even more efficient algorithm and a stricter return type,
1509
+ * but only for `index === 0`.
1510
+ * See `takeFirstBy` to get all the elements up to and including `index`.
1511
+ *
1512
+ * @param data - The input array.
1513
+ * @param index - The zero-based index for selecting the element in the sorted order. Negative indices count backwards from the end.
1514
+ * @param rules - A variadic array of order rules defining the sorting criteria. Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, "desc"]` for descending order.
1515
+ * @returns The element at the specified index in the sorted order, or `undefined` if the index is out of bounds.
1516
+ * @signature
1517
+ * P.nthBy(data, index, ...rules);
1518
+ * @example
1519
+ * P.nthBy([2,1,4,5,3,], 2, identity); // => 3
1520
+ * @dataFirst
1521
+ * @category Array
1522
+ */
1523
+ declare function nthBy<T extends IterableContainer>(data: T, index: number, ...rules: Readonly<NonEmptyArray<OrderRule<T[number]>>>): T[number] | undefined;
1524
+ /**
1525
+ * Retrieves the element that would be at the given index if the array were sorted according to specified rules.
1526
+ * This function uses the *QuickSelect* algorithm running at an average complexity of *O(n)*.
1527
+ * Semantically it is equivalent to `sortBy(data, ...rules)[index]` which would run at *O(nlogn)*.
1528
+ *
1529
+ * See also `firstBy` which provides an even more efficient algorithm and a stricter return type,
1530
+ * but only for `index === 0`.
1531
+ * See `takeFirstBy` to get all the elements up to and including `index`.
1532
+ *
1533
+ * @param index - The zero-based index for selecting the element in the sorted order. Negative indices count backwards from the end.
1534
+ * @param rules - A variadic array of order rules defining the sorting criteria. Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, "desc"]` for descending order.
1535
+ * @returns The element at the specified index in the sorted order, or `undefined` if the index is out of bounds.
1536
+ * @signature
1537
+ * P.nthBy(index, ...rules)(data);
1538
+ * @example
1539
+ * P.pipe([2,1,4,5,3,], P.nthBy(2, identity)); // => 3
1540
+ * @dataLast
1541
+ * @category Array
1542
+ */
1543
+ declare function nthBy<T extends IterableContainer>(index: number, ...rules: Readonly<NonEmptyArray<OrderRule<T[number]>>>): (data: T) => T[number] | undefined;
1544
+
1545
+ type Only<T extends IterableContainer> = T extends readonly [...Array<unknown>, unknown, unknown] | readonly [] | readonly [unknown, ...Array<unknown>, unknown] | readonly [unknown, unknown, ...Array<unknown>] ? undefined : T extends readonly [unknown] ? T[number] : T[number] | undefined;
1546
+ /**
1547
+ * Returns the first and only element of `array`, or undefined otherwise.
1548
+ * Note: In `pipe`, use `only()` form instead of `only`. Otherwise, the
1549
+ * inferred type is lost.
1550
+ *
1551
+ * @param array the target array
1552
+ * @signature
1553
+ * P.only(array)
1554
+ * @example
1555
+ * P.only([]) // => undefined
1556
+ * P.only([1]) // => 1
1557
+ * P.only([1, 2]) // => undefined
1558
+ * @pipeable
1559
+ * @category Array
1560
+ * @dataFirst
1561
+ */
1562
+ declare function only<T extends IterableContainer>(array: Readonly<T>): Only<T>;
1563
+ /**
1564
+ * Returns the first and only element of `array`, or undefined otherwise.
1565
+ * Note: In `pipe`, use `only()` form instead of `only`. Otherwise, the
1566
+ * inferred type is lost.
1567
+ *
1568
+ * @signature
1569
+ * P.only(array)
1570
+ * @example
1571
+ * P.only([]) // => undefined
1572
+ * P.only([1]) // => 1
1573
+ * P.only([1, 2]) // => undefined
1574
+ * @pipeable
1575
+ * @category Array
1576
+ * @dataLast
1577
+ */
1578
+ declare function only<T extends IterableContainer>(): (array: Readonly<T>) => Only<T>;
1579
+
1580
+ /**
1581
+ * Splits a collection into two groups, the first of which contains elements the `predicate` type guard passes, and the second one containing the rest.
1582
+ * @param items the items to split
1583
+ * @param predicate a type guard function to invoke on every item
1584
+ * @returns the array of grouped elements.
1585
+ * @signature
1586
+ * P.partition(array, fn)
1587
+ * @example
1588
+ * P.partition(['one', 'two', 'forty two'], x => x.length === 3) // => [['one', 'two'], ['forty two']]
1589
+ * @dataFirst
1590
+ * @indexed
1591
+ * @category Array
1592
+ */
1593
+ declare function partition<T, S extends T>(items: ReadonlyArray<T>, predicate: (item: T) => item is S): [Array<S>, Array<Exclude<T, S>>];
1594
+ /**
1595
+ * Splits a collection into two groups, the first of which contains elements the `predicate` function matches, and the second one containing the rest.
1596
+ * @param items the items to split
1597
+ * @param predicate the function invoked per iteration
1598
+ * @returns the array of grouped elements.
1599
+ * @signature
1600
+ * P.partition(array, fn)
1601
+ * @example
1602
+ * P.partition(['one', 'two', 'forty two'], x => x.length === 3) // => [['one', 'two'], ['forty two']]
1603
+ * @dataFirst
1604
+ * @indexed
1605
+ * @category Array
1606
+ */
1607
+ declare function partition<T>(items: ReadonlyArray<T>, predicate: (item: T) => boolean): [Array<T>, Array<T>];
1608
+ /**
1609
+ * Splits a collection into two groups, the first of which contains elements the `predicate` type guard passes, and the second one containing the rest.
1610
+ * @param predicate the grouping function
1611
+ * @returns the array of grouped elements.
1612
+ * @signature
1613
+ * P.partition(fn)(array)
1614
+ * @example
1615
+ * P.pipe(['one', 'two', 'forty two'], P.partition(x => x.length === 3)) // => [['one', 'two'], ['forty two']]
1616
+ * @dataLast
1617
+ * @indexed
1618
+ * @category Array
1619
+ */
1620
+ declare function partition<T, S extends T>(predicate: (item: T) => item is S): (array: ReadonlyArray<T>) => [Array<S>, Array<Exclude<T, S>>];
1621
+ /**
1622
+ * Splits a collection into two groups, the first of which contains elements the `predicate` function matches, and the second one containing the rest.
1623
+ * @param predicate the grouping function
1624
+ * @returns the array of grouped elements.
1625
+ * @signature
1626
+ * P.partition(fn)(array)
1627
+ * @example
1628
+ * P.pipe(['one', 'two', 'forty two'], P.partition(x => x.length === 3)) // => [['one', 'two'], ['forty two']]
1629
+ * @dataLast
1630
+ * @indexed
1631
+ * @category Array
1632
+ */
1633
+ declare function partition<T>(predicate: (item: T) => boolean): (array: ReadonlyArray<T>) => [Array<T>, Array<T>];
1634
+ declare namespace partition {
1635
+ function indexed<T>(array: ReadonlyArray<T>, predicate: PredIndexed<T, boolean>): [Array<T>, Array<T>];
1636
+ function indexed<T>(predicate: PredIndexed<T, boolean>): (array: ReadonlyArray<T>) => [Array<T>, Array<T>];
1637
+ }
1638
+
1639
+ /**
1640
+ * Returns a list of numbers from `start` (inclusive) to `end` (exclusive).
1641
+ * @param start the start number
1642
+ * @param end the end number
1643
+ * @signature range(start, end)
1644
+ * @example
1645
+ * P.range(1, 5) // => [1, 2, 3, 4]
1646
+ * @dataFirst
1647
+ * @category Array
1648
+ */
1649
+ declare function range(start: number, end: number): Array<number>;
1650
+ /**
1651
+ * Returns a list of numbers from `start` (inclusive) to `end` (exclusive).
1652
+ * @param end the end number
1653
+ * @signature range(end)(start)
1654
+ * @example
1655
+ * P.range(5)(1) // => [1, 2, 3, 4]
1656
+ * @dataFirst
1657
+ * @category Array
1658
+ */
1659
+ declare function range(end: number): (start: number) => Array<number>;
1660
+
1661
+ /**
1662
+ * Calculates the rank of an item in an array based on `rules`. The rank is the position where the item would appear in the sorted array. This function provides an efficient way to determine the rank in *O(n)* time, compared to *O(nlogn)* for the equivalent `sortedIndex(sortBy(data, ...rules), item)`.
1663
+ *
1664
+ * @param data - The input array.
1665
+ * @param item - The item whose rank is to be determined.
1666
+ * @param rules - A variadic array of order rules defining the sorting criteria. Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, "desc"]` for descending order.
1667
+ * @returns - The rank of the item in the sorted array in the range [0..data.length]
1668
+ * @signature
1669
+ * P.rankBy(data, item, ...rules)
1670
+ * @example
1671
+ * const DATA = [{ a: 5 }, { a: 1 }, { a: 3 }] as const;
1672
+ * P.rankBy(DATA, 0, P.prop('a')) // => 0
1673
+ * P.rankBy(DATA, 1, P.prop('a')) // => 1
1674
+ * P.rankBy(DATA, 2, P.prop('a')) // => 1
1675
+ * P.rankBy(DATA, 3, P.prop('a')) // => 2
1676
+ * @dataFirst
1677
+ * @category Array
1678
+ */
1679
+ declare function rankBy<T>(data: ReadonlyArray<T>, item: T, ...rules: Readonly<NonEmptyArray<OrderRule<T>>>): number;
1680
+ /**
1681
+ * Calculates the rank of an item in an array based on `rules`. The rank is the position where the item would appear in the sorted array. This function provides an efficient way to determine the rank in *O(n)* time, compared to *O(nlogn)* for the equivalent `sortedIndex(sortBy(data, ...rules), item)`.
1682
+ *
1683
+ * @param item - The item whose rank is to be determined.
1684
+ * @param rules - A variadic array of order rules defining the sorting criteria. Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, "desc"]` for descending order.
1685
+ * @returns - The rank of the item in the sorted array in the range [0..data.length]
1686
+ * @signature
1687
+ * P.rankBy(item, ...rules)(data)
1688
+ * @example
1689
+ * const DATA = [{ a: 5 }, { a: 1 }, { a: 3 }] as const;
1690
+ * P.pipe(DATA, P.rankBy(0, P.prop('a'))) // => 0
1691
+ * P.pipe(DATA, P.rankBy(1, P.prop('a'))) // => 1
1692
+ * P.pipe(DATA, P.rankBy(2, P.prop('a'))) // => 1
1693
+ * P.pipe(DATA, P.rankBy(3, P.prop('a'))) // => 2
1694
+ * @dataLast
1695
+ * @category Array
1696
+ */
1697
+ declare function rankBy<T>(item: T, ...rules: Readonly<NonEmptyArray<OrderRule<T>>>): (data: ReadonlyArray<T>) => number;
1698
+
1699
+ /**
1700
+ * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
1701
+ *
1702
+ * @param items the array to reduce
1703
+ * @param fn the callback function
1704
+ * @param initialValue the initial value to use as an accumulator value in the callback function
1705
+ * @signature
1706
+ * P.reduce(items, fn, initialValue)
1707
+ * P.reduce.indexed(items, fn, initialValue)
1708
+ * @example
1709
+ * P.reduce([1, 2, 3, 4, 5], (acc, x) => acc + x, 100) // => 115
1710
+ * P.reduce.indexed([1, 2, 3, 4, 5], (acc, x, i, array) => acc + x, 100) // => 115
1711
+ * @dataFirst
1712
+ * @indexed
1713
+ * @category Array
1714
+ */
1715
+ declare function reduce<T, K>(items: ReadonlyArray<T>, fn: (acc: K, item: T) => K, initialValue: K): K;
1716
+ /**
1717
+ * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
1718
+ *
1719
+ * @param fn the callback function
1720
+ * @param initialValue the initial value to use as an accumulator value in the callback function
1721
+ * @signature
1722
+ * P.reduce(fn, initialValue)(array)
1723
+ * @example
1724
+ * P.pipe([1, 2, 3, 4, 5], P.reduce((acc, x) => acc + x, 100)) // => 115
1725
+ * P.pipe([1, 2, 3, 4, 5], P.reduce.indexed((acc, x, i, array) => acc + x, 100)) // => 115
1726
+ * @dataLast
1727
+ * @indexed
1728
+ * @category Array
1729
+ */
1730
+ declare function reduce<T, K>(fn: (acc: K, item: T) => K, initialValue: K): (items: ReadonlyArray<T>) => K;
1731
+ declare namespace reduce {
1732
+ function indexed<T, K>(array: ReadonlyArray<T>, fn: (acc: K, item: T, index: number, items: ReadonlyArray<T>) => K, initialValue: K): K;
1733
+ function indexed<T, K>(fn: (acc: K, item: T, index: number, items: ReadonlyArray<T>) => K, initialValue: K): (array: ReadonlyArray<T>) => K;
1734
+ }
1735
+
1736
+ /**
1737
+ * Reject the elements of an array that meet the condition specified in a callback function.
1738
+ * @param items The array to reject.
1739
+ * @param fn the callback function.
1740
+ * @signature
1741
+ * P.reject(array, fn)
1742
+ * P.reject.indexed(array, fn)
1743
+ * @example
1744
+ * P.reject([1, 2, 3], x => x % 2 === 0) // => [1, 3]
1745
+ * P.reject.indexed([1, 2, 3], (x, i, array) => x % 2 === 0) // => [1, 3]
1746
+ * @dataFirst
1747
+ * @indexed
1748
+ * @pipeable
1749
+ * @category Array
1750
+ */
1751
+ declare function reject<T>(items: ReadonlyArray<T>, fn: Pred<T, boolean>): Array<T>;
1752
+ /**
1753
+ * Reject the elements of an array that meet the condition specified in a callback function.
1754
+ * @param fn the callback function.
1755
+ * @signature
1756
+ * P.reject(array, fn)
1757
+ * P.reject.indexed(array, fn)
1758
+ * @example
1759
+ * P.reject([1, 2, 3], x => x % 2 === 0) // => [1, 3]
1760
+ * P.reject.indexed([1, 2, 3], (x, i, array) => x % 2 === 0) // => [1, 3]
1761
+ * @dataFirst
1762
+ * @indexed
1763
+ * @pipeable
1764
+ * @category Array
1765
+ */
1766
+ declare function reject<T>(fn: Pred<T, boolean>): (items: ReadonlyArray<T>) => Array<T>;
1767
+ declare namespace reject {
1768
+ function indexed<T, K>(array: ReadonlyArray<T>, fn: PredIndexed<T, boolean>): Array<K>;
1769
+ function indexed<T, K>(fn: PredIndexed<T, boolean>): (array: ReadonlyArray<T>) => Array<K>;
1770
+ const lazy: <T>(fn: PredIndexedOptional<T, boolean>) => LazyEvaluator<T>;
1771
+ const lazyIndexed: (<T>(fn: PredIndexedOptional<T, boolean>) => LazyEvaluator<T>) & {
1772
+ readonly indexed: true;
1773
+ };
1774
+ }
1775
+
1776
+ type Reverse<T extends ReadonlyArray<unknown>, R extends ReadonlyArray<unknown> = []> = ReturnType<T extends IsNoTuple<T> ? () => [...T, ...R] : T extends readonly [infer F, ...infer L] ? () => Reverse<L, [F, ...R]> : () => R>;
1777
+ type IsNoTuple<T> = T extends readonly [unknown, ...Array<unknown>] ? never : T;
1778
+ /**
1779
+ * Reverses an array.
1780
+ *
1781
+ * @param array the array
1782
+ * @signature
1783
+ * P.reverse(arr);
1784
+ * @example
1785
+ * P.reverse([1, 2, 3]) // [3, 2, 1]
1786
+ * @dataFirst
1787
+ * @category Array
1788
+ */
1789
+ declare function reverse<T extends ReadonlyArray<unknown>>(array: T): Reverse<T>;
1790
+ /**
1791
+ * Reverses an array.
1792
+ *
1793
+ * @signature
1794
+ * P.reverse()(array);
1795
+ * @example
1796
+ * P.reverse()([1, 2, 3]) // [3, 2, 1]
1797
+ * @dataLast
1798
+ * @category Array
1799
+ */
1800
+ declare function reverse<T extends ReadonlyArray<unknown>>(): (array: T) => Reverse<T>;
1801
+
1802
+ type Sampled<T extends IterableContainer, N extends number> = number extends N ? SampledGeneric<T> : undefined extends T[N] ? T : SampledLiteral<T, N>;
1803
+ type SampledGeneric<T extends IterableContainer> = T[number] extends never ? T : T extends readonly [infer First, ...infer Rest] ? [First, ...SampledGeneric<Rest>] | SampledGeneric<Rest> : Array<T[number]>;
1804
+ type SampledLiteral<T extends IterableContainer, N extends number, Iteration extends Array<unknown> = []> = Iteration['length'] extends N ? [] : T extends readonly [infer First, ...infer Tail] ? [
1805
+ First | Tail[number],
1806
+ ...SampledLiteral<Tail, N, [unknown, ...Iteration]>
1807
+ ] : T extends readonly [...infer Head, infer Last] ? [...SampledLiteral<Head, N, [unknown, ...Iteration]>, Last] : [T[number], ...SampledLiteral<T, N, [unknown, ...Iteration]>] | SampledLiteral<T, N, [unknown, ...Iteration]>;
1808
+ /**
1809
+ * Returns a random subset of size `sampleSize` from `array`.
1810
+ *
1811
+ * Maintains and infers most of the typing information that could be passed
1812
+ * along to the output. This means that when using tuples, the output will be
1813
+ * a tuple too, and when using literals, those literals would be preserved.
1814
+ *
1815
+ * The items in the result are kept in the same order as they are in the input.
1816
+ * If you need to get a shuffled response you can pipe the shuffle function
1817
+ * after this one.
1818
+ *
1819
+ * @param data the array
1820
+ * @param sampleSize the number of elements to take
1821
+ * @signature
1822
+ * P.sample(array, sampleSize)
1823
+ * @example
1824
+ * P.sample(["hello", "world"], 1); // => ["hello"] // typed string[]
1825
+ * P.sample(["hello", "world"] as const, 1); // => ["world"] // typed ["hello" | "world"]
1826
+ * @dataFirst
1827
+ * @pipeable
1828
+ * @category Array
1829
+ */
1830
+ declare function sample<T extends IterableContainer, N extends number = number>(data: T, sampleSize: N): Sampled<T, N>;
1831
+ /**
1832
+ * Returns a random subset of size `sampleSize` from `array`.
1833
+ *
1834
+ * Maintains and infers most of the typing information that could be passed
1835
+ * along to the output. This means that when using tuples, the output will be
1836
+ * a tuple too, and when using literals, those literals would be preserved.
1837
+ *
1838
+ * The items in the result are kept in the same order as they are in the input.
1839
+ * If you need to get a shuffled response you can pipe the shuffle function
1840
+ * after this one.
1841
+ *
1842
+ * @param sampleSize the number of elements to take
1843
+ * @signature
1844
+ * P.sample(sampleSize)(array)
1845
+ * @example
1846
+ * P.sample(1)(["hello", "world"]); // => ["hello"] // typed string[]
1847
+ * P.sample(1)(["hello", "world"] as const); // => ["world"] // typed ["hello" | "world"]
1848
+ * @dataLast
1849
+ * @pipeable
1850
+ * @category Array
1851
+ */
1852
+ declare function sample<T extends IterableContainer, N extends number = number>(sampleSize: N): (data: T) => Sampled<T, N>;
1853
+
1854
+ /**
1855
+ * Shuffles the input array, returning a new array with the same elements in a random order.
1856
+ * @param items the array to shuffle
1857
+ * @signature
1858
+ * P.shuffle(array)
1859
+ * @example
1860
+ * P.shuffle([4, 2, 7, 5]) // => [7, 5, 4, 2]
1861
+ * @category Array
1862
+ * @dataFirst
1863
+ */
1864
+ declare function shuffle<T>(items: ReadonlyArray<T>): Array<T>;
1865
+ /**
1866
+ * Shuffles the input array, returning a new array with the same elements in a random order.
1867
+ * @signature
1868
+ * P.shuffle()(array)
1869
+ * @example
1870
+ * P.pipe([4, 2, 7, 5], P.shuffle()) // => [7, 5, 4, 2]
1871
+ * @category Array
1872
+ * @dataLast
1873
+ */
1874
+ declare function shuffle<T>(): (items: ReadonlyArray<T>) => Array<T>;
1875
+
1876
+ interface Strict$5 {
1877
+ <T extends IterableContainer>(items: T, cmp: (a: T[number], b: T[number]) => number): Sorted<T>;
1878
+ <T extends IterableContainer>(cmp: (a: T[number], b: T[number]) => number): (items: T) => Sorted<T>;
1879
+ }
1880
+ type Sorted<T extends IterableContainer> = {
1881
+ -readonly [P in keyof T]: T[number];
1882
+ };
1883
+ /**
1884
+ * Sorts an array. The comparator function should accept two values at a time and return a negative number if the first value is smaller, a positive number if it's larger, and zero if they are equal.
1885
+ * Sorting is based on a native `sort` function. It's not guaranteed to be stable.
1886
+ *
1887
+ * If the input array is more complex (non-empty array, tuple, etc...) use the
1888
+ * strict mode to maintain it's shape.
1889
+ *
1890
+ * @param items the array to sort
1891
+ * @param cmp the comparator function
1892
+ * @signature
1893
+ * P.sort(items, cmp)
1894
+ * P.sort.strict(items, cmp)
1895
+ * @example
1896
+ * P.sort([4, 2, 7, 5], (a, b) => a - b) // => [2, 4, 5, 7] typed Array<number>
1897
+ * P.sort.strict([4, 2] as [number, number], (a, b) => a - b) // [2, 4] typed [number, number]
1898
+ * @dataFirst
1899
+ * @category Array
1900
+ * @strict
1901
+ */
1902
+ declare function sort<T>(items: ReadonlyArray<T>, cmp: (a: T, b: T) => number): Array<T>;
1903
+ /**
1904
+ * Sorts an array. The comparator function should accept two values at a time and return a negative number if the first value is smaller, a positive number if it's larger, and zero if they are equal.
1905
+ * Sorting is based on a native `sort` function. It's not guaranteed to be stable.
1906
+ *
1907
+ * If the input array is more complex (non-empty array, tuple, etc...) use the
1908
+ * strict mode to maintain it's shape.
1909
+ *
1910
+ * @param cmp the comparator function
1911
+ * @signature
1912
+ * P.sort(cmp)(items)
1913
+ * P.sort.strict(cmp)(items)
1914
+ * @example
1915
+ * P.pipe([4, 2, 7, 5], P.sort((a, b) => a - b)) // => [2, 4, 5, 7] typed Array<number>
1916
+ * P.pipe([4, 2] as [number, number], P.sort.strict((a, b) => a - b)) // => [2, 4] typed [number, number]
1917
+ * @dataLast
1918
+ * @category Array
1919
+ * @strict
1920
+ */
1921
+ declare function sort<T>(cmp: (a: T, b: T) => number): (items: ReadonlyArray<T>) => Array<T>;
1922
+ declare namespace sort {
1923
+ const strict: Strict$5;
1924
+ }
1925
+
1926
+ interface Strict$4 {
1927
+ <T extends IterableContainer>(...sortRules: Readonly<NonEmptyArray<OrderRule<T[number]>>>): (array: T) => SortedBy<T>;
1928
+ <T extends IterableContainer>(array: T, ...sortRules: Readonly<NonEmptyArray<OrderRule<T[number]>>>): SortedBy<T>;
1929
+ }
1930
+ type SortedBy<T extends IterableContainer> = {
1931
+ -readonly [P in keyof T]: T[number];
1932
+ };
1933
+ /**
1934
+ * Sorts `data` using the provided ordering rules. The `sort` is done via the native `Array.prototype.sort` but is performed on a shallow copy of the array to avoid mutating the original data.
1935
+ *
1936
+ * To maintain the shape of more complex inputs (like non-empty arrays, tuples, etc...) use the `strict` variant.
1937
+ *
1938
+ * There are several other functions that take order rules and **bypass** the need to sort the array first (in *O(nlogn)* time):
1939
+ * `firstBy` === `first(sortBy(data, ...rules))`, O(n).
1940
+ * `takeFirstBy` === `take(sortBy(data, ...rules), k)`, O(nlogk).
1941
+ * `dropFirstBy` === `drop(sortBy(data, ...rules), k)`, O(nlogk).
1942
+ * `nthBy` === `sortBy(data, ...rules).at(k)`, O(n).
1943
+ * `rankBy` === `sortedIndex(sortBy(data, ...rules), item)`, O(n).
1944
+ * Refer to the docs for more details.
1945
+ *
1946
+ * @param rules - A variadic array of order rules defining the sorting criteria. Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, "desc"]` for descending order.
1947
+ * @return - A shallow copy of the input array sorted by the provided rules.
1948
+ * @signature
1949
+ * P.sortBy(...rules)(data)
1950
+ * P.sortBy.strict(...rules)(data)
1951
+ * @example
1952
+ * P.pipe(
1953
+ * [{ a: 1 }, { a: 3 }, { a: 7 }, { a: 2 }],
1954
+ * P.sortBy(x => x.a)
1955
+ * ) // => [{ a: 1 }, { a: 2 }, { a: 3 }, { a: 7 }] typed Array<{a:number}>
1956
+ * P.pipe(
1957
+ * [{ a: 1 }, { a: 3 }] as const,
1958
+ * P.sortBy.strict(x => x.a)
1959
+ * ) // => [{ a: 1 }, { a: 3 }] typed [{a: 1 | 3}, {a: 1 | 3}]
1960
+ * @dataLast
1961
+ * @category Array
1962
+ * @strict
1963
+ */
1964
+ declare function sortBy<T>(...rules: Readonly<NonEmptyArray<OrderRule<T>>>): (data: ReadonlyArray<T>) => Array<T>;
1965
+ /**
1966
+ * Sorts `data` using the provided ordering rules. The `sort` is done via the native `Array.prototype.sort` but is performed on a shallow copy of the array to avoid mutating the original data.
1967
+ *
1968
+ * To maintain the shape of more complex inputs (like non-empty arrays, tuples, etc...) use the `strict` variant.
1969
+ *
1970
+ * There are several other functions that take order rules and **bypass** the need to sort the array first (in *O(nlogn)* time):
1971
+ * `firstBy` === `first(sortBy(data, ...rules))`, O(n).
1972
+ * `takeFirstBy` === `take(sortBy(data, ...rules), k)`, O(nlogk).
1973
+ * `dropFirstBy` === `drop(sortBy(data, ...rules), k)`, O(nlogk).
1974
+ * `nthBy` === `sortBy(data, ...rules).at(k)`, O(n).
1975
+ * `rankBy` === `sortedIndex(sortBy(data, ...rules), item)`, O(n).
1976
+ * Refer to the docs for more details.
1977
+ *
1978
+ * @param array - The input array.
1979
+ * @param sortRules - A variadic array of order rules defining the sorting criteria. Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, "desc"]` for descending order.
1980
+ * @return - A shallow copy of the input array sorted by the provided rules.
1981
+ * @signature
1982
+ * P.sortBy(data, ...rules)
1983
+ * P.sortBy.strict(data, ...rules)
1984
+ * @example
1985
+ * P.sortBy(
1986
+ * [{ a: 1 }, { a: 3 }, { a: 7 }, { a: 2 }],
1987
+ * x => x.a
1988
+ * )
1989
+ * // => [{ a: 1 }, { a: 2 }, { a: 3 }, { a: 7 }] typed Array<{a:number}>
1990
+ *
1991
+ * P.sortBy(
1992
+ * [
1993
+ * {color: 'red', weight: 2},
1994
+ * {color: 'blue', weight: 3},
1995
+ * {color: 'green', weight: 1},
1996
+ * {color: 'purple', weight: 1},
1997
+ * ],
1998
+ * [x => x.weight, 'asc'], x => x.color
1999
+ * )
2000
+ * // =>
2001
+ * // {color: 'green', weight: 1},
2002
+ * // {color: 'purple', weight: 1},
2003
+ * // {color: 'red', weight: 2},
2004
+ * // {color: 'blue', weight: 3},
2005
+ * // typed Array<{color: string, weight: number}>
2006
+ *
2007
+ * P.sortBy.strict(
2008
+ * [{ a: 1 }, { a: 3 }] as const,
2009
+ * x => x.a
2010
+ * )
2011
+ * // => [{ a: 1 }, { a: 3 }] typed [{a: 1 | 3}, {a: 1 | 3}]
2012
+ * @dataFirst
2013
+ * @category Array
2014
+ * @strict
2015
+ */
2016
+ declare function sortBy<T>(array: ReadonlyArray<T>, ...sortRules: Readonly<NonEmptyArray<OrderRule<T>>>): Array<T>;
2017
+ declare namespace sortBy {
2018
+ const strict: Strict$4;
2019
+ }
2020
+
2021
+ /**
2022
+ * Find the insertion position (index) of an item in an array with items sorted
2023
+ * in ascending order; so that `splice(sortedIndex, 0, item)` would result in
2024
+ * maintaining the array's sort-ness. The array can contain duplicates.
2025
+ * If the item already exists in the array the index would be of the *first*
2026
+ * occurrence of the item.
2027
+ *
2028
+ * Runs in O(logN) time.
2029
+ *
2030
+ * @param data - The (ascending) sorted array.
2031
+ * @param item - The item to insert.
2032
+ * @return - Insertion index (In the range 0..array.length)
2033
+ *
2034
+ * @signature
2035
+ * P.sortedIndex(data, item)
2036
+ * @example
2037
+ * P.sortedIndex(['a','a','b','c','c'], 'c') // => 3
2038
+ * @dataFirst
2039
+ * @category Array
2040
+ *
2041
+ * @see sortedIndexBy, sortedIndexWith, sortedLastIndex, sortedLastIndexBy
2042
+ */
2043
+ declare function sortedIndex<T>(data: ReadonlyArray<T>, item: T): number;
2044
+ /**
2045
+ * Find the insertion position (index) of an item in an array with items sorted
2046
+ * in ascending order; so that `splice(sortedIndex, 0, item)` would result in
2047
+ * maintaining the array's sort-ness. The array can contain duplicates.
2048
+ * If the item already exists in the array the index would be of the *first*
2049
+ * occurrence of the item.
2050
+ *
2051
+ * Runs in O(logN) time.
2052
+ *
2053
+ * @param item - The item to insert.
2054
+ * @return - Insertion index (In the range 0..array.length)
2055
+ *
2056
+ * @signature
2057
+ * P.sortedIndex(item)(data)
2058
+ * @example
2059
+ * P.pipe(['a','a','b','c','c'], P.sortedIndex('c')) // => 3
2060
+ * @dataLast
2061
+ * @category Array
2062
+ *
2063
+ * @see sortedIndexBy, sortedIndexWith, sortedLastIndex, sortedLastIndexBy
2064
+ */
2065
+ declare function sortedIndex<T>(item: T): (data: ReadonlyArray<T>) => number;
2066
+
2067
+ /**
2068
+ * Performs a **binary search** for the index of the item at which the predicate
2069
+ * stops returning `true`. This function assumes that the array is "sorted" in
2070
+ * regards to the predicate, meaning that running the predicate as a mapper on
2071
+ * it would result in an array `[...true[], ...false[]]`.
2072
+ * This stricter requirement from the predicate provides us 2 benefits over
2073
+ * `findIndex` which does a similar thing:
2074
+ * 1. It would run at O(logN) time instead of O(N) time.
2075
+ * 2. It always returns a value (it would return `data.length` if the
2076
+ * predicate returns `true` for all items).
2077
+ *
2078
+ * This function is the basis for all other sortedIndex functions which search
2079
+ * for a specific item in a sorted array, and it could be used to perform
2080
+ * similar efficient searches.
2081
+ *
2082
+ * @param data - Array, "sorted" by `predicate`
2083
+ * @param predicate - A predicate which also defines the array's order
2084
+ * @return - Index (In the range 0..data.length)
2085
+ *
2086
+ * @signature
2087
+ * P.sortedIndexWith(data, predicate)
2088
+ * @example
2089
+ * P.sortedIndexWith(['a','ab','abc'], (item) => item.length < 2) // => 1
2090
+ * @dataFirst
2091
+ * @indexed
2092
+ * @category Array
2093
+ *
2094
+ * @see findIndex, sortedIndex, sortedIndexBy, sortedLastIndex, sortedLastIndexBy
2095
+ */
2096
+ declare function sortedIndexWith<T>(data: ReadonlyArray<T>, predicate: (item: T) => boolean): number;
2097
+ /**
2098
+ * Performs a **binary search** for the index of the item at which the predicate
2099
+ * stops returning `true`. This function assumes that the array is "sorted" in
2100
+ * regards to the predicate, meaning that running the predicate as a mapper on
2101
+ * it would result in an array `[...true[], ...false[]]`.
2102
+ * This stricter requirement from the predicate provides us 2 benefits over
2103
+ * `findIndex` which does a similar thing:
2104
+ * 1. It would run at O(logN) time instead of O(N) time.
2105
+ * 2. It always returns a value (it would return `data.length` if the
2106
+ * predicate returns `false` for all items).
2107
+ *
2108
+ * This function is the basis for all other sortedIndex functions which search
2109
+ * for a specific item in a sorted array, and it could be used to perform
2110
+ * similar efficient searches.
2111
+ *
2112
+ * @param predicate - A predicate which also defines the array's order
2113
+ * @return - Index (In the range 0..data.length)
2114
+ *
2115
+ * @signature
2116
+ * P.sortedIndexWith(predicate)(data)
2117
+ * @example
2118
+ * P.pipe(['a','ab','abc'], P.sortedIndexWith((item) => item.length < 2)) // => 1
2119
+ * @dataLast
2120
+ * @indexed
2121
+ * @category Array
2122
+ *
2123
+ * @see findIndex, sortedIndex, sortedIndexBy, sortedLastIndex, sortedLastIndexBy
2124
+ */
2125
+ declare function sortedIndexWith<T>(predicate: (item: T) => boolean): (data: ReadonlyArray<T>) => number;
2126
+ declare namespace sortedIndexWith {
2127
+ function indexed<T>(data: ReadonlyArray<T>, predicate: (item: T, index: number) => NonNullable<unknown>): number;
2128
+ function indexed<T>(predicate: (item: T, index: number) => NonNullable<unknown>): (data: ReadonlyArray<T>) => number;
2129
+ }
2130
+
2131
+ /**
2132
+ * Find the insertion position (index) of an item in an array with items sorted
2133
+ * in ascending order using a value function; so that `splice(sortedIndex, 0, item)`
2134
+ * would result in maintaining the arrays sort-ness. The array can contain
2135
+ * duplicates.
2136
+ * If the item already exists in the array the index would be of the *first*
2137
+ * occurrence of the item.
2138
+ *
2139
+ * Runs in O(logN) time.
2140
+ *
2141
+ * @param data - The (ascending) sorted array.
2142
+ * @param item - The item to insert.
2143
+ * @param valueFunction - All comparisons would be performed on the result of
2144
+ * calling this function on each compared item. Preferably this function should
2145
+ * return a `number` or `string`. This function should be the same as the one
2146
+ * provided to sortBy to sort the array.
2147
+ * @return - Insertion index (In the range 0..data.length)
2148
+ *
2149
+ * @signature
2150
+ * P.sortedIndexBy(data, item, valueFunction)
2151
+ * @example
2152
+ * P.sortedIndexBy([{age:20},{age:22}],{age:21},prop('age')) // => 1
2153
+ * @dataFirst
2154
+ * @indexed
2155
+ * @category Array
2156
+ *
2157
+ * @see sortedIndex, sortedIndexWith, sortedLastIndex, sortedLastIndexBy
2158
+ */
2159
+ declare function sortedIndexBy<T>(data: ReadonlyArray<T>, item: T, valueFunction: (item: T) => NonNullable<unknown>): number;
2160
+ /**
2161
+ * Find the insertion position (index) of an item in an array with items sorted
2162
+ * in ascending order using a value function; so that `splice(sortedIndex, 0, item)`
2163
+ * would result in maintaining the arrays sort-ness. The array can contain
2164
+ * duplicates.
2165
+ * If the item already exists in the array the index would be of the *first*
2166
+ * occurrence of the item.
2167
+ *
2168
+ * Runs in O(logN) time.
2169
+ *
2170
+ * @param item - The item to insert.
2171
+ * @param valueFunction - All comparisons would be performed on the result of
2172
+ * calling this function on each compared item. Preferably this function should
2173
+ * return a `number` or `string`. This function should be the same as the one
2174
+ * provided to sortBy to sort the array.
2175
+ * @return - Insertion index (In the range 0..data.length)
2176
+ *
2177
+ * @signature
2178
+ * P.sortedIndexBy(data, item, valueFunction)
2179
+ * @example
2180
+ * P.sortedIndexBy([{age:20},{age:22}],{age:21},prop('age')) // => 1
2181
+ * @dataLast
2182
+ * @indexed
2183
+ * @category Array
2184
+ *
2185
+ * @see sortedIndex, sortedIndexWith, sortedLastIndex, sortedLastIndexBy
2186
+ */
2187
+ declare function sortedIndexBy<T>(item: T, valueFunction: (item: T) => NonNullable<unknown>): (data: ReadonlyArray<T>) => number;
2188
+ declare namespace sortedIndexBy {
2189
+ function indexed<T>(data: ReadonlyArray<T>, item: T, valueFunction: (item: T, index?: number) => NonNullable<unknown>): number;
2190
+ function indexed<T>(item: T, valueFunction: (item: T, index?: number) => NonNullable<unknown>): (data: ReadonlyArray<T>) => number;
2191
+ }
2192
+
2193
+ /**
2194
+ * Find the insertion position (index) of an item in an array with items sorted
2195
+ * in ascending order; so that `splice(sortedIndex, 0, item)` would result in
2196
+ * maintaining the array's sort-ness. The array can contain duplicates.
2197
+ * If the item already exists in the array the index would be of the *last*
2198
+ * occurrence of the item.
2199
+ *
2200
+ * Runs in O(logN) time.
2201
+ *
2202
+ * @param data - The (ascending) sorted array.
2203
+ * @param item - The item to insert.
2204
+ * @return - Insertion index (In the range 0..data.length)
2205
+ *
2206
+ * @signature
2207
+ * P.sortedLastIndex(data, item)
2208
+ * @example
2209
+ * P.sortedLastIndex(['a','a','b','c','c'], 'c') // => 5
2210
+ * @dataFirst
2211
+ * @category Array
2212
+ *
2213
+ * @see sortedIndex, sortedIndexBy, sortedIndexWith, sortedLastIndexBy
2214
+ */
2215
+ declare function sortedLastIndex<T>(data: ReadonlyArray<T>, item: T): number;
2216
+ /**
2217
+ * Find the insertion position (index) of an item in an array with items sorted
2218
+ * in ascending order; so that `splice(sortedIndex, 0, item)` would result in
2219
+ * maintaining the array's sort-ness. The array can contain duplicates.
2220
+ * If the item already exists in the array the index would be of the *last*
2221
+ * occurrence of the item.
2222
+ *
2223
+ * Runs in O(logN) time.
2224
+ *
2225
+ * @param item - The item to insert.
2226
+ * @return - Insertion index (In the range 0..data.length)
2227
+ *
2228
+ * @signature
2229
+ * P.sortedLastIndex(item)(data)
2230
+ * @example
2231
+ * P.pipe(['a','a','b','c','c'], sortedLastIndex('c')) // => 5
2232
+ * @dataLast
2233
+ * @category Array
2234
+ *
2235
+ * @see sortedIndex, sortedIndexBy, sortedIndexWith, sortedLastIndexBy
2236
+ */
2237
+ declare function sortedLastIndex<T>(item: T): (data: ReadonlyArray<T>) => number;
2238
+
2239
+ /**
2240
+ * Removes elements from an array and, inserts new elements in their place.
2241
+ *
2242
+ * @param items the array to splice.
2243
+ * @param start the index from which to start removing elements.
2244
+ * @param deleteCount the number of elements to remove.
2245
+ * @param replacement the elements to insert into the array in place of the deleted elements.
2246
+ * @signature
2247
+ * P.splice(items, start, deleteCount, replacement)
2248
+ * @example
2249
+ * P.splice([1,2,3,4,5,6,7,8], 2, 3, []); //=> [1,2,6,7,8]
2250
+ * P.splice([1,2,3,4,5,6,7,8], 2, 3, [9, 10]); //=> [1,2,9,10,6,7,8]
2251
+ * @dataFirst
2252
+ * @category Array
2253
+ */
2254
+ declare function splice<T>(items: ReadonlyArray<T>, start: number, deleteCount: number, replacement: ReadonlyArray<T>): Array<T>;
2255
+ /**
2256
+ * Removes elements from an array and, inserts new elements in their place.
2257
+ *
2258
+ * @param start the index from which to start removing elements.
2259
+ * @param deleteCount the number of elements to remove.
2260
+ * @param replacement the elements to insert into the array in place of the deleted elements.
2261
+ * @signature
2262
+ * P.splice(start, deleteCount, replacement)(items)
2263
+ * @example
2264
+ * P.pipe([1,2,3,4,5,6,7,8], P.splice(2, 3, [])) // => [1,2,6,7,8]
2265
+ * P.pipe([1,2,3,4,5,6,7,8], P.splice(2, 3, [9, 10])) // => [1,2,9,10,6,7,8]
2266
+ * @dataLast
2267
+ * @category Array
2268
+ */
2269
+ declare function splice<T>(start: number, deleteCount: number, replacement: ReadonlyArray<T>): (items: ReadonlyArray<T>) => Array<T>;
2270
+
2271
+ /**
2272
+ * Splits a given array at a given index.
2273
+ *
2274
+ * @param array the array to split
2275
+ * @param index the index to split at
2276
+ * @signature
2277
+ * P.splitAt(array, index)
2278
+ * @example
2279
+ * P.splitAt([1, 2, 3], 1) // => [[1], [2, 3]]
2280
+ * P.splitAt([1, 2, 3, 4, 5], -1) // => [[1, 2, 3, 4], [5]]
2281
+ * @dataFirst
2282
+ * @category Array
2283
+ */
2284
+ declare function splitAt<T>(array: ReadonlyArray<T>, index: number): [Array<T>, Array<T>];
2285
+ /**
2286
+ * Splits a given array at a given index.
2287
+ *
2288
+ * @param index the index to split at
2289
+ * @signature
2290
+ * P.splitAt(index)(array)
2291
+ * @example
2292
+ * P.splitAt(1)([1, 2, 3]) // => [[1], [2, 3]]
2293
+ * P.splitAt(-1)([1, 2, 3, 4, 5]) // => [[1, 2, 3, 4], [5]]
2294
+ * @dataLast
2295
+ * @category Array
2296
+ */
2297
+ declare function splitAt<T>(index: number): (array: ReadonlyArray<T>) => [Array<T>, Array<T>];
2298
+
2299
+ /**
2300
+ * Splits a given array at the first index where the given predicate returns true.
2301
+ * @param array the array to split
2302
+ * @param fn the predicate
2303
+ * @signature
2304
+ * P.splitWhen(array, fn)
2305
+ * @example
2306
+ * P.splitWhen([1, 2, 3], x => x === 2) // => [[1], [2, 3]]
2307
+ * @dataFirst
2308
+ * @category Array
2309
+ */
2310
+ declare function splitWhen<T>(array: ReadonlyArray<T>, fn: (item: T) => boolean): [Array<T>, Array<T>];
2311
+ /**
2312
+ * Splits a given array at an index where the given predicate returns true.
2313
+ * @param fn the predicate
2314
+ * @signature
2315
+ * P.splitWhen(fn)(array)
2316
+ * @example
2317
+ * P.splitWhen(x => x === 2)([1, 2, 3]) // => [[1], [2, 3]]
2318
+ * @dataLast
2319
+ * @category Array
2320
+ */
2321
+ declare function splitWhen<T>(fn: (item: T) => boolean): (array: ReadonlyArray<T>) => [Array<T>, Array<T>];
2322
+
2323
+ /**
2324
+ * Returns the sum of the elements of an array using the provided predicate.
2325
+ * @param fn predicate function
2326
+ * @signature
2327
+ * P.sumBy(fn)(array)
2328
+ * P.sumBy.indexed(fn)(array)
2329
+ * @example
2330
+ * P.pipe(
2331
+ * [{a: 5}, {a: 1}, {a: 3}],
2332
+ * P.sumBy(x => x.a)
2333
+ * ) // 9
2334
+ * @dataLast
2335
+ * @indexed
2336
+ * @category Array
2337
+ */
2338
+ declare function sumBy<T>(fn: (item: T) => number): (items: ReadonlyArray<T>) => number;
2339
+ /**
2340
+ * Returns the sum of the elements of an array using the provided predicate.
2341
+ * @param items the array
2342
+ * @param fn predicate function
2343
+ * @signature
2344
+ * P.sumBy(array, fn)
2345
+ * P.sumBy.indexed(array, fn)
2346
+ * @example
2347
+ * P.sumBy(
2348
+ * [{a: 5}, {a: 1}, {a: 3}],
2349
+ * x => x.a
2350
+ * ) // 9
2351
+ * @dataFirst
2352
+ * @indexed
2353
+ * @category Array
2354
+ */
2355
+ declare function sumBy<T>(items: ReadonlyArray<T>, fn: (item: T) => number): number;
2356
+ declare namespace sumBy {
2357
+ function indexed<T>(array: ReadonlyArray<T>, fn: PredIndexed<T, number>): number;
2358
+ function indexed<T>(fn: PredIndexed<T, number>): (array: ReadonlyArray<T>) => number;
2359
+ }
2360
+
2361
+ /**
2362
+ * @link https://github.com/sindresorhus/type-fest/blob/main/source/is-equal.d.ts
2363
+ */
2364
+ type isEqual<A, B> = (<G>() => G extends A ? 1 : 2) extends <G>() => G extends B ? 1 : 2 ? true : false;
2365
+ type Difference<A extends number, B extends number> = TupleOfLength<A> extends [
2366
+ ...infer U,
2367
+ ...TupleOfLength<B>
2368
+ ] ? U['length'] : never;
2369
+ type isLessThan<A extends number, B extends number> = isEqual<A, B> extends true ? false : 0 extends A ? true : 0 extends B ? false : isLessThan<Difference<A, 1>, Difference<B, 1>>;
2370
+ type TupleOfLength<L extends number, T extends IterableContainer = []> = T['length'] extends L ? T : TupleOfLength<L, [...T, unknown]>;
2371
+ type IsNonNegative<T extends number> = number extends T ? false : `${T}` extends `-${string}` ? false : true;
2372
+ type CharactersTuple<T extends string> = string extends T ? Array<string> : T extends `${infer C}${infer R}` ? [C, ...CharactersTuple<R>] : [];
2373
+ type SwapArrayInternal<T extends IterableContainer, Index1 extends number, Index2 extends number, Position extends ReadonlyArray<unknown> = [], Original extends IterableContainer = T> = T extends readonly [infer AtPosition, ...infer Rest] ? [
2374
+ Position['length'] extends Index1 ? Original[Index2] : Position['length'] extends Index2 ? Original[Index1] : AtPosition,
2375
+ ...SwapArrayInternal<Rest, Index1, Index2, [
2376
+ unknown,
2377
+ ...Position
2378
+ ], Original>
2379
+ ] : T;
2380
+ type SwapString<T extends string, K1 extends number, K2 extends number> = Joined<SwapArray<CharactersTuple<T>, K1, K2>, ''>;
2381
+ type SwapArray<T extends IterableContainer, K1 extends number, K2 extends number> = IsNonNegative<K1> extends false ? Array<T[number]> : IsNonNegative<K2> extends false ? Array<T[number]> : isLessThan<K1, T['length']> extends false ? T : isLessThan<K2, T['length']> extends false ? T : SwapArrayInternal<T, K1, K2>;
2382
+ type SwappedIndices<T extends IterableContainer | string, K1 extends number, K2 extends number> = T extends string ? SwapString<T, K1, K2> : T extends IterableContainer ? SwapArray<T, K1, K2> : never;
2383
+ /**
2384
+ * Swaps the positions of two elements in an array or string at the provided indices.
2385
+ *
2386
+ * Negative indices are supported and would be treated as an offset from the end of the array. The resulting type thought would be less strict than when using positive indices.
2387
+ *
2388
+ * If either index is out of bounds the result would be a shallow copy of the input, as-is.
2389
+ *
2390
+ * @param data the item to be manipulated. This can be an array, or a string.
2391
+ * @param index1 the first index
2392
+ * @param index2 the second index
2393
+ *
2394
+ * @signature
2395
+ * swapIndices(data, index1, index2)
2396
+ *
2397
+ * @example
2398
+ * swapIndices(['a', 'b', 'c'], 0, 1) // => ['b', 'a', 'c']
2399
+ * swapIndices(['a', 'b', 'c'], 1, -1) // => ['c', 'b', 'a']
2400
+ * swapIndices('abc', 0, 1) // => 'bac'
2401
+ *
2402
+ * @category Array
2403
+ *
2404
+ * @returns Returns the manipulated array or string.
2405
+ *
2406
+ * @dataFirst
2407
+ */
2408
+ declare function swapIndices<T extends IterableContainer | string, K1 extends number, K2 extends number>(data: T, index1: K1, index2: K2): SwappedIndices<T, K1, K2>;
2409
+ /**
2410
+ * @param index1 the first index
2411
+ * @param index2 the second index
2412
+ *
2413
+ * @signature
2414
+ * swapIndices(index1, index2)(data)
2415
+ *
2416
+ * @example
2417
+ * swapIndices(0, 1)(['a', 'b', 'c']) // => ['b', 'a', 'c']
2418
+ * swapIndices(0, -1)('abc') // => 'cba'
2419
+ *
2420
+ * @category Array
2421
+ * @returns Returns the manipulated array or string.
2422
+ * @dataLast
2423
+ */
2424
+ declare function swapIndices<K1 extends number, K2 extends number>(index1: K1, index2: K2): <T extends IterableContainer | string>(data: T) => SwappedIndices<T, K1, K2>;
2425
+
2426
+ /**
2427
+ * Returns the first `n` elements of `array`.
2428
+ * @param array the array
2429
+ * @param n the number of elements to take
2430
+ * @signature
2431
+ * P.take(array, n)
2432
+ * @example
2433
+ * P.take([1, 2, 3, 4, 3, 2, 1], 3) // => [1, 2, 3]
2434
+ * @dataFirst
2435
+ * @pipeable
2436
+ * @category Array
2437
+ */
2438
+ declare function take<T>(array: ReadonlyArray<T>, n: number): Array<T>;
2439
+ /**
2440
+ * Returns the first `n` elements of `array`.
2441
+ * @param n the number of elements to take
2442
+ * @signature
2443
+ * P.take(n)(array)
2444
+ * @example
2445
+ * P.pipe([1, 2, 3, 4, 3, 2, 1], P.take(n)) // => [1, 2, 3]
2446
+ * @dataLast
2447
+ * @pipeable
2448
+ * @category Array
2449
+ */
2450
+ declare function take<T>(n: number): (array: ReadonlyArray<T>) => Array<T>;
2451
+ declare namespace take {
2452
+ function lazy<T>(n: number): LazyEvaluator<T>;
2453
+ }
2454
+
2455
+ /**
2456
+ * Take the first `n` items from `data` based on the provided ordering criteria.
2457
+ * This allows you to avoid sorting the array before taking the items.
2458
+ * The complexity of this function is *O(Nlogn)* where `N` is the length of the array.
2459
+ *
2460
+ * For the opposite operation (to drop `n` elements) see `dropFirstBy`.
2461
+ *
2462
+ * @params data - the input array
2463
+ * @params n - the number of items to take. If `n` is non-positive no items would be returned, if `n` is bigger then data.length a *clone* of `data` would be returned.
2464
+ * @param rules - A variadic array of order rules defining the sorting criteria.
2465
+ * Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, "desc"]` for descending order.
2466
+ * @returns a subset of the input array.
2467
+ * @signature
2468
+ * P.takeFirstBy(data, n, ...rules);
2469
+ * @example
2470
+ * P.takeFirstBy(['aa', 'aaaa', 'a', 'aaa'], 2, x => x.length); // => ['a', 'aa']
2471
+ * @dataFirst
2472
+ * @category Array
2473
+ */
2474
+ declare function takeFirstBy<T>(data: ReadonlyArray<T>, n: number, ...rules: Readonly<NonEmptyArray<OrderRule<T>>>): Array<T>;
2475
+ /**
2476
+ * Take the first `n` items from `data` based on the provided ordering criteria.
2477
+ * This allows you to avoid sorting the array before taking the items.
2478
+ * The complexity of this function is *O(Nlogn)* where `N` is the length of the array.
2479
+ *
2480
+ * For the opposite operation (to drop `n` elements) see `dropFirstBy`.
2481
+ *
2482
+ * @params n - the number of items to take. If `n` is non-positive no items would be returned, if `n` is bigger then data.length a *clone* of `data` would be returned.
2483
+ * @param rules - A variadic array of order rules defining the sorting criteria.
2484
+ * Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, "desc"]` for descending order.
2485
+ * @returns a subset of the input array.
2486
+ * @signature
2487
+ * P.takeFirstBy(n, ...rules)(data);
2488
+ * @example
2489
+ * R.pipe(['aa', 'aaaa', 'a', 'aaa'], P.takeFirstBy(2, x => x.length)); // => ['a', 'aa']
2490
+ * @dataLast
2491
+ * @category Array
2492
+ */
2493
+ declare function takeFirstBy<T>(n: number, ...rules: Readonly<NonEmptyArray<OrderRule<T>>>): (data: ReadonlyArray<T>) => Array<T>;
2494
+
2495
+ /**
2496
+ * Returns elements from the array until predicate returns false.
2497
+ * @param array the array
2498
+ * @param fn the predicate
2499
+ * @signature
2500
+ * P.takeWhile(array, fn)
2501
+ * @example
2502
+ * P.takeWhile([1, 2, 3, 4, 3, 2, 1], x => x !== 4) // => [1, 2, 3]
2503
+ * @dataFirst
2504
+ * @category Array
2505
+ */
2506
+ declare function takeWhile<T>(array: ReadonlyArray<T>, fn: (item: T) => boolean): Array<T>;
2507
+ /**
2508
+ * Returns elements from the array until predicate returns false.
2509
+ * @param fn the predicate
2510
+ * @signature
2511
+ * P.takeWhile(fn)(array)
2512
+ * @example
2513
+ * P.pipe([1, 2, 3, 4, 3, 2, 1], P.takeWhile(x => x !== 4)) // => [1, 2, 3]
2514
+ * @dataLast
2515
+ * @category Array
2516
+ */
2517
+ declare function takeWhile<T>(fn: (item: T) => boolean): (array: ReadonlyArray<T>) => Array<T>;
2518
+
2519
+ /**
2520
+ * Returns a new array containing only one copy of each element in the original list.
2521
+ * Elements are compared by reference using Set.
2522
+ * @param array
2523
+ * @signature
2524
+ * P.uniq(array)
2525
+ * @example
2526
+ * P.uniq([1, 2, 2, 5, 1, 6, 7]) // => [1, 2, 5, 6, 7]
2527
+ * @pipeable
2528
+ * @category Array
2529
+ * @dataFirst
2530
+ */
2531
+ declare function uniq<T>(array: ReadonlyArray<T>): Array<T>;
2532
+ /**
2533
+ * Returns a new array containing only one copy of each element in the original list.
2534
+ * Elements are compared by reference using Set.
2535
+ * @param array
2536
+ * @signature
2537
+ * P.uniq()(array)
2538
+ * @example
2539
+ * P.pipe(
2540
+ * [1, 2, 2, 5, 1, 6, 7], // only 4 iterations
2541
+ * P.uniq(),
2542
+ * P.take(3)
2543
+ * ) // => [1, 2, 5]
2544
+ * @pipeable
2545
+ * @category Array
2546
+ * @dataLast
2547
+ */
2548
+ declare function uniq<T>(): (array: ReadonlyArray<T>) => Array<T>;
2549
+ declare namespace uniq {
2550
+ function lazy<T>(): LazyEvaluator<T>;
2551
+ }
2552
+
2553
+ declare function uniqBy<T, K>(array: ReadonlyArray<T>, transformer: (item: T) => K): Array<T>;
2554
+ /**
2555
+ * Returns a new array containing only one copy of each element in the original list transformed by a function.
2556
+ * Elements are compared by reference using Set.
2557
+ * @param array
2558
+ * @signature
2559
+ * P.uniqBy(array, fn)
2560
+ * @example
2561
+ * P.uniqBy(
2562
+ * [{ n: 1 }, { n: 2 }, { n: 2 }, { n: 5 }, { n: 1 }, { n: 6 }, { n: 7 }],
2563
+ * (obj) => obj.n,
2564
+ * ) // => [{n: 1}, {n: 2}, {n: 5}, {n: 6}, {n: 7}]
2565
+ * P.pipe(
2566
+ * [{n: 1}, {n: 2}, {n: 2}, {n: 5}, {n: 1}, {n: 6}, {n: 7}], // only 4 iterations
2567
+ * P.uniqBy(obj => obj.n),
2568
+ * P.take(3)
2569
+ * ) // => [{n: 1}, {n: 2}, {n: 5}]
2570
+ * @pipeable
2571
+ * @category Array
2572
+ */
2573
+ declare function uniqBy<T, K>(transformer: (item: T) => K): (array: ReadonlyArray<T>) => Array<T>;
2574
+
2575
+ type IsEquals<T> = (a: T, b: T) => boolean;
2576
+ declare function lazy_<T>(isEquals: IsEquals<T>): LazyEvaluator<T>;
2577
+ /**
2578
+ * Returns a new array containing only one copy of each element in the original list.
2579
+ * Elements are compared by custom comparator isEquals.
2580
+ * @param array
2581
+ * @param isEquals the comparator
2582
+ * @signature
2583
+ * P.uniqWith(array, isEquals)
2584
+ * @example
2585
+ * P.uniqWith(
2586
+ * [{a: 1}, {a: 2}, {a: 2}, {a: 5}, {a: 1}, {a: 6}, {a: 7}],
2587
+ * P.isDeepEqual,
2588
+ * ) // => [{a: 1}, {a: 2}, {a: 5}, {a: 6}, {a: 7}]
2589
+ * @dataFirst
2590
+ * @category Array
2591
+ */
2592
+ declare function uniqWith<T>(array: ReadonlyArray<T>, isEquals: IsEquals<T>): Array<T>;
2593
+ /**
2594
+ * Returns a new array containing only one copy of each element in the original list.
2595
+ * Elements are compared by custom comparator isEquals.
2596
+ * @param isEquals the comparator
2597
+ * @signature P.uniqWith(isEquals)(array)
2598
+ * @example
2599
+ * P.uniqWith(P.isDeepEqual)(
2600
+ * [{a: 1}, {a: 2}, {a: 2}, {a: 5}, {a: 1}, {a: 6}, {a: 7}],
2601
+ * ) // => [{a: 1}, {a: 2}, {a: 5}, {a: 6}, {a: 7}]
2602
+ * P.pipe(
2603
+ * [{a: 1}, {a: 2}, {a: 2}, {a: 5}, {a: 1}, {a: 6}, {a: 7}], // only 4 iterations
2604
+ * P.uniqWith(P.isDeepEqual),
2605
+ * P.take(3)
2606
+ * ) // => [{a: 1}, {a: 2}, {a: 5}]
2607
+ * @dataLast
2608
+ * @category Object
2609
+ */
2610
+ declare function uniqWith<T>(isEquals: IsEquals<T>): (array: ReadonlyArray<T>) => Array<T>;
2611
+ declare namespace uniqWith {
2612
+ const lazy: typeof lazy_ & {
2613
+ readonly indexed: true;
2614
+ };
2615
+ }
2616
+
2617
+ interface Strict$3 {
2618
+ <F extends IterableContainer, S extends IterableContainer>(first: F, second: S): Zip<F, S>;
2619
+ <S extends IterableContainer>(second: S): <F extends IterableContainer>(first: F) => Zip<F, S>;
2620
+ }
2621
+ type Zip<Left extends IterableContainer, Right extends IterableContainer> = Left extends readonly [] ? [] : Right extends readonly [] ? [] : Left extends readonly [infer LeftHead, ...infer LeftRest] ? Right extends readonly [infer RightHead, ...infer RightRest] ? [
2622
+ [LeftHead, RightHead],
2623
+ ...Zip<LeftRest, RightRest>
2624
+ ] : [
2625
+ [LeftHead, Right[number]],
2626
+ ...Zip<LeftRest, Right>
2627
+ ] : Right extends readonly [infer RightHead, ...infer RightRest] ? [[Left[number], RightHead], ...Zip<Left, RightRest>] : Array<[Left[number], Right[number]]>;
2628
+ /**
2629
+ * Creates a new list from two supplied lists by pairing up equally-positioned items.
2630
+ * The length of the returned list will match the shortest of the two inputs.
2631
+ *
2632
+ * If the input array are tuples, you can use the strict option
2633
+ * to get another tuple instead of a generic array type.
2634
+ * @param first the first input list
2635
+ * @param second the second input list
2636
+ * @signature
2637
+ * P.zip(first, second)
2638
+ * @example
2639
+ * P.zip([1, 2], ['a', 'b']) // => [[1, 'a'], [2, 'b']] (type: [number, string][])
2640
+ * P.zip.strict([1, 2] as const, ['a', 'b'] as const) // => [[1, 'a'], [2, 'b']] (type: [[1, 'a'], [2, 'b']])
2641
+ * @dataFirst
2642
+ * @category Array
2643
+ * @strict
2644
+ */
2645
+ declare function zip<F, S>(first: ReadonlyArray<F>, second: ReadonlyArray<S>): Array<[F, S]>;
2646
+ /**
2647
+ * Creates a new list from two supplied lists by pairing up equally-positioned items.
2648
+ * The length of the returned list will match the shortest of the two inputs.
2649
+ *
2650
+ * If the input array are tuples, you can use the strict option
2651
+ * to get another tuple instead of a generic array type.
2652
+ * @param second the second input list
2653
+ * @signature
2654
+ * P.zip(second)(first)
2655
+ * @example
2656
+ * P.zip(['a', 'b'])([1, 2]) // => [[1, 'a'], [2, 'b']] (type: [number, string][])
2657
+ * P.zip.strict(['a', 'b'] as const)([1, 2] as const) // => [[1, 'a'], [2, 'b']] (type: [[1, 'a'], [2, 'b']])
2658
+ * @dataLast
2659
+ * @category Array
2660
+ * @strict
2661
+ */
2662
+ declare function zip<S>(second: ReadonlyArray<S>): <F>(first: ReadonlyArray<F>) => Array<[F, S]>;
2663
+ declare namespace zip {
2664
+ const strict: Strict$3;
2665
+ }
2666
+
2667
+ /**
2668
+ * Creates a new object from two supplied lists by pairing up equally-positioned items.
2669
+ * Key/value pairing is truncated to the length of the shorter of the two lists
2670
+ * @param first the first input list
2671
+ * @param second the second input list
2672
+ * @signature
2673
+ * P.zipObj(first, second)
2674
+ * @example
2675
+ * P.zipObj(['a', 'b'], [1, 2]) // => {a: 1, b: 2}
2676
+ * @dataFirst
2677
+ * @category Array
2678
+ */
2679
+ declare function zipObj<F extends PropertyKey, S>(first: ReadonlyArray<F>, second: ReadonlyArray<S>): Record<F, S>;
2680
+ /**
2681
+ * Creates a new object from two supplied lists by pairing up equally-positioned items.
2682
+ * Key/value pairing is truncated to the length of the shorter of the two lists
2683
+ * @param second the second input list
2684
+ * @signature
2685
+ * P.zipObj(second)(first)
2686
+ * @example
2687
+ * P.zipObj([1, 2])(['a', 'b']) // => {a: 1, b: 2}
2688
+ * @dataLast
2689
+ * @category Array
2690
+ */
2691
+ declare function zipObj<S>(second: ReadonlyArray<S>): <F extends PropertyKey>(first: ReadonlyArray<F>) => Record<F, S>;
2692
+
2693
+ type ZippingFunction<F = unknown, S = unknown, R = unknown> = (f: F, s: S) => R;
2694
+ /**
2695
+ * Creates a new list from two supplied lists by calling the supplied function
2696
+ * with the same-positioned element from each list.
2697
+ * @param first the first input list
2698
+ * @param second the second input list
2699
+ * @param fn the function applied to each position of the list
2700
+ * @signature
2701
+ * P.zipWith(first, second, fn)
2702
+ * @example
2703
+ * P.zipWith(['1', '2', '3'], ['a', 'b', 'c'], (a, b) => a + b) // => ['1a', '2b', '3c']
2704
+ * @dataFirst
2705
+ * @category Array
2706
+ */
2707
+ declare function zipWith<F, S, R>(first: ReadonlyArray<F>, second: ReadonlyArray<S>, fn: ZippingFunction<F, S, R>): Array<R>;
2708
+ /**
2709
+ * Creates a new list from two supplied lists by calling the supplied function
2710
+ * with the same-positioned element from each list.
2711
+ * @param fn the function applied to each position of the list
2712
+ * @signature
2713
+ * P.zipWith(fn)(first, second)
2714
+ * @example
2715
+ * P.zipWith((a, b) => a + b)(['1', '2', '3'], ['a', 'b', 'c']) // => ['1a', '2b', '3c']
2716
+ * @dataLast
2717
+ * @category Array
2718
+ */
2719
+ declare function zipWith<F, S, R>(fn: ZippingFunction<F, S, R>): (first: ReadonlyArray<F>, second: ReadonlyArray<S>) => Array<R>;
2720
+ /**
2721
+ * Creates a new list from two supplied lists by calling the supplied function
2722
+ * with the same-positioned element from each list.
2723
+ * @param fn the function applied to each position of the list
2724
+ * @param second the second input list
2725
+ * @signature
2726
+ * P.zipWith(fn)(first, second)
2727
+ * @example
2728
+ * P.zipWith((a, b) => a + b, ['a', 'b', 'c'])(['1', '2', '3']) // => ['1a', '2b', '3c']
2729
+ * @dataLast
2730
+ * @category Array
2731
+ */
2732
+ declare function zipWith<F, S, R>(fn: ZippingFunction<F, S, R>, second: ReadonlyArray<S>): (first: ReadonlyArray<F>) => Array<R>;
2733
+
2734
+ type Case<In, Out, Thru extends In = In> = readonly [
2735
+ when: ((data: In) => boolean) | ((data: In) => data is Thru),
2736
+ then: (data: Thru) => Out
2737
+ ];
2738
+ /**
2739
+ * Executes a transformer function based on the first matching predicate,
2740
+ * functioning like a series of `if...else if...` statements. It sequentially
2741
+ * evaluates each case and, upon finding a truthy predicate, runs the
2742
+ * corresponding transformer, and returns, ignoring any further cases, even if
2743
+ * they would match.
2744
+ *
2745
+ * !IMPORTANT! - Unlike similar implementations in frameworks like Lodash and
2746
+ * Ramda, this implementation does **NOT** return a default/fallback
2747
+ * `undefined` value when none of the cases match; and instead will **throw** an
2748
+ * exception in those cases.
2749
+ * To add a default case use the `conditional.defaultCase` helper as the final
2750
+ * case of your implementation. By default it returns `undefined`, but could be
2751
+ * provided a transformer in order to return something else.
2752
+ *
2753
+ * Due to TypeScript's inability to infer the result of negating a type-
2754
+ * predicate we can't refine the types used in subsequent cases based on
2755
+ * previous conditions. Using a `switch (true)` statement or ternary operators
2756
+ * is recommended for more precise type control when such type narrowing is
2757
+ * needed.
2758
+ *
2759
+ * @param cases - A list of (up to 10) tuples, each defining a case. Each tuple
2760
+ * consists of a predicate (or a type-predicate) and a transformer function that
2761
+ * processes the data if its case matches.
2762
+ * @returns The output of the matched transformer. If no cases match, an
2763
+ * exception is thrown. The return type is a union of the return types of all
2764
+ * provided transformers.
2765
+ * @signature
2766
+ * P.conditional(...cases)(data);
2767
+ * @example
2768
+ * const nameOrId = 3 as string | number;
2769
+ * P.pipe(
2770
+ * nameOrId,
2771
+ * P.conditional(
2772
+ * [P.isString, (name) => `Hello ${name}`],
2773
+ * [P.isNumber, (id) => `Hello ID: ${id}`],
2774
+ * P.conditional.defaultCase(
2775
+ * (something) => `Hello something (${JSON.stringify(something)})`,
2776
+ * ),
2777
+ * ),
2778
+ * ); //=> 'Hello ID: 3'
2779
+ * @dataLast
2780
+ * @category Function
2781
+ */
2782
+ declare function conditional<T, Return0, Return1 = never, Return2 = never, Return3 = never, Return4 = never, Return5 = never, Return6 = never, Return7 = never, Return8 = never, Return9 = never, Thru0 extends T = T, Thru1 extends T = T, Thru2 extends T = T, Thru3 extends T = T, Thru4 extends T = T, Thru5 extends T = T, Thru6 extends T = T, Thru7 extends T = T, Thru8 extends T = T, Thru9 extends T = T>(case0: Case<T, Return0, Thru0>, case1?: Case<T, Return1, Thru1>, case2?: Case<T, Return2, Thru2>, case3?: Case<T, Return3, Thru3>, case4?: Case<T, Return4, Thru4>, case5?: Case<T, Return5, Thru5>, case6?: Case<T, Return6, Thru6>, case7?: Case<T, Return7, Thru7>, case8?: Case<T, Return8, Thru8>, case9?: Case<T, Return9, Thru9>): (data: T) => Return0 | Return1 | Return2 | Return3 | Return4 | Return5 | Return6 | Return7 | Return8 | Return9;
2783
+ /**
2784
+ * Executes a transformer function based on the first matching predicate,
2785
+ * functioning like a series of `if...else if...` statements. It sequentially
2786
+ * evaluates each case and, upon finding a truthy predicate, runs the
2787
+ * corresponding transformer, and returns, ignoring any further cases, even if
2788
+ * they would match.
2789
+ *
2790
+ * !IMPORTANT! - Unlike similar implementations in frameworks like Lodash and
2791
+ * Ramda, this implementation does **NOT** return a default/fallback
2792
+ * `undefined` value when none of the cases match; and instead will **throw** an
2793
+ * exception in those cases.
2794
+ * To add a default case use the `conditional.defaultCase` helper as the final
2795
+ * case of your implementation. By default it returns `undefined`, but could be
2796
+ * provided a transformer in order to return something else.
2797
+ *
2798
+ * Due to TypeScript's inability to infer the result of negating a type-
2799
+ * predicate we can't refine the types used in subsequent cases based on
2800
+ * previous conditions. Using a `switch (true)` statement or ternary operators
2801
+ * is recommended for more precise type control when such type narrowing is
2802
+ * needed.
2803
+ *
2804
+ * @param data - The input data to be evaluated against the provided cases.
2805
+ * @param cases - A list of (up to 10) tuples, each defining a case. Each tuple
2806
+ * consists of a predicate (or a type-predicate) and a transformer function that
2807
+ * processes the data if its case matches.
2808
+ * @returns The output of the matched transformer. If no cases match, an
2809
+ * exception is thrown. The return type is a union of the return types of all
2810
+ * provided transformers.
2811
+ * @signature
2812
+ * P.conditional(data, ...cases);
2813
+ * @example
2814
+ * const nameOrId = 3 as string | number;
2815
+ * P.conditional(
2816
+ * nameOrId,
2817
+ * [P.isString, (name) => `Hello ${name}`],
2818
+ * [P.isNumber, (id) => `Hello ID: ${id}`],
2819
+ * P.conditional.defaultCase(
2820
+ * (something) => `Hello something (${JSON.stringify(something)})`,
2821
+ * ),
2822
+ * ); //=> 'Hello ID: 3'
2823
+ * @dataFirst
2824
+ * @category Function
2825
+ */
2826
+ declare function conditional<T, Return0, Return1 = never, Return2 = never, Return3 = never, Return4 = never, Return5 = never, Return6 = never, Return7 = never, Return8 = never, Return9 = never, Thru0 extends T = T, Thru1 extends T = T, Thru2 extends T = T, Thru3 extends T = T, Thru4 extends T = T, Thru5 extends T = T, Thru6 extends T = T, Thru7 extends T = T, Thru8 extends T = T, Thru9 extends T = T>(data: T, case0: Case<T, Return0, Thru0>, case1?: Case<T, Return1, Thru1>, case2?: Case<T, Return2, Thru2>, case3?: Case<T, Return3, Thru3>, case4?: Case<T, Return4, Thru4>, case5?: Case<T, Return5, Thru5>, case6?: Case<T, Return6, Thru6>, case7?: Case<T, Return7, Thru7>, case8?: Case<T, Return8, Thru8>, case9?: Case<T, Return9, Thru9>): Return0 | Return1 | Return2 | Return3 | Return4 | Return5 | Return6 | Return7 | Return8 | Return9;
2827
+ declare namespace conditional {
2828
+ /**
2829
+ * A simplified case that accepts all data. Put this as the last case to
2830
+ * prevent an exception from being thrown when none of the previous cases
2831
+ * match.
2832
+ * If this is not the last case it will short-circuit anything after it.
2833
+ * @param then - You only need to provide the transformer, the predicate is
2834
+ * implicit. @default () => undefined, which is how Lodash and Ramda handle
2835
+ * the final fallback case.
2836
+ */
2837
+ function defaultCase<In>(then?: (data: In) => unknown): readonly [() => boolean, (data: In) => unknown];
2838
+ }
2839
+
2840
+ /**
2841
+ * Creates a data-last pipe function. First function must be always annotated. Other functions are automatically inferred.
2842
+ * @signature
2843
+ * P.createPipe(op1, op2, op3)(data);
2844
+ * @example
2845
+ * P.createPipe(
2846
+ * (x: number) => x * 2,
2847
+ * x => x * 3
2848
+ * )(1) // => 6
2849
+ * @category Function
2850
+ */
2851
+ declare function createPipe<A, B>(op1: (input: A) => B): (value: A) => B;
2852
+ declare function createPipe<A, B, C>(op1: (input: A) => B, op2: (input: B) => C): (value: A) => C;
2853
+ declare function createPipe<A, B, C, D>(op1: (input: A) => B, op2: (input: B) => C, op3: (input: C) => D): (value: A) => D;
2854
+ declare function createPipe<A, B, C, D, E>(op1: (input: A) => B, op2: (input: B) => C, op3: (input: C) => D, op4: (input: D) => E): (value: A) => E;
2855
+ declare function createPipe<A, B, C, D, E, F>(op1: (input: A) => B, op2: (input: B) => C, op3: (input: C) => D, op4: (input: D) => E, op5: (input: E) => F): (value: A) => F;
2856
+ declare function createPipe<A, B, C, D, E, F, G>(op1: (input: A) => B, op2: (input: B) => C, op3: (input: C) => D, op4: (input: D) => E, op5: (input: E) => F, op6: (input: F) => G): (value: A) => G;
2857
+ declare function createPipe<A, B, C, D, E, F, G, H>(op1: (input: A) => B, op2: (input: B) => C, op3: (input: C) => D, op4: (input: D) => E, op5: (input: E) => F, op6: (input: F) => G, op7: (input: G) => H): (value: A) => H;
2858
+
2859
+ /**
2860
+ * A function that always returns the param passed to it
2861
+ * @signature
2862
+ * P.identity(data)
2863
+ * @example
2864
+ * P.identity('foo') // => 'foo'
2865
+ * @category Function
2866
+ */
2867
+ declare function identity<T>(value: T): T;
2868
+
2869
+ /**
2870
+ * A function that returns always `undefined`.
2871
+ * @signature
2872
+ * P.noop()
2873
+ * @example
2874
+ * onSomething(P.noop)
2875
+ * @category Function
2876
+ */
2877
+ declare function noop(): undefined;
2878
+
2879
+ /**
2880
+ * Creates a function that is restricted to invoking `func` once. Repeat calls to the function return the value of the first invocation.
2881
+ * @param fn the function to wrap
2882
+ * @signature P.once(fn)
2883
+ * @example
2884
+ * const initialize = P.once(createApplication);
2885
+ * initialize();
2886
+ * initialize();
2887
+ * // => `createApplication` is invoked once
2888
+ * @category Function
2889
+ */
2890
+ declare function once<T>(fn: () => T): () => T;
2891
+
2892
+ interface Debouncer<F extends (...args: any) => unknown, IsNullable extends boolean = true> {
2893
+ /**
2894
+ * The last computed value of the debounced function.
2895
+ */
2896
+ readonly cachedValue: ReturnType<F> | undefined;
2897
+ /**
2898
+ * Invoke the debounced function.
2899
+ * @param args - same as the args for the debounced function.
2900
+ * @returns - the last computed value of the debounced function with the
2901
+ * latest args provided to it. If `timing` does not include `leading` then the
2902
+ * the function would return `undefined` until the first cool-down period is
2903
+ * over, otherwise the function would always return the return type of the
2904
+ * debounced function.
2905
+ */
2906
+ readonly call: (...args: Parameters<F>) => ReturnType<F> | (true extends IsNullable ? undefined : never);
2907
+ /**
2908
+ * Cancels any debounced functions without calling them, effectively resetting
2909
+ * the debouncer to the same state it is when initially created.
2910
+ */
2911
+ readonly cancel: () => void;
2912
+ /**
2913
+ * Similar to `cancel`, but would also trigger the `trailing` invocation if
2914
+ * the debouncer would run one at the end of the cool-down period.
2915
+ */
2916
+ readonly flush: () => ReturnType<F> | undefined;
2917
+ /**
2918
+ * Is `true` when there is an active cool-down period currently debouncing
2919
+ * invocations.
2920
+ */
2921
+ readonly isPending: boolean;
2922
+ }
2923
+ interface DebounceOptions {
2924
+ readonly maxWaitMs?: number;
2925
+ readonly waitMs?: number;
2926
+ }
2927
+ /**
2928
+ * Wraps `func` with a debouncer object that "debounces" (delays) invocations of the function during a defined cool-down period (`waitMs`). It can be configured to invoke the function either at the start of the cool-down period, the end of it, or at both ends (`timing`).
2929
+ * It can also be configured to allow invocations during the cool-down period (`maxWaitMs`).
2930
+ * It stores the latest call's arguments so they could be used at the end of the cool-down period when invoking `func` (if configured to invoke the function at the end of the cool-down period).
2931
+ * It stores the value returned by `func` whenever its invoked. This value is returned on every call, and is accessible via the `cachedValue` property of the debouncer. Its important to note that the value might be different from the value that would be returned from running `func` with the current arguments as it is a cached value from a previous invocation.
2932
+ * **Important**: The cool-down period defines the minimum between two invocations, and not the maximum. The period will be **extended** each time a call is made until a full cool-down period has elapsed without any additional calls.
2933
+ * @param func The function to debounce, the returned `call` function will have
2934
+ * the exact same signature.
2935
+ * @param options An object allowing further customization of the debouncer:
2936
+ * - `timing?: 'leading' | 'trailing' |'both'`. The default is `'trailing'`.
2937
+ * `leading` would result in the function being invoked at the start of the
2938
+ * cool-down period; `trailing` would result in the function being invoked at
2939
+ * the end of the cool-down period (using the args from the last call to the
2940
+ * debouncer). When `both` is selected the `trailing` invocation would only
2941
+ * take place if there were more than one call to the debouncer during the
2942
+ * cool-down period. **DEFAULT: 'trailing'**
2943
+ * - `waitMs?: number`. The length of the cool-down period in milliseconds. The
2944
+ * debouncer would wait until this amount of time has passed without **any**
2945
+ * additional calls to the debouncer before triggering the end-of-cool-down-
2946
+ * period event. When this happens, the function would be invoked (if `timing`
2947
+ * isn't `'leading'`) and the debouncer state would be reset. **DEFAULT: 0**
2948
+ * - `maxWaitMs?: number`. The length of time since a debounced call (a call
2949
+ * that the debouncer prevented from being invoked) was made until it would be
2950
+ * invoked. Because the debouncer can be continually triggered and thus never
2951
+ * reach the end of the cool-down period, this allows the function to still
2952
+ * be invoked occasionally. IMPORTANT: This param is ignored when `timing` is
2953
+ * `'leading'`.
2954
+ * @returns a debouncer object. The main function is `call`. In addition to it
2955
+ * the debouncer comes with the following additional functions and properties:
2956
+ * - `cancel` method to cancel delayed `func` invocations
2957
+ * - `flush` method to end the cool-down period immediately.
2958
+ * - `cachedValue` the latest return value of an invocation (if one occurred).
2959
+ * - `isPending` flag to check if there is an inflight cool-down window.
2960
+ * @signature
2961
+ * P.debounce(func, options);
2962
+ * @example
2963
+ * const debouncer = debounce(identity, { timing: 'trailing', waitMs: 1000 });
2964
+ * const result1 = debouncer.call(1); // => undefined
2965
+ * const result2 = debouncer.call(2); // => undefined
2966
+ * // after 1 second
2967
+ * const result3 = debouncer.call(3); // => 2
2968
+ * // after 1 second
2969
+ * debouncer.cachedValue; // => 3
2970
+ * @dataFirst
2971
+ * @category Function
2972
+ * @see https://css-tricks.com/debouncing-throttling-explained-examples/
2973
+ */
2974
+ declare function debounce<F extends (...args: any) => any>(func: F, options: {
2975
+ readonly timing?: 'trailing';
2976
+ } & DebounceOptions): Debouncer<F>;
2977
+ declare function debounce<F extends (...args: any) => any>(func: F, options: ({
2978
+ readonly timing: 'both';
2979
+ } & DebounceOptions) | ({
2980
+ readonly timing: 'leading';
2981
+ } & Omit<DebounceOptions, 'maxWaitMs'>)): Debouncer<F, false>;
2982
+
2983
+ type LazyEvaluatorFactory = (...args: any) => LazyEvaluator;
2984
+ interface MaybeLazyFunction {
2985
+ (...args: any): unknown;
2986
+ readonly lazy?: LazyEvaluatorFactory;
2987
+ }
2988
+ /**
2989
+ * Creates a function with `dataFirst` and `dataLast` signatures.
2990
+ *
2991
+ * `purry` is a dynamic function and it's not type safe. It should be wrapped by
2992
+ * a function that have proper typings. Refer to the example below for correct
2993
+ * usage.
2994
+ *
2995
+ * !IMPORTANT: functions that simply call `purry` and return the result (like
2996
+ * almost all functions in this library) should return `unknown` themselves if
2997
+ * an explicit return type is required. This is because we currently don't
2998
+ * provide a generic return type that is built from the input function, and
2999
+ * crafting one manually isn't worthwhile as we rely on function declaration
3000
+ * overloading to combine the types for dataFirst and dataLast invocations!
3001
+ *
3002
+ * @param fn the function to purry.
3003
+ * @param args the arguments
3004
+ * @param lazyFactory - A lazy version of the function to purry.
3005
+ * @signature P.purry(fn, arguments);
3006
+ * @exampleRaw
3007
+ * function findIndex_(array, fn) {
3008
+ * for (let i = 0; i < array.length; i++) {
3009
+ * if (fn(array[i])) {
3010
+ * return i;
3011
+ * }
3012
+ * }
3013
+ * return -1;
3014
+ * }
3015
+ *
3016
+ * // data-first
3017
+ * function findIndex<T>(array: T[], fn: (item: T) => boolean): number;
3018
+ *
3019
+ * // data-last
3020
+ * function findIndex<T>(fn: (item: T) => boolean): (array: T[]) => number;
3021
+ *
3022
+ * function findIndex() {
3023
+ * return P.purry(findIndex_, arguments);
3024
+ * }
3025
+ * @category Function
3026
+ */
3027
+ declare function purry(fn: MaybeLazyFunction, args: IArguments | ReadonlyArray<unknown>, lazyFactory?: LazyEvaluatorFactory): unknown;
3028
+
3029
+ /**
3030
+ * Delay execution for a given number of milliseconds.
3031
+ *
3032
+ * @param timeout the number of milliseconds to wait
3033
+ * @signature
3034
+ * P.sleep(timeout)
3035
+ * @example
3036
+ * P.sleep(1000) // => Promise<void>
3037
+ * @category Function
3038
+ */
3039
+ declare function sleep(timeout: number): Promise<void>;
3040
+
3041
+ /**
3042
+ * Calls an input function `n` times, returning an array containing the results
3043
+ * of those function calls.
3044
+ *
3045
+ * `fn` is passed one argument: The current value of `n`, which begins at `0`
3046
+ * and is gradually incremented to `n - 1`.
3047
+ *
3048
+ * @param count A value between `0` and `n - 1`. Increments after each function call.
3049
+ * @param fn The function to invoke. Passed one argument, the current value of `n`.
3050
+ * @return An array containing the return values of all calls to `fn`.
3051
+ * @example times(5, identity); //=> [0, 1, 2, 3, 4]
3052
+ * @dataFirst
3053
+ */
3054
+ declare function times<T>(count: number, fn: (n: number) => T): Array<T>;
3055
+ /**
3056
+ * Calls an input function `n` times, returning an array containing the results
3057
+ * of those function calls.
3058
+ *
3059
+ * `fn` is passed one argument: The current value of `n`, which begins at `0`
3060
+ * and is gradually incremented to `n - 1`.
3061
+ *
3062
+ * @param fn The function to invoke. Passed one argument, the current value of `n`.
3063
+ * @return An array containing the return values of all calls to `fn`.
3064
+ * @example P.times(identity)(5); //=> [0, 1, 2, 3, 4]
3065
+ * @dataLast
3066
+ */
3067
+ declare function times<T>(fn: (n: number) => T): (count: number) => Array<T>;
3068
+
3069
+ /**
3070
+ * Checks if `subObject` is a sub-object of `object`, which means for every
3071
+ * property and value in `subObject`, there's the same property in `object`
3072
+ * with an equal value. Equality is checked with `isDeepEqual`.
3073
+ *
3074
+ * @param data - The object to test.
3075
+ * @param subObject - The sub-object to test against.
3076
+ * @signature
3077
+ * P.hasSubObject(data, subObject)
3078
+ * @example
3079
+ * P.hasSubObject({ a: 1, b: 2, c: 3 }, { a: 1, c: 3 }) //=> true
3080
+ * P.hasSubObject({ a: 1, b: 2, c: 3 }, { b: 4 }) //=> false
3081
+ * P.hasSubObject({ a: 1, b: 2, c: 3 }, {}) //=> true
3082
+ * @dataFirst
3083
+ * @category Guard
3084
+ */
3085
+ declare function hasSubObject<T, S extends Partial<T>>(data: T, subObject: S): data is Simplify<S & T>;
3086
+ /**
3087
+ * Checks if `subObject` is a sub-object of `object`, which means for every
3088
+ * property and value in `subObject`, there's the same property in `object`
3089
+ * with an equal value. Equality is checked with `isDeepEqual`.
3090
+ *
3091
+ * @param subObject - The sub-object to test against.
3092
+ * @signature
3093
+ * P.hasSubObject(subObject)(data)
3094
+ * @example
3095
+ * P.hasSubObject({ a: 1, c: 3 })({ a: 1, b: 2, c: 3 }) //=> true
3096
+ * P.hasSubObject({ b: 4 })({ a: 1, b: 2, c: 3 }) //=> false
3097
+ * P.hasSubObject({})({ a: 1, b: 2, c: 3 }) //=> true
3098
+ * @dataLast
3099
+ * @category Guard
3100
+ */
3101
+ declare function hasSubObject<T, S extends Partial<T>>(subObject: S): (data: T) => data is Simplify<S & T>;
3102
+
3103
+ /**
3104
+ * A function that checks if the passed parameter is an Array and narrows its type accordingly
3105
+ * @param data the variable to check
3106
+ * @signature
3107
+ * P.isArray(data)
3108
+ * @returns true if the passed input is an Array, false otherwise
3109
+ * @example
3110
+ * P.isArray([5]) //=> true
3111
+ * P.isArray([]) //=> true
3112
+ * P.isArray('somethingElse') //=> false
3113
+ * @category Guard
3114
+ */
3115
+ declare function isArray<T>(data: ArrayLike<unknown> | T): data is NarrowedTo<T, ReadonlyArray<unknown>>;
3116
+
3117
+ /**
3118
+ * A function that checks if the passed parameter is a boolean and narrows its type accordingly
3119
+ * @param data the variable to check
3120
+ * @signature
3121
+ * P.isBoolean(data)
3122
+ * @returns true if the passed input is a boolean, false otherwise
3123
+ * @example
3124
+ * P.isBoolean(true) //=> true
3125
+ * P.isBoolean(false) //=> true
3126
+ * P.isBoolean('somethingElse') //=> false
3127
+ * @category Guard
3128
+ */
3129
+ declare function isBoolean<T>(data: T | boolean): data is NarrowedTo<T, boolean>;
3130
+
3131
+ /**
3132
+ * A function that checks if the passed parameter is a Date and narrows its type accordingly
3133
+ * @param data the variable to check
3134
+ * @signature
3135
+ * P.isDate(data)
3136
+ * @returns true if the passed input is a Date, false otherwise
3137
+ * @example
3138
+ * P.isDate(new Date()) //=> true
3139
+ * P.isDate('somethingElse') //=> false
3140
+ * @category Guard
3141
+ */
3142
+ declare function isDate(data: unknown): data is Date;
3143
+
3144
+ /**
3145
+ * Performs a deep *semantic* comparison between two values to determine if they
3146
+ * are equivalent. For primitive values this is equivalent to `===`, for arrays
3147
+ * the check would be performed on every item recursively, in order, and for
3148
+ * objects all props will be compared recursively. The built-in Date and RegExp
3149
+ * are special-cased and will be compared by their values.
3150
+ *
3151
+ * !IMPORTANT: Maps, Sets and TypedArrays, and symbol properties of objects are
3152
+ * not supported right now and might result in unexpected behavior.
3153
+ *
3154
+ * The result would be narrowed to the second value so that the function can be
3155
+ * used as a type guard.
3156
+ *
3157
+ * @param data - The first value to compare.
3158
+ * @param other - The second value to compare.
3159
+ * @signature
3160
+ * P.isDeepEqual(data, other)
3161
+ * @example
3162
+ * P.isDeepEqual(1, 1) //=> true
3163
+ * P.isDeepEqual(1, '1') //=> false
3164
+ * P.isDeepEqual([1, 2, 3], [1, 2, 3]) //=> true
3165
+ * @dataFirst
3166
+ * @category Guard
3167
+ */
3168
+ declare function isDeepEqual<T, S extends T = T>(data: T, other: S): data is S;
3169
+ /**
3170
+ * Performs a deep *semantic* comparison between two values to determine if they
3171
+ * are equivalent. For primitive values this is equivalent to `===`, for arrays
3172
+ * the check would be performed on every item recursively, in order, and for
3173
+ * objects all props will be compared recursively. The built-in Date and RegExp
3174
+ * are special-cased and will be compared by their values.
3175
+ *
3176
+ * !IMPORTANT: Maps, Sets and TypedArrays, and symbol properties of objects are
3177
+ * not supported right now and might result in unexpected behavior.
3178
+ *
3179
+ * The result would be narrowed to the second value so that the function can be
3180
+ * used as a type guard.
3181
+ *
3182
+ * @param other - The second value to compare.
3183
+ * @signature
3184
+ * P.isDeepEqual(other)(data)
3185
+ * @example
3186
+ * P.pipe(1, P.isDeepEqual(1)); //=> true
3187
+ * P.pipe(1, P.isDeepEqual('1')); //=> false
3188
+ * P.pipe([1, 2, 3], P.isDeepEqual([1, 2, 3])); //=> true
3189
+ * @dataLast
3190
+ * @category Guard
3191
+ */
3192
+ declare function isDeepEqual<T, S extends T = T>(other: S): (data: T) => data is S;
3193
+
3194
+ /**
3195
+ * A function that checks if the passed parameter is defined and narrows its type accordingly.
3196
+ * To test specifically for `undefined` (and not `null`) use the strict variant of this function.
3197
+ * @param data the variable to check
3198
+ * @signature
3199
+ * P.isDefined(data)
3200
+ * P.isDefined.strict(data)
3201
+ * @returns true if the passed input is defined, false otherwise
3202
+ * @example
3203
+ * P.isDefined('string') //=> true
3204
+ * P.isDefined(null) //=> false
3205
+ * P.isDefined(undefined) //=> false
3206
+ * P.isDefined.strict(null) //=> true
3207
+ * P.isDefined.strict(undefined) //=> false
3208
+ * @category Guard
3209
+ * @strict
3210
+ */
3211
+ declare function isDefined<T>(data: T): data is NonNullable<T>;
3212
+ declare namespace isDefined {
3213
+ function strict<T>(data: T | undefined): data is T;
3214
+ }
3215
+
3216
+ /**
3217
+ * A function that checks if the passed parameter is empty.
3218
+ *
3219
+ * `undefined` is also considered empty, but only when it's in a union with a
3220
+ * `string` or string-like type.
3221
+ *
3222
+ * This guard doesn't work negated because of typescript limitations! If you
3223
+ * need to check that an array is *not* empty, use `P.hasAtLeast(data, 1)`
3224
+ * and not `!P.isEmpty(data)`. For strings and objects there's no way in
3225
+ * typescript to narrow the result to a non-empty type.
3226
+ *
3227
+ * @param data the variable to check
3228
+ * @signature
3229
+ * P.isEmpty(data)
3230
+ * @returns true if the passed input is empty, false otherwise
3231
+ * @example
3232
+ * P.isEmpty(undefined) //=>true
3233
+ * P.isEmpty('') //=> true
3234
+ * P.isEmpty([]) //=> true
3235
+ * P.isEmpty({}) //=> true
3236
+ * P.isEmpty('test') //=> false
3237
+ * P.isEmpty([1, 2, 3]) //=> false
3238
+ * P.isEmpty({ length: 0 }) //=> false
3239
+ * @category Guard
3240
+ */
3241
+ declare function isEmpty<T extends string | undefined>(data: T): data is ('' extends T ? '' : never) | (undefined extends T ? undefined : never);
3242
+ declare function isEmpty(data: IterableContainer): data is [];
3243
+ declare function isEmpty<T extends Readonly<Record<PropertyKey, unknown>>>(data: T): data is Record<keyof T, never>;
3244
+
3245
+ type DefinitelyError<T> = Extract<T, Error> extends never ? Error : Extract<T, Error>;
3246
+ /**
3247
+ * A function that checks if the passed parameter is an Error and narrows its type accordingly
3248
+ * @param data the variable to check
3249
+ * @signature
3250
+ * P.isError(data)
3251
+ * @returns true if the passed input is an Error, false otherwise
3252
+ * @example
3253
+ * P.isError(new Error('message')) //=> true
3254
+ * P.isError('somethingElse') //=> false
3255
+ * @category Guard
3256
+ */
3257
+ declare function isError<T>(data: Error | T): data is DefinitelyError<T>;
3258
+
3259
+ type DefinitelyFunction<T> = Extract<T, Function> extends never ? Function : Extract<T, Function>;
3260
+ /**
3261
+ * A function that checks if the passed parameter is a Function and narrows its type accordingly
3262
+ * @param data the variable to check
3263
+ * @signature
3264
+ * P.isFunction(data)
3265
+ * @returns true if the passed input is a Function, false otherwise
3266
+ * @example
3267
+ * P.isFunction(() => {}) //=> true
3268
+ * P.isFunction('somethingElse') //=> false
3269
+ * @category Guard
3270
+ */
3271
+ declare function isFunction<T>(data: Function | T): data is DefinitelyFunction<T>;
3272
+
3273
+ /**
3274
+ * Checks if the item is included in the container. This is a wrapper around
3275
+ * `Array.prototype.includes` and `Set.prototype.has` and thus relies on the
3276
+ * same equality checks that those functions do (which is reference equality,
3277
+ * e.g. `===`). The input's type is narrowed to the container's type if
3278
+ * possible.
3279
+ *
3280
+ * Notice that unlike most functions, this function takes a generic item as it's
3281
+ * data and **an array** as it's parameter.
3282
+ *
3283
+ * @param data - The item that is checked.
3284
+ * @param container - The items that are checked against.
3285
+ * @returns A narrowed version of the input data on success, `false` otherwise.
3286
+ * @signature
3287
+ * P.isIncludedIn(data, container);
3288
+ * @example
3289
+ * P.isIncludedIn(2, [1, 2, 3]); // => true
3290
+ * P.isIncludedIn(4, [1, 2, 3]); // => false
3291
+ *
3292
+ * const data = "cat" as "cat" | "dog" | "mouse";
3293
+ * P.isIncludedIn(data, ["cat", "dog"] as const); // true (typed "cat" | "dog");
3294
+ * @dataFirst
3295
+ * @category Guard
3296
+ */
3297
+ declare function isIncludedIn<T, S extends T>(data: T, container: IterableContainer<S>): data is S;
3298
+ /**
3299
+ * Checks if the item is included in the container. This is a wrapper around
3300
+ * `Array.prototype.includes` and `Set.prototype.has` and thus relies on the
3301
+ * same equality checks that those functions do (which is reference equality,
3302
+ * e.g. `===`). The input's type is narrowed to the container's type if
3303
+ * possible.
3304
+ *
3305
+ * Notice that unlike most functions, this function takes a generic item as it's
3306
+ * data and **an array** as it's parameter.
3307
+ *
3308
+ * @param container - The items that are checked against.
3309
+ * @returns A narrowed version of the input data on success, `false` otherwise.
3310
+ * @signature
3311
+ * P.isIncludedIn(container)(data);
3312
+ * @example
3313
+ * P.pipe(2, P.isIncludedIn([1, 2, 3])); // => true
3314
+ * P.pipe(4, P.isIncludedIn([1, 2, 3])); // => false
3315
+ *
3316
+ * const data = "cat" as "cat" | "dog" | "mouse";
3317
+ * P.pipe(
3318
+ * data,
3319
+ * P.isIncludedIn(["cat", "dog"] as const),
3320
+ * ); // => true (typed "cat" | "dog");
3321
+ * @dataLast
3322
+ * @category Guard
3323
+ */
3324
+ declare function isIncludedIn<T, S extends T>(container: IterableContainer<S>): (data: T) => data is S;
3325
+
3326
+ /**
3327
+ * A function that checks if the passed parameter is Nil (null or undefined) and narrows its type accordingly
3328
+ * @param data the variable to check
3329
+ * @signature
3330
+ * P.isNil(data)
3331
+ * @returns true if the passed input is Nil (null or undefined), false otherwise
3332
+ * @example
3333
+ * P.isNil(undefined) //=> true
3334
+ * P.isNil(null) //=> true
3335
+ * P.isNil('somethingElse') //=> false
3336
+ * @category Guard
3337
+ */
3338
+ declare function isNil<T>(data: T): data is Extract<T, null | undefined>;
3339
+
3340
+ /**
3341
+ * A function that checks if the passed parameter is not `null` and narrows its type accordingly.
3342
+ * Notice that `undefined` is not null!
3343
+ * @param data the variable to check
3344
+ * @signature
3345
+ * P.isNonNull(data)
3346
+ * @returns true if the passed input is defined, false otherwise
3347
+ * @example
3348
+ * P.isNonNull('string') //=> true
3349
+ * P.isNonNull(null) //=> false
3350
+ * P.isNonNull(undefined) //=> true
3351
+ * @category Guard
3352
+ */
3353
+ declare function isNonNull<T>(data: T | null): data is T;
3354
+
3355
+ /**
3356
+ * A function that takes a guard function as predicate and returns a guard that negates it
3357
+ * @param predicate the guard function to negate
3358
+ * @signature
3359
+ * P.isNot(P.isTruthy)(data)
3360
+ * @returns function A guard function
3361
+ * @example
3362
+ * P.isNot(P.isTruthy)(false) //=> true
3363
+ * P.isNot(P.isTruthy)(true) //=> false
3364
+ * @dataLast
3365
+ * @category Guard
3366
+ */
3367
+ declare function isNot<T, S extends T>(predicate: (data: T) => data is S): (data: T) => data is Exclude<T, S>;
3368
+ declare function isNot<T>(predicate: (data: T) => boolean): (data: T) => boolean;
3369
+
3370
+ /**
3371
+ * A function that checks if the passed parameter is a number and narrows its type accordingly
3372
+ * @param data the variable to check
3373
+ * @signature
3374
+ * P.isNumber(data)
3375
+ * @returns true if the passed input is a number, false otherwise
3376
+ * @example
3377
+ * P.isNumber(1) //=> true
3378
+ * P.isNumber('notANumber') //=> false
3379
+ * @category Guard
3380
+ */
3381
+ declare function isNumber<T>(data: T | number): data is NarrowedTo<T, number>;
3382
+
3383
+ /**
3384
+ * Checks if `data` is a "plain" object. A plain object is defined as an object with string keys and values of any type, including primitives, other objects, functions, classes, etc (aka struct/shape/record/simple). Technically, a plain object is one whose prototype is either `Object.prototype` or `null`, ensuring it does not inherit properties or methods from other object types.
3385
+ *
3386
+ * This function is narrower in scope than `isObjectType`, which accepts any entity considered an `"object"` by JavaScript's `typeof`.
3387
+ *
3388
+ * Note that Maps, Arrays, and Sets are not considered plain objects and would return `false`.
3389
+ *
3390
+ * @param data - The variable to check.
3391
+ * @returns - The input type, narrowed to only plain objects.
3392
+ * @signature
3393
+ * P.isObject(data)
3394
+ * @example
3395
+ * // true
3396
+ * P.isObject({}) //=> true
3397
+ * P.isObject({ a: 123 }) //=> true
3398
+ *
3399
+ * // false
3400
+ * P.isObject([]) //=> false
3401
+ * P.isObject(Promise.resolve("something")) //=> false
3402
+ * P.isObject(new Date()) //=> false
3403
+ * P.isObject(new Error("error")) //=> false
3404
+ * P.isObject('somethingElse') //=> false
3405
+ * P.isObject(null) //=> false
3406
+ * @category Guard
3407
+ */
3408
+ declare function isObject<T>(data: Readonly<Record<PropertyKey, unknown>> | T): data is NarrowedTo<T, Record<PropertyKey, unknown>>;
3409
+
3410
+ /**
3411
+ * A function that checks if the passed parameter is a Promise and narrows its type accordingly
3412
+ * @param data the variable to check
3413
+ * @signature
3414
+ * P.isPromise(data)
3415
+ * @returns true if the passed input is a Promise, false otherwise
3416
+ * @example
3417
+ * P.isPromise(Promise.resolve(5)) //=> true
3418
+ * P.isPromise(Promise.reject(5)) //=> true
3419
+ * P.isPromise('somethingElse') //=> false
3420
+ * @category Guard
3421
+ */
3422
+ declare function isPromise<T, S>(data: Promise<T> | S): data is Promise<T>;
3423
+
3424
+ /**
3425
+ * A function that checks if the passed parameter is a string and narrows its type accordingly
3426
+ * @param data the variable to check
3427
+ * @signature
3428
+ * P.isString(data)
3429
+ * @returns true if the passed input is a string, false otherwise
3430
+ * @example
3431
+ * P.isString('string') //=> true
3432
+ * P.isString(1) //=> false
3433
+ * @category Guard
3434
+ */
3435
+ declare function isString<T>(data: T | string): data is NarrowedTo<T, string>;
3436
+
3437
+ /**
3438
+ * A function that checks if the passed parameter is a symbol and narrows its type accordingly
3439
+ * @param data the variable to check
3440
+ * @signature
3441
+ * P.isSymbol(data)
3442
+ * @returns true if the passed input is a symbol, false otherwise
3443
+ * @example
3444
+ * P.isSymbol(Symbol('foo')) //=> true
3445
+ * P.isSymbol(1) //=> false
3446
+ * @category Guard
3447
+ */
3448
+ declare function isSymbol<T>(data: T | symbol): data is NarrowedTo<T, symbol>;
3449
+
3450
+ /**
3451
+ * A function that checks if the passed parameter is truthy and narrows its type accordingly
3452
+ * @param data the variable to check
3453
+ * @signature
3454
+ * P.isTruthy(data)
3455
+ * @returns true if the passed input is truthy, false otherwise
3456
+ * @example
3457
+ * P.isTruthy('somethingElse') //=> true
3458
+ * P.isTruthy(null) //=> false
3459
+ * P.isTruthy(undefined) //=> false
3460
+ * P.isTruthy(false) //=> false
3461
+ * P.isTruthy(0) //=> false
3462
+ * P.isTruthy('') //=> false
3463
+ * @category Guard
3464
+ */
3465
+ declare function isTruthy<T>(data: T): data is Exclude<T, '' | 0 | false | null | undefined>;
3466
+
3467
+ /**
3468
+ * Adds two numbers.
3469
+ * @param value The number.
3470
+ * @param addend The number to add to the value.
3471
+ * @signature
3472
+ * P.add(value, addend);
3473
+ * @example
3474
+ * P.add(10, 5) // => 15
3475
+ * P.add(10, -5) // => 5
3476
+ * P.reduce([1, 2, 3, 4], P.add, 0) // => 10
3477
+ * @dataFirst
3478
+ * @category Number
3479
+ */
3480
+ declare function add(value: number, addend: number): number;
3481
+ /**
3482
+ * Adds two numbers.
3483
+ * @param addend The number to add to the value.
3484
+ * @signature
3485
+ * P.add(addend)(value);
3486
+ * @example
3487
+ * P.add(5)(10) // => 15
3488
+ * P.add(-5)(10) // => 5
3489
+ * P.map([1, 2, 3, 4], P.add(1)) // => [2, 3, 4, 5]
3490
+ * @dataLast
3491
+ * @category Number
3492
+ */
3493
+ declare function add(addend: number): (value: number) => number;
3494
+
3495
+ /**
3496
+ * Rounds up a given number to a specific precision.
3497
+ * If you'd like to round up to an integer (i.e. use this function with constant `precision === 0`),
3498
+ * use `Math.ceil` instead, as it won't incur the additional library overhead.
3499
+ *
3500
+ * @param value The number to round up.
3501
+ * @param precision The precision to round up to. Must be an integer between -15 and 15.
3502
+ * @signature
3503
+ * P.ceil(value, precision);
3504
+ * @example
3505
+ * P.ceil(123.9876, 3) // => 123.988
3506
+ * P.ceil(483.22243, 1) // => 483.3
3507
+ * P.ceil(8541, -1) // => 8550
3508
+ * P.ceil(456789, -3) // => 457000
3509
+ * @dataFirst
3510
+ * @category Number
3511
+ */
3512
+ declare function ceil(value: number, precision: number): number;
3513
+ /**
3514
+ * Rounds up a given number to a specific precision.
3515
+ * If you'd like to round up to an integer (i.e. use this function with constant `precision === 0`),
3516
+ * use `Math.ceil` instead, as it won't incur the additional library overhead.
3517
+ *
3518
+ * @param precision The precision to round up to. Must be an integer between -15 and 15.
3519
+ * @signature
3520
+ * P.ceil(precision)(value);
3521
+ * @example
3522
+ * P.ceil(3)(123.9876) // => 123.988
3523
+ * P.ceil(1)(483.22243) // => 483.3
3524
+ * P.ceil(-1)(8541) // => 8550
3525
+ * P.ceil(-3)(456789) // => 457000
3526
+ * @dataLast
3527
+ * @category Number
3528
+ */
3529
+ declare function ceil(precision: number): (value: number) => number;
3530
+
3531
+ interface Limits {
3532
+ readonly max?: number;
3533
+ readonly min?: number;
3534
+ }
3535
+ /**
3536
+ * Clamp the given value within the inclusive min and max bounds.
3537
+ * @param value the number
3538
+ * @param limits the bounds limits
3539
+ * @param limits.min the minimal bounds limits
3540
+ * @param limits.max the maximal bounds limits
3541
+ * @signature
3542
+ * P.clamp(value, { min, max });
3543
+ * @example
3544
+ * P.clamp(10, { min: 20 }) // => 20
3545
+ * P.clamp(10, { max: 5 }) // => 5
3546
+ * P.clamp(10, { max: 20, min: 5 }) // => 10
3547
+ * @dataFirst
3548
+ * @category Number
3549
+ */
3550
+ declare function clamp(value: number, limits: Limits): number;
3551
+ /**
3552
+ * Clamp the given value within the inclusive min and max bounds.
3553
+ * @param limits the bounds limits
3554
+ * @param limits.min the minimal bounds limits
3555
+ * @param limits.max the maximal bounds limits
3556
+ * @signature
3557
+ * P.clamp({ min, max })(value);
3558
+ * @example
3559
+ * P.clamp({ min: 20 })(10) // => 20
3560
+ * P.clamp({ max: 5 })(10) // => 5
3561
+ * P.clamp({ max: 20, min: 5 })(10) // => 10
3562
+ * @dataLast
3563
+ * @category Number
3564
+ */
3565
+ declare function clamp(limits: Limits): (value: number) => number;
3566
+
3567
+ /**
3568
+ * Divides two numbers.
3569
+ * @param value The number.
3570
+ * @param divisor The number to divide the value by.
3571
+ * @signature
3572
+ * P.divide(value, divisor);
3573
+ * @example
3574
+ * P.divide(12, 3) // => 4
3575
+ * P.reduce([1, 2, 3, 4], P.divide, 24) // => 1
3576
+ * @dataFirst
3577
+ * @category Number
3578
+ */
3579
+ declare function divide(value: number, divisor: number): number;
3580
+ /**
3581
+ * Divides two numbers.
3582
+ * @param divisor The number to divide the value by.
3583
+ * @signature
3584
+ * P.divide(divisor)(value);
3585
+ * @example
3586
+ * P.divide(3)(12) // => 4
3587
+ * P.map([2, 4, 6, 8], P.divide(2)) // => [1, 2, 3, 4]
3588
+ * @dataLast
3589
+ * @category Number
3590
+ */
3591
+ declare function divide(divisor: number): (value: number) => number;
3592
+
3593
+ /**
3594
+ * Rounds down a given number to a specific precision.
3595
+ * If you'd like to round down to an integer (i.e. use this function with constant `precision === 0`),
3596
+ * use `Math.floor` instead, as it won't incur the additional library overhead.
3597
+ *
3598
+ * @param value The number to round down.
3599
+ * @param precision The precision to round down to. Must be an integer between -15 and 15.
3600
+ * @signature
3601
+ * P.floor(value, precision);
3602
+ * @example
3603
+ * P.floor(123.9876, 3) // => 123.987
3604
+ * P.floor(483.22243, 1) // => 483.2
3605
+ * P.floor(8541, -1) // => 8540
3606
+ * P.floor(456789, -3) // => 456000
3607
+ * @dataFirst
3608
+ * @category Number
3609
+ */
3610
+ declare function floor(value: number, precision: number): number;
3611
+ /**
3612
+ * Rounds down a given number to a specific precision.
3613
+ * If you'd like to round down to an integer (i.e. use this function with constant `precision === 0`),
3614
+ * use `Math.floor` instead, as it won't incur the additional library overhead.
3615
+ *
3616
+ * @param precision The precision to round down to. Must be an integer between -15 and 15.
3617
+ * @signature
3618
+ * P.floor(precision)(value);
3619
+ * @example
3620
+ * P.floor(3)(123.9876) // => 123.987
3621
+ * P.floor(1)(483.22243) // => 483.2
3622
+ * P.floor(-1)(8541) // => 8540
3623
+ * P.floor(-3)(456789) // => 456000
3624
+ * @dataLast
3625
+ * @category Number
3626
+ */
3627
+ declare function floor(precision: number): (value: number) => number;
3628
+
3629
+ /**
3630
+ * Multiplies two numbers.
3631
+ *
3632
+ * @param value The number.
3633
+ * @param multiplicand The number to multiply the value by.
3634
+ * @signature
3635
+ * P.multiply(value, multiplicand);
3636
+ * @example
3637
+ * P.multiply(3, 4) // => 12
3638
+ * P.reduce([1, 2, 3, 4], P.multiply, 1) // => 24
3639
+ * @dataFirst
3640
+ * @category Number
3641
+ */
3642
+ declare function multiply(value: number, multiplicand: number): number;
3643
+ /**
3644
+ * Multiplies two numbers.
3645
+ *
3646
+ * @param multiplicand The number to multiply the value by.
3647
+ * @signature
3648
+ * P.multiply(multiplicand)(value);
3649
+ * @example
3650
+ * P.multiply(4)(3) // => 12
3651
+ * P.map([1, 2, 3, 4], P.multiply(2)) // => [2, 4, 6, 8]
3652
+ * @dataLast
3653
+ * @category Number
3654
+ */
3655
+ declare function multiply(multiplicand: number): (value: number) => number;
3656
+
3657
+ /**
3658
+ * Rounds a given number to a specific precision.
3659
+ * If you'd like to round to an integer (i.e. use this function with constant `precision === 0`),
3660
+ * use `Math.round` instead, as it won't incur the additional library overhead.
3661
+ *
3662
+ * @param value The number to round.
3663
+ * @param precision The precision to round to. Must be an integer between -15 and 15.
3664
+ * @signature
3665
+ * P.round(value, precision);
3666
+ * @example
3667
+ * P.round(123.9876, 3) // => 123.988
3668
+ * P.round(483.22243, 1) // => 483.2
3669
+ * P.round(8541, -1) // => 8540
3670
+ * P.round(456789, -3) // => 457000
3671
+ * @dataFirst
3672
+ * @category Number
3673
+ */
3674
+ declare function round(value: number, precision: number): number;
3675
+ /**
3676
+ * Rounds a given number to a specific precision.
3677
+ * If you'd like to round to an integer (i.e. use this function with constant `precision === 0`),
3678
+ * use `Math.round` instead, as it won't incur the additional library overhead.
3679
+ *
3680
+ * @param precision The precision to round to. Must be an integer between -15 and 15.
3681
+ * @signature
3682
+ * P.round(precision)(value);
3683
+ * @example
3684
+ * P.round(3)(123.9876) // => 123.988
3685
+ * P.round(1)(483.22243) // => 483.2
3686
+ * P.round(-1)(8541) // => 8540
3687
+ * P.round(-3)(456789) // => 457000
3688
+ * @dataLast
3689
+ * @category Number
3690
+ */
3691
+ declare function round(precision: number): (value: number) => number;
3692
+
3693
+ /**
3694
+ * Subtracts two numbers.
3695
+ *
3696
+ * @param value The number.
3697
+ * @param subtrahend The number to subtract from the value.
3698
+ * @signature
3699
+ * P.subtract(value, subtrahend);
3700
+ * @example
3701
+ * P.subtract(10, 5) // => 5
3702
+ * P.subtract(10, -5) // => 15
3703
+ * R.reduce([1, 2, 3, 4], P.subtract, 20) // => 10
3704
+ * @dataFirst
3705
+ * @category Number
3706
+ */
3707
+ declare function subtract(value: number, subtrahend: number): number;
3708
+ /**
3709
+ * Subtracts two numbers.
3710
+ *
3711
+ * @param subtrahend The number to subtract from the value.
3712
+ * @signature
3713
+ * P.subtract(subtrahend)(value);
3714
+ * @example
3715
+ * P.subtract(5)(10) // => 5
3716
+ * P.subtract(-5)(10) // => 15
3717
+ * P.map([1, 2, 3, 4], P.subtract(1)) // => [0, 1, 2, 3]
3718
+ * @dataLast
3719
+ * @category Number
3720
+ */
3721
+ declare function subtract(subtrahend: number): (value: number) => number;
3722
+
3723
+ /**
3724
+ * Add a new property to an object.
3725
+ * @param obj the target object
3726
+ * @param prop the property name
3727
+ * @param value the property value
3728
+ * @signature
3729
+ * P.addProp(obj, prop, value)
3730
+ * @example
3731
+ * P.addProp({firstName: 'john'}, 'lastName', 'doe') // => {firstName: 'john', lastName: 'doe'}
3732
+ * @dataFirst
3733
+ * @category Object
3734
+ */
3735
+ declare function addProp<T extends Record<PropertyKey, unknown>, K extends string, V>(obj: T, prop: K, value: V): T & {
3736
+ [x in K]: V;
3737
+ };
3738
+ /**
3739
+ * Add a new property to an object.
3740
+ * @param prop the property name
3741
+ * @param value the property value
3742
+ * @signature
3743
+ * P.addProp(prop, value)(obj)
3744
+ * @example
3745
+ * P.addProp('lastName', 'doe')({firstName: 'john'}) // => {firstName: 'john', lastName: 'doe'}
3746
+ * @dataLast
3747
+ * @category Object
3748
+ */
3749
+ declare function addProp<T extends Record<PropertyKey, unknown>, K extends string, V>(prop: K, value: V): (obj: T) => T & {
3750
+ [x in K]: V;
3751
+ };
3752
+
3753
+ /**
3754
+ * Creates a deep copy of the value. Supported types: `Array`, `Object`, `Number`, `String`, `Boolean`, `Date`, `RegExp`. Functions are assigned by reference rather than copied.
3755
+ * @param value the object to clone
3756
+ * @category Object
3757
+ * @signature P.clone(value)
3758
+ * @example
3759
+ * P.clone({foo: 'bar'}) // {foo: 'bar'}
3760
+ */
3761
+ declare function clone<T>(value: T): T;
3762
+
3763
+ type IndexedIteratee<T extends Record<PropertyKey, unknown>, K extends keyof T> = (value: T[K], key: K, obj: T) => void;
3764
+ type UnindexedIteratee<T extends Record<PropertyKey, unknown>> = (value: T[keyof T]) => void;
3765
+ /**
3766
+ * Iterate an object using a defined callback function. The original object is returned.
3767
+ * @param object The object.
3768
+ * @param fn The callback function.
3769
+ * @returns The original object
3770
+ * @signature
3771
+ * P.forEachObj(object, fn)
3772
+ * @example
3773
+ * P.forEachObj({a: 1}, (val) => {
3774
+ * console.log(`${val}`)
3775
+ * }) // "1"
3776
+ * P.forEachObj.indexed({a: 1}, (val, key, obj) => {
3777
+ * console.log(`${key}: ${val}`)
3778
+ * }) // "a: 1"
3779
+ * @dataFirst
3780
+ * @category Object
3781
+ */
3782
+ declare function forEachObj<T extends Record<PropertyKey, unknown>>(object: T, fn: UnindexedIteratee<T>): T;
3783
+ /**
3784
+ * Iterate an object using a defined callback function. The original object is returned.
3785
+ * @param fn The callback function.
3786
+ * @signature
3787
+ * P.forEachObj(fn)(object)
3788
+ * @example
3789
+ * P.pipe(
3790
+ * {a: 1},
3791
+ * P.forEachObj((val) => console.log(`${val}`))
3792
+ * ) // "1"
3793
+ * P.pipe(
3794
+ * {a: 1},
3795
+ * P.forEachObj.indexed((val, key) => console.log(`${key}: ${val}`))
3796
+ * ) // "a: 1"
3797
+ * @dataLast
3798
+ * @category Object
3799
+ */
3800
+ declare function forEachObj<T extends Record<PropertyKey, unknown>>(fn: UnindexedIteratee<T>): (object: T) => T;
3801
+ declare namespace forEachObj {
3802
+ function indexed<T extends Record<PropertyKey, unknown>>(object: T, fn: IndexedIteratee<T, keyof T>): T;
3803
+ function indexed<T extends Record<PropertyKey, unknown>>(fn: IndexedIteratee<T, keyof T>): (object: T) => T;
3804
+ }
3805
+
3806
+ type ExactlyOneKey<T, V> = T extends PropertyKey ? {
3807
+ [P in T]: V;
3808
+ } : never;
3809
+ type FromKeys<T extends IterableContainer, V> = T extends readonly [] ? {} : T extends readonly [infer Head, ...infer Rest] ? ExactlyOneKey<Head, V> & FromKeys<Rest, V> : T[number] extends PropertyKey ? Partial<Record<T[number], V>> : never;
3810
+ /**
3811
+ * Creates an object that maps each key in `data` to the result of `mapper` for
3812
+ * that key. Duplicate keys are overwritten, guaranteeing that `mapper` is run
3813
+ * for each item in `data`.
3814
+ *
3815
+ * @param data - An array of keys of the output object. All items in the array
3816
+ * would be keys in the output array.
3817
+ * @param mapper - Takes a key and returns the value that would be associated
3818
+ * with that key.
3819
+ * @signature
3820
+ * P.fromKeys(data, mapper);
3821
+ * @example
3822
+ * P.fromKeys(["cat", "dog"], P.length()); // { cat: 3, dog: 3 } (typed as Partial<Record<"cat" | "dog", number>>)
3823
+ * P.fromKeys([1, 2], P.add(1)); // { 1: 2, 2: 3 } (typed as Partial<Record<1 | 2, number>>)
3824
+ * @dataFirst
3825
+ * @category Object
3826
+ */
3827
+ declare function fromKeys<T extends IterableContainer<PropertyKey>, V>(data: T, mapper: (item: T[number]) => V): Simplify<FromKeys<T, V>>;
3828
+ /**
3829
+ * Creates an object that maps each key in `data` to the result of `mapper` for
3830
+ * that key. Duplicate keys are overwritten, guaranteeing that `mapper` is run
3831
+ * for each item in `data`.
3832
+ *
3833
+ * @param mapper - Takes a key and returns the value that would be associated
3834
+ * with that key.
3835
+ * @signature
3836
+ * P.fromKeys(mapper)(data);
3837
+ * @example
3838
+ * P.pipe(["cat", "dog"], P.fromKeys(P.length())); // { cat: 3, dog: 3 } (typed as Partial<Record<"cat" | "dog", number>>)
3839
+ * P.pipe([1, 2], P.fromKeys(P.add(1))); // { 1: 2, 2: 3 } (typed as Partial<Record<1 | 2, number>>)
3840
+ * @dataLast
3841
+ * @category Object
3842
+ */
3843
+ declare function fromKeys<T extends IterableContainer<PropertyKey>, V>(mapper: (item: T[number]) => V): (data: T) => Simplify<FromKeys<T, V>>;
3844
+
3845
+ type Entry<Key extends PropertyKey = PropertyKey, Value = unknown> = readonly [
3846
+ key: Key,
3847
+ value: Value
3848
+ ];
3849
+ type Strict$2 = <Entries extends IterableContainer<Entry>>(entries: Entries) => StrictOut<Entries>;
3850
+ type StrictOut<Entries> = Entries extends readonly [infer First, ...infer Tail] ? FromPairsTuple<First, Tail> : Entries extends readonly [...infer Head, infer Last] ? FromPairsTuple<Last, Head> : Entries extends IterableContainer<Entry> ? FromPairsArray<Entries> : 'ERROR: Entries array-like could not be infered';
3851
+ type FromPairsTuple<E, Rest> = E extends Entry ? Record<E[0], E[1]> & StrictOut<Rest> : 'ERROR: Array-like contains a non-entry element';
3852
+ type FromPairsArray<Entries extends IterableContainer<Entry>> = string extends AllKeys$1<Entries> ? Record<string, Entries[number][1]> : number extends AllKeys$1<Entries> ? Record<number, Entries[number][1]> : symbol extends AllKeys$1<Entries> ? Record<symbol, Entries[number][1]> : FromPairsArrayWithLiteralKeys<Entries>;
3853
+ type FromPairsArrayWithLiteralKeys<Entries extends IterableContainer<Entry>> = {
3854
+ [K in AllKeys$1<Entries>]?: ValueForKey<Entries, K>;
3855
+ };
3856
+ type AllKeys$1<Entries extends IterableContainer<Entry>> = Extract<Entries[number], Entry>[0];
3857
+ type ValueForKey<Entries extends IterableContainer<Entry>, K extends PropertyKey> = (Extract<Entries[number], Entry<K>> extends never ? Entries[number] : Extract<Entries[number], Entry<K>>)[1];
3858
+ /**
3859
+ * Creates a new object from an array of tuples by pairing up first and second elements as `{[key]: value}`.
3860
+ * If a tuple is not supplied for any element in the array, the element will be ignored
3861
+ * If duplicate keys exist, the tuple with the greatest index in the input array will be preferred.
3862
+ *
3863
+ * The strict option supports more sophisticated use-cases like those that would
3864
+ * result when calling the strict `toPairs` function.
3865
+ * @param pairs the list of input tuples
3866
+ * @signature
3867
+ * P.fromPairs(tuples)
3868
+ * P.fromPairs.strict(tuples)
3869
+ * @example
3870
+ * P.fromPairs([['a', 'b'], ['c', 'd']]) // => {a: 'b', c: 'd'} (type: Record<string, string>)
3871
+ * P.fromPairs.strict(['a', 1] as const) // => {a: 1} (type: {a: 1})
3872
+ * P.pipe(
3873
+ * [['a', 'b'], ['c', 'd']],
3874
+ * P.fromPairs,
3875
+ * ); // => {a: 'b', c: 'd'} (type: Record<string, string>)
3876
+ * P.pipe(
3877
+ * ['a', 1] as const,
3878
+ * P.fromPairs.strict,
3879
+ * ); // => {a: 1} (type: {a: 1})
3880
+ * @category Object
3881
+ * @strict
3882
+ * @dataFirst
3883
+ */
3884
+ declare function fromPairs<V>(pairs: ReadonlyArray<Entry<number, V>>): Record<number, V>;
3885
+ declare function fromPairs<V>(pairs: ReadonlyArray<Entry<string, V>>): Record<string, V>;
3886
+ declare namespace fromPairs {
3887
+ const strict: Strict$2;
3888
+ }
3889
+
3890
+ type Inverted<T extends object> = T[keyof T] extends PropertyKey ? Record<T[keyof T], keyof T> : never;
3891
+ /**
3892
+ * Returns an object whose keys are values are swapped. If the object contains duplicate values,
3893
+ * subsequent values will overwrite previous values.
3894
+ *
3895
+ * @param object the object
3896
+ * @signature
3897
+ * P.invert(object)
3898
+ * @example
3899
+ * P.invert({ a: "d", b: "e", c: "f" }) // => { d: "a", e: "b", f: "c" }
3900
+ * @dataFirst
3901
+ * @category Object
3902
+ * @pipeable
3903
+ */
3904
+ declare function invert<T extends object>(object: T): Inverted<T>;
3905
+ /**
3906
+ * Returns an object whose keys are values are swapped. If the object contains duplicate values,
3907
+ * subsequent values will overwrite previous values.
3908
+ *
3909
+ * @signature
3910
+ * P.invert()(object)
3911
+ * @example
3912
+ * P.pipe({ a: "d", b: "e", c: "f" }, P.invert()); // => { d: "a", e: "b", f: "c" }
3913
+ * @dataLast
3914
+ * @category Object
3915
+ * @pipeable
3916
+ */
3917
+ declare function invert<T extends object>(): (object: T) => Inverted<T>;
3918
+
3919
+ type Strict$1 = <T extends object>(data: T) => Keys<T>;
3920
+ type Keys<T> = T extends IterableContainer ? ArrayKeys<T> : ObjectKeys<T>;
3921
+ type ArrayKeys<T extends IterableContainer> = {
3922
+ -readonly [Index in keyof T]: Index extends number | string ? `${IsIndexAfterSpread<T, Index> extends true ? number : Index}` : never;
3923
+ };
3924
+ type IsIndexAfterSpread<T extends IterableContainer, Index extends number | string> = IndicesAfterSpread<T> extends never ? false : Index extends `${IndicesAfterSpread<T>}` ? true : false;
3925
+ type IndicesAfterSpread<T extends [] | ReadonlyArray<unknown>, Iterations extends ReadonlyArray<unknown> = []> = T[number] extends never ? never : T extends readonly [unknown, ...infer Tail] ? IndicesAfterSpread<Tail, [unknown, ...Iterations]> : T extends readonly [...infer Head, unknown] ? IndicesAfterSpread<Head, [unknown, ...Iterations]> | Iterations['length'] : Iterations['length'];
3926
+ type ObjectKeys<T> = T extends Record<PropertyKey, never> ? [] : Array<`${Exclude<keyof T, symbol>}`>;
3927
+ /**
3928
+ * Returns a new array containing the keys of the array or object.
3929
+ *
3930
+ * @param source Either an array or an object
3931
+ * @signature
3932
+ * P.keys(source)
3933
+ * P.keys.strict(source)
3934
+ * @example
3935
+ * P.keys(['x', 'y', 'z']) // => ['0', '1', '2']
3936
+ * P.keys({ a: 'x', b: 'y', c: 'z' }) // => ['a', 'b', 'c']
3937
+ * P.keys.strict({ a: 'x', b: 'y', 5: 'z' } as const ) // => ['a', 'b', '5'], typed Array<'a' | 'b' | '5'>
3938
+ * P.pipe(['x', 'y', 'z'], P.keys) // => ['0', '1', '2']
3939
+ * P.pipe({ a: 'x', b: 'y', c: 'z' }, P.keys) // => ['a', 'b', 'c']
3940
+ * P.pipe(
3941
+ * { a: 'x', b: 'y', c: 'z' },
3942
+ * P.keys,
3943
+ * P.first(),
3944
+ * ) // => 'a'
3945
+ * P.pipe({ a: 'x', b: 'y', 5: 'z' } as const, P.keys.strict) // => ['a', 'b', '5'], typed Array<'a' | 'b' | '5'>
3946
+ * @pipeable
3947
+ * @strict
3948
+ * @category Object
3949
+ * @dataFirst
3950
+ */
3951
+ declare function keys(source: ArrayLike<unknown> | Readonly<Record<PropertyKey, unknown>>): Array<string>;
3952
+ declare namespace keys {
3953
+ const strict: Strict$1;
3954
+ }
3955
+
3956
+ /**
3957
+ * Maps keys of `object` and keeps the same values.
3958
+ * @param data the object to map
3959
+ * @param fn the mapping function
3960
+ * @signature
3961
+ * P.mapKeys(object, fn)
3962
+ * @example
3963
+ * P.mapKeys({a: 1, b: 2}, (key, value) => key + value) // => { a1: 1, b2: 2 }
3964
+ * @dataFirst
3965
+ * @category Object
3966
+ */
3967
+ declare function mapKeys<T, S extends PropertyKey>(data: T, fn: (key: keyof T, value: Required<T>[keyof T]) => S): Record<S, T[keyof T]>;
3968
+ /**
3969
+ * Maps keys of `object` and keeps the same values.
3970
+ * @param fn the mapping function
3971
+ * @signature
3972
+ * P.mapKeys(fn)(object)
3973
+ * @example
3974
+ * P.pipe({a: 1, b: 2}, P.mapKeys((key, value) => key + value)) // => { a1: 1, b2: 2 }
3975
+ * @dataLast
3976
+ * @category Object
3977
+ */
3978
+ declare function mapKeys<T, S extends PropertyKey>(fn: (key: keyof T, value: Required<T>[keyof T]) => S): (data: T) => Record<S, T[keyof T]>;
3979
+
3980
+ /**
3981
+ * Maps values of `object` and keeps the same keys.
3982
+ * @param data the object to map
3983
+ * @param fn the mapping function
3984
+ * @signature
3985
+ * P.mapValues(object, fn)
3986
+ * @example
3987
+ * P.mapValues({a: 1, b: 2}, (value, key) => value + key) // => {a: '1a', b: '2b'}
3988
+ * @dataFirst
3989
+ * @category Object
3990
+ */
3991
+ declare function mapValues<T extends Record<PropertyKey, unknown>, S>(data: T, fn: (value: T[ObjectKeys$1<T>], key: ObjectKeys$1<T>) => S): Record<ObjectKeys$1<T>, S>;
3992
+ /**
3993
+ * Maps values of `object` and keeps the same keys.
3994
+ * @param fn the mapping function
3995
+ * @signature
3996
+ * P.mapValues(fn)(object)
3997
+ * @example
3998
+ * P.pipe({a: 1, b: 2}, P.mapValues((value, key) => value + key)) // => {a: '1a', b: '2b'}
3999
+ * @dataLast
4000
+ * @category Object
4001
+ */
4002
+ declare function mapValues<T extends Record<PropertyKey, unknown>, S>(fn: (value: T[keyof T], key: keyof T) => S): (data: T) => Record<ObjectKeys$1<T>, S>;
4003
+
4004
+ /**
4005
+ * Merges two objects into one by combining their properties, effectively
4006
+ * creating a new object that incorporates elements from both. The merge
4007
+ * operation prioritizes the second object's properties, allowing them to
4008
+ * overwrite those from the first object with the same names.
4009
+ *
4010
+ * Equivalent to `{ ...data, ...source }`.
4011
+ *
4012
+ * @param data - The destination object, serving as the basis for the merge.
4013
+ * Properties from this object are included in the new object, but will be
4014
+ * overwritten by properties from the source object with matching keys.
4015
+ * @param source - The source object, whose properties will be included in the
4016
+ * new object. If properties in this object share keys with properties in the
4017
+ * destination object, the values from the source object will be used in the
4018
+ * new object.
4019
+ * @returns An object fully containing `source`, and any properties from `data`
4020
+ * that don't share a name with any property in `source`.
4021
+ * @signature
4022
+ * R.merge(data, source)
4023
+ * @example
4024
+ * R.merge({ x: 1, y: 2 }, { y: 10, z: 2 }) // => { x: 1, y: 10, z: 2 }
4025
+ * @dataFirst
4026
+ * @category Object
4027
+ */
4028
+ declare function merge<T, Source>(data: T, source: Source): Merge<T, Source>;
4029
+ /**
4030
+ * Merges two objects into one by combining their properties, effectively
4031
+ * creating a new object that incorporates elements from both. The merge
4032
+ * operation prioritizes the second object's properties, allowing them to
4033
+ * overwrite those from the first object with the same names.
4034
+ *
4035
+ * Equivalent to `{ ...data, ...source }`.
4036
+ *
4037
+ * @param source - The source object, whose properties will be included in the
4038
+ * new object. If properties in this object share keys with properties in the
4039
+ * destination object, the values from the source object will be used in the
4040
+ * new object.
4041
+ * @returns An object fully containing `source`, and any properties from `data`
4042
+ * that don't share a name with any property in `source`.
4043
+ * @signature
4044
+ * R.merge(source)(data)
4045
+ * @example
4046
+ * R.pipe(
4047
+ * { x: 1, y: 2 },
4048
+ * R.merge({ y: 10, z: 2 }),
4049
+ * ); // => { x: 1, y: 10, z: 2 }
4050
+ * @dataLast
4051
+ * @category Object
4052
+ */
4053
+ declare function merge<Source>(source: Source): <T>(data: T) => Merge<T, Source>;
4054
+
4055
+ /**
4056
+ * Merges the `source` object into the `destination` object. The merge is similar to performing `{ ...destination, ... source }` (where disjoint values from each object would be copied as-is, and for any overlapping props the value from `source` would be used); But for *each prop* (`p`), if **both** `destination` and `source` have a **plain-object** as a value, the value would be taken as the result of recursively deepMerging them (`result.p === deepMerge(destination.p, source.p)`).
4057
+ *
4058
+ * @param destination - The object to merge into. In general, this object would have it's values overridden.
4059
+ * @param source - The object to merge from. In general, shared keys would be taken from this object.
4060
+ * @returns - The merged object.
4061
+ * @signature
4062
+ * P.mergeDeep(destination, source)
4063
+ * @example
4064
+ * P.mergeDeep({ foo: 'bar', x: 1 }, { foo: 'baz', y: 2 }) // => { foo: 'baz', x: 1, y: 2 }
4065
+ * @dataFirst
4066
+ * @category Object
4067
+ */
4068
+ declare function mergeDeep<Destination extends Record<string, unknown>, Source extends Record<string, unknown>>(destination: Destination, source: Source): MergeDeep<Destination, Source>;
4069
+ /**
4070
+ * Merges the `source` object into the `destination` object. The merge is similar to performing `{ ...destination, ... source }` (where disjoint values from each object would be copied as-is, and for any overlapping props the value from `source` would be used); But for *each prop* (`p`), if **both** `destination` and `source` have a **plain-object** as a value, the value would be taken as the result of recursively deepMerging them (`result.p === deepMerge(destination.p, source.p)`).
4071
+ *
4072
+ * @param source - The object to merge from. In general, shared keys would be taken from this object.
4073
+ * @returns - The merged object.
4074
+ * @signature
4075
+ * P.mergeDeep(source)(destination)
4076
+ * @example
4077
+ * P.pipe(
4078
+ * { foo: 'bar', x: 1 },
4079
+ * P.mergeDeep({ foo: 'baz', y: 2 }),
4080
+ * ); // => { foo: 'baz', x: 1, y: 2 }
4081
+ * @dataLast
4082
+ * @category Object
4083
+ */
4084
+ declare function mergeDeep<Destination extends Record<string, unknown>, Source extends Record<string, unknown>>(source: Source): (target: Destination) => MergeDeep<Destination, Source>;
4085
+
4086
+ /**
4087
+ * Returns a partial copy of an object omitting the keys specified.
4088
+ * @param propNames the property names
4089
+ * @signature
4090
+ * P.omit(propNames)(obj);
4091
+ * @example
4092
+ * P.pipe({ a: 1, b: 2, c: 3, d: 4 }, P.omit(['a', 'd'])) // => { b: 2, c: 3 }
4093
+ * @dataLast
4094
+ * @category Object
4095
+ */
4096
+ declare function omit<T extends object, K extends keyof T>(propNames: ReadonlyArray<K>): (data: T) => Omit<T, K>;
4097
+ /**
4098
+ * Returns a partial copy of an object omitting the keys specified.
4099
+ * @param data the object
4100
+ * @param propNames the property names
4101
+ * @signature
4102
+ * P.omit(obj, names);
4103
+ * @example
4104
+ * P.omit({ a: 1, b: 2, c: 3, d: 4 }, ['a', 'd']) // => { b: 2, c: 3 }
4105
+ * @dataFirst
4106
+ * @category Object
4107
+ */
4108
+ declare function omit<T extends object, K extends keyof T>(data: T, propNames: ReadonlyArray<K>): Omit<T, K>;
4109
+
4110
+ /**
4111
+ * Returns a partial copy of an object omitting the keys matching predicate.
4112
+ * @param object the target object
4113
+ * @param fn the predicate
4114
+ * @signature P.omitBy(object, fn)
4115
+ * @example
4116
+ * P.omitBy({a: 1, b: 2, A: 3, B: 4}, (val, key) => key.toUpperCase() === key) // => {a: 1, b: 2}
4117
+ * @dataFirst
4118
+ * @category Object
4119
+ */
4120
+ declare function omitBy<T>(object: T, fn: <K extends keyof T>(value: T[K], key: K) => boolean): T extends Record<keyof T, T[keyof T]> ? T : Partial<T>;
4121
+ /**
4122
+ * Returns a partial copy of an object omitting the keys matching predicate.
4123
+ * @param fn the predicate
4124
+ * @signature P.omitBy(fn)(object)
4125
+ * @example
4126
+ * P.omitBy((val, key) => key.toUpperCase() === key)({a: 1, b: 2, A: 3, B: 4}) // => {a: 1, b: 2}
4127
+ * @dataLast
4128
+ * @category Object
4129
+ */
4130
+ declare function omitBy<T>(fn: <K extends keyof T>(value: T[K], key: K) => boolean): (object: T) => T extends Record<keyof T, T[keyof T]> ? T : Partial<T>;
4131
+
4132
+ /**
4133
+ * Given a union of indexable types `T`, we derive an indexable type
4134
+ * containing all of the keys of each variant of `T`. If a key is
4135
+ * present in multiple variants of `T`, then the corresponding type in
4136
+ * `Pathable<T>` will be the intersection of all types for that key.
4137
+ * @example
4138
+ * type T1 = Pathable<{a: number} | {a: string; b: boolean}>
4139
+ * // {a: number | string; b: boolean}
4140
+ *
4141
+ * type T2 = Pathable<{a?: {b: string}}
4142
+ * // {a: {b: string} | undefined}
4143
+ *
4144
+ * type T3 = Pathable<{a: string} | number>
4145
+ * // {a: string}
4146
+ *
4147
+ * type T4 = Pathable<{a: number} | {a: string} | {b: boolean}>
4148
+ * // {a: number | string; b: boolean}
4149
+ *
4150
+ * This type lets us answer the questions:
4151
+ * - Given some object of type `T`, what keys might this object have?
4152
+ * - If this object did happen to have a particular key, what values
4153
+ * might that key have?
4154
+ */
4155
+ type Pathable<T> = {
4156
+ [K in AllKeys<T>]: TypesForKey<T, K>;
4157
+ };
4158
+ type AllKeys<T> = T extends infer I ? keyof I : never;
4159
+ type TypesForKey<T, K extends PropertyKey> = T extends infer I ? K extends keyof I ? I[K] : never : never;
4160
+ type StrictlyRequired<T> = {
4161
+ [K in keyof T]-?: NonNullable<T[K]>;
4162
+ };
4163
+ /**
4164
+ * Given some `A` which is a key of at least one variant of `T`, derive
4165
+ * `T[A]` for the cases where `A` is present in `T`, and `T[A]` is not
4166
+ * null or undefined.
4167
+ */
4168
+ type PathValue1<T, A extends keyof Pathable<T>> = StrictlyRequired<Pathable<T>>[A];
4169
+ /** All possible options after successfully reaching `T[A]` */
4170
+ type Pathable1<T, A extends keyof Pathable<T>> = Pathable<PathValue1<T, A>>;
4171
+ /** As `PathValue1`, but for `T[A][B]` */
4172
+ type PathValue2<T, A extends keyof Pathable<T>, B extends keyof Pathable1<T, A>> = StrictlyRequired<Pathable1<T, A>>[B];
4173
+ /** As `Pathable1`, but for `T[A][B]` */
4174
+ type Pathable2<T, A extends keyof Pathable<T>, B extends keyof Pathable1<T, A>> = Pathable<PathValue2<T, A, B>>;
4175
+ /** As `PathValue1`, but for `T[A][B][C]` */
4176
+ type PathValue3<T, A extends keyof Pathable<T>, B extends keyof Pathable1<T, A>, C extends keyof Pathable2<T, A, B>> = StrictlyRequired<Pathable2<T, A, B>>[C];
4177
+ /**
4178
+ * Gets the value at `path` of `object`. If the resolved value is `undefined`, the `defaultValue` is returned in its place.
4179
+ *
4180
+ * @param object the target object
4181
+ * @param path the path of the property to get
4182
+ * @param defaultValue the default value
4183
+ * @signature P.pathOr(object, array, defaultValue)
4184
+ * @example
4185
+ * P.pathOr({x: 10}, ['y'], 2) // 2
4186
+ * P.pathOr({y: 10}, ['y'], 2) // 10
4187
+ * @dataFirst
4188
+ * @category Object
4189
+ */
4190
+ declare function pathOr<T, A extends keyof Pathable<T>>(object: T, path: readonly [A], defaultValue: PathValue1<T, A>): PathValue1<T, A>;
4191
+ declare function pathOr<T, A extends keyof Pathable<T>, B extends keyof Pathable1<T, A>>(object: T, path: readonly [A, B], defaultValue: PathValue2<T, A, B>): PathValue2<T, A, B>;
4192
+ declare function pathOr<T, A extends keyof Pathable<T>, B extends keyof Pathable1<T, A>, C extends keyof Pathable2<T, A, B>>(object: T, path: readonly [A, B, C], defaultValue: PathValue3<T, A, B, C>): PathValue3<T, A, B, C>;
4193
+ /**
4194
+ * Gets the value at `path` of `object`. If the resolved value is `undefined`, the `defaultValue` is returned in its place.
4195
+ *
4196
+ * @param path the path of the property to get
4197
+ * @param defaultValue the default value
4198
+ * @signature P.pathOr(array, defaultValue)(object)
4199
+ * @example
4200
+ * P.pipe({x: 10}, P.pathOr(['y'], 2)) // 2
4201
+ * P.pipe({y: 10}, P.pathOr(['y'], 2)) // 10
4202
+ * @dataLast
4203
+ * @category Object
4204
+ */
4205
+ declare function pathOr<T, A extends keyof Pathable<T>>(path: readonly [A], defaultValue: PathValue1<T, A>): (object: T) => PathValue1<T, A>;
4206
+ declare function pathOr<T, A extends keyof Pathable<T>, B extends keyof Pathable1<T, A>>(path: readonly [A, B], defaultValue: PathValue2<T, A, B>): (object: T) => PathValue2<T, A, B>;
4207
+ declare function pathOr<T, A extends keyof Pathable<T>, B extends keyof Pathable1<T, A>, C extends keyof Pathable2<T, A, B>>(path: readonly [A, B, C], defaultValue: PathValue3<T, A, B, C>): (object: T) => PathValue3<T, A, B, C>;
4208
+
4209
+ /**
4210
+ * Creates an object composed of the picked `object` properties.
4211
+ * @param names the properties names
4212
+ * @signature P.pick([prop1, prop2])(object)
4213
+ * @example
4214
+ * P.pipe({ a: 1, b: 2, c: 3, d: 4 }, P.pick(['a', 'd'])) // => { a: 1, d: 4 }
4215
+ * @dataLast
4216
+ * @category Object
4217
+ */
4218
+ declare function pick<T extends object, K extends keyof T>(names: ReadonlyArray<K>): (object: T) => Pick<T, K>;
4219
+ /**
4220
+ * Creates an object composed of the picked `object` properties.
4221
+ * @param object the target object
4222
+ * @param names the properties names
4223
+ * @signature P.pick(object, [prop1, prop2])
4224
+ * @example
4225
+ * P.pick({ a: 1, b: 2, c: 3, d: 4 }, ['a', 'd']) // => { a: 1, d: 4 }
4226
+ * @dataFirst
4227
+ * @category Object
4228
+ */
4229
+ declare function pick<T extends object, K extends keyof T>(object: T, names: ReadonlyArray<K>): Pick<T, K>;
4230
+
4231
+ /**
4232
+ * Creates an object composed of the picked `object` properties.
4233
+ *
4234
+ * @param object the target object
4235
+ * @param fn the predicate
4236
+ * @signature P.pickBy(object, fn)
4237
+ * @example
4238
+ * P.pickBy({a: 1, b: 2, A: 3, B: 4}, (val, key) => key.toUpperCase() === key) // => {A: 3, B: 4}
4239
+ * @dataFirst
4240
+ * @category Object
4241
+ */
4242
+ declare function pickBy<T>(object: T, fn: <K extends keyof T>(value: T[K], key: K) => boolean): T extends Record<keyof T, T[keyof T]> ? T : Partial<T>;
4243
+ /**
4244
+ * Creates an object composed of the picked `object` properties.
4245
+ *
4246
+ * @param fn the predicate
4247
+ * @signature P.pickBy(fn)(object)
4248
+ * @example
4249
+ * P.pickBy((val, key) => key.toUpperCase() === key)({a: 1, b: 2, A: 3, B: 4}) // => {A: 3, B: 4}
4250
+ * @dataLast
4251
+ * @category Object
4252
+ */
4253
+ declare function pickBy<T>(fn: <K extends keyof T>(value: T[K], key: K) => boolean): (object: T) => T extends Record<keyof T, T[keyof T]> ? T : Partial<T>;
4254
+
4255
+ /**
4256
+ * Gets the value of the given property.
4257
+ * @param propName the property name
4258
+ * @signature P.prop(prop)(object)
4259
+ * @example
4260
+ * P.pipe({foo: 'bar'}, P.prop('foo')) // => 'bar'
4261
+ * @dataLast
4262
+ * @category Object
4263
+ */
4264
+ declare function prop<T, K extends keyof T>(propName: K): ({ [propName]: value }: T) => T[K];
4265
+
4266
+ /**
4267
+ * Sets the `value` at `prop` of `object`.
4268
+ * @param obj the target method
4269
+ * @param prop the property name
4270
+ * @param value the value to set
4271
+ * @signature
4272
+ * P.set(obj, prop, value)
4273
+ * @example
4274
+ * P.set({ a: 1 }, 'a', 2) // => { a: 2 }
4275
+ * @dataFirst
4276
+ * @category Object
4277
+ */
4278
+ declare function set<T, K extends keyof T>(obj: T, prop: K, value: T[K]): T;
4279
+ /**
4280
+ * Sets the `value` at `prop` of `object`.
4281
+ * @param prop the property name
4282
+ * @param value the value to set
4283
+ * @signature
4284
+ * P.set(prop, value)(obj)
4285
+ * @example
4286
+ * P.pipe({ a: 1 }, P.set('a', 2)) // => { a: 2 }
4287
+ * @dataLast
4288
+ * @category Object
4289
+ */
4290
+ declare function set<T, K extends keyof T>(prop: K, value: T[K]): (obj: T) => T;
4291
+
4292
+ /**
4293
+ * Copied from ts-toolbelt
4294
+ * https://github.com/millsp/ts-toolbelt/blob/master/sources/Function/Narrow.ts
4295
+ */
4296
+ /**
4297
+ * Similar to [[Cast]] but with a custom fallback `Catch`. If it fails,
4298
+ * it will enforce `Catch` instead of `A2`.
4299
+ * @param A1 to check against
4300
+ * @param A2 to try/test with
4301
+ * @param Catch to fallback to if the test failed
4302
+ * @returns `A1 | Catch`
4303
+ * @example
4304
+ * ```ts
4305
+ * import {A} from 'ts-toolbelt'
4306
+ *
4307
+ * type test0 = A.Try<'42', string> // '42'
4308
+ * type test1 = A.Try<'42', number> // never
4309
+ * type test1 = A.Try<'42', number, 'tried'> // 'tried'
4310
+ * ```
4311
+ */
4312
+ type Try<A1, A2, Catch = never> = A1 extends A2 ? A1 : Catch;
4313
+ /**
4314
+ * Describes types that can be narrowed
4315
+ */
4316
+ type Narrowable = bigint | boolean | number | string;
4317
+ /**
4318
+ * @hidden
4319
+ */
4320
+ type NarrowRaw<A> = {
4321
+ [K in keyof A]: A[K] extends (...args: ReadonlyArray<unknown>) => unknown ? A[K] : NarrowRaw<A[K]>;
4322
+ } | (A extends [] ? [] : never) | (A extends Narrowable ? A : never);
4323
+ /**
4324
+ * Prevent type widening on generic function parameters
4325
+ * @param A to narrow
4326
+ * @returns `A`
4327
+ * @example
4328
+ * ```ts
4329
+ * import {F} from 'ts-toolbelt'
4330
+ *
4331
+ * declare function foo<A extends any[]>(x: F.Narrow<A>): A;
4332
+ * declare function bar<A extends object>(x: F.Narrow<A>): A;
4333
+ *
4334
+ * const test0 = foo(['e', 2, true, {f: ['g', ['h']]}])
4335
+ * // `A` inferred : ['e', 2, true, {f: ['g']}]
4336
+ *
4337
+ * const test1 = bar({a: 1, b: 'c', d: ['e', 2, true, {f: ['g']}]})
4338
+ * // `A` inferred : {a: 1, b: 'c', d: ['e', 2, true, {f: ['g']}]}
4339
+ * ```
4340
+ */
4341
+ type Narrow<A> = Try<A, [], NarrowRaw<A>>;
4342
+
4343
+ type Path<Obj, Prefix extends Array<PropertyKey> = []> = Obj extends Primitive ? Prefix : Obj extends Array<infer Item> ? Path<Item, [...Prefix, number]> | Prefix : PathsOfObject<Obj, Prefix> | Prefix;
4344
+ type PathsOfObject<Obj, Prefix extends Array<PropertyKey>> = {
4345
+ [K in keyof Obj]: Path<Obj[K], [...Prefix, K]>;
4346
+ }[keyof Obj];
4347
+ type ValueAtPath<Obj, ObjPath extends Array<PropertyKey> = []> = ObjPath extends [] ? Obj : ObjPath extends [infer Head, ...infer Tail] ? Tail extends Array<PropertyKey> ? Head extends keyof Obj ? ValueAtPath<Obj[Head], Tail> : never : never : never;
4348
+ type SupportsValueAtPath<Obj, Path extends Array<PropertyKey>, Value> = Value extends ValueAtPath<Obj, Path> ? Obj : never;
4349
+ type Primitive = boolean | null | number | string | symbol | undefined;
4350
+
4351
+ /**
4352
+ * Sets the value at `path` of `object`. `path` can be an array or a path string.
4353
+ *
4354
+ * @param object the target method
4355
+ * @param path the property name
4356
+ * @param value the value to set
4357
+ * @signature
4358
+ * P.setPath(obj, path, value)
4359
+ * @example
4360
+ * P.setPath({ a: { b: 1 } }, ['a', 'b'], 2) // => { a: { b: 2 } }
4361
+ * @dataFirst
4362
+ * @category Object
4363
+ */
4364
+ declare function setPath<T, TPath extends Array<PropertyKey> & Path<T>>(object: T, path: Narrow<TPath>, value: ValueAtPath<T, TPath>): T;
4365
+ /**
4366
+ * Sets the value at `path` of `object`. `path` can be an array or a path string.
4367
+ *
4368
+ * @param path the property name
4369
+ * @param value the value to set
4370
+ * @signature
4371
+ * P.setPath(path, value)
4372
+ * @example
4373
+ * P.pipe({ a: { b: 1 } }, P.setPath(['a', 'b'], 2)) // { a: { b: 2 } }
4374
+ * @dataFirst
4375
+ * @category Object
4376
+ */
4377
+ declare function setPath<TPath extends Array<PropertyKey>, Value>(path: Narrow<TPath>, value: Value): <Obj>(object: SupportsValueAtPath<Obj, TPath, Value>) => Obj;
4378
+ declare function setPath_(data: unknown, path: ReadonlyArray<PropertyKey>, value: unknown): unknown;
4379
+
4380
+ type SwappedProps<T, K1 extends keyof T, K2 extends keyof T> = {
4381
+ [K in keyof T]: T[K1 extends K ? K2 : K2 extends K ? K1 : K];
4382
+ };
4383
+ /**
4384
+ * Swaps the positions of two properties in an object based on the provided keys.
4385
+ *
4386
+ * @param data the object to be manipulated
4387
+ * @param key1 the first property key
4388
+ * @param key2 the second property key
4389
+ *
4390
+ * @signature
4391
+ * swap(data, key1, key2)
4392
+ *
4393
+ * @returns Returns the manipulated object.
4394
+ *
4395
+ * @example
4396
+ * swap({a: 1, b: 2, c: 3}, 'a', 'b') // => {a: 2, b: 1, c: 3}
4397
+ *
4398
+ * @category Object
4399
+ *
4400
+ * @dataFirst
4401
+ */
4402
+ declare function swapProps<T extends object, K1 extends keyof T, K2 extends keyof T>(data: T, key1: K1, key2: K2): SwappedProps<T, K1, K2>;
4403
+ /**
4404
+ * Swaps the positions of two properties in an object based on the provided keys.
4405
+ *
4406
+ * @param key1 the first property key
4407
+ * @param key2 the second property key
4408
+ *
4409
+ * @signature
4410
+ * swap(key1, key2)(data)
4411
+ *
4412
+ * @example
4413
+ * swap('a', 'b')({a: 1, b: 2, c: 3}) // => {a: 2, b: 1, c: 3}
4414
+ *
4415
+ * @returns Returns the manipulated object.
4416
+ *
4417
+ * @category Object
4418
+ *
4419
+ * @dataLast
4420
+ */
4421
+ declare function swapProps<T extends object, K1 extends keyof T, K2 extends keyof T>(key1: K1, key2: K2): (data: T) => SwappedProps<T, K1, K2>;
4422
+
4423
+ type Pairs<T> = Array<{
4424
+ [K in keyof T]-?: [key: K, value: Required<T>[K]];
4425
+ }[keyof T]>;
4426
+ interface Strict {
4427
+ <T extends NonNullable<unknown>>(object: T): Pairs<T>;
4428
+ }
4429
+ /**
4430
+ * Returns an array of key/values of the enumerable properties of an object.
4431
+ * @param object
4432
+ * @signature
4433
+ * P.toPairs(object)
4434
+ * P.toPairs.strict(object)
4435
+ * @example
4436
+ * P.toPairs({ a: 1, b: 2, c: 3 }) // => [['a', 1], ['b', 2], ['c', 3]]
4437
+ * P.toPairs.strict({ a: 1 } as const) // => [['a', 1]] typed Array<['a', 1]>
4438
+ * P.pipe(
4439
+ * { a: 1, b: 2, c: 3 },
4440
+ * toPairs,
4441
+ * ); // => [['a', 1], ['b', 2], ['c', 3]]
4442
+ * P.pipe(
4443
+ * { a: 1 } as const,
4444
+ * toPairs.strict,
4445
+ * ); // => [['a', 1]] typed Array<['a', 1]>
4446
+ * @strict
4447
+ * @category Object
4448
+ * @dataFirst
4449
+ */
4450
+ declare function toPairs<T>(object: Readonly<Record<string, T>>): Array<[string, T]>;
4451
+ declare namespace toPairs {
4452
+ const strict: Strict;
4453
+ }
4454
+
4455
+ /**
4456
+ * Returns a new array containing the values of the array or object.
4457
+ *
4458
+ * @param source Either an array or an object
4459
+ * @signature
4460
+ * P.values(source)
4461
+ * @example
4462
+ * P.values(['x', 'y', 'z']) // => ['x', 'y', 'z']
4463
+ * P.values({ a: 'x', b: 'y', c: 'z' }) // => ['x', 'y', 'z']
4464
+ * P.pipe(
4465
+ * { a: 'x', b: 'y', c: 'z' },
4466
+ * P.values,
4467
+ * P.first
4468
+ * ) // => 'x'
4469
+ * @pipeable
4470
+ * @category Object
4471
+ */
4472
+ type Values<T extends object> = T extends [] | ReadonlyArray<unknown> ? Array<T[number]> : Array<T[keyof T]>;
4473
+ declare function values<T extends object>(source: T): Values<T>;
4474
+
4475
+ type Splitter = '.' | '/' | '_' | '-';
4476
+ type FirstOfString<S extends string> = S extends `${infer F}${string}` ? F : never;
4477
+ type RemoveFirstOfString<S extends string> = S extends `${string}${infer R}` ? R : never;
4478
+ type IsUpper<S extends string> = S extends Uppercase<S> ? true : false;
4479
+ type IsLower<S extends string> = S extends Lowercase<S> ? true : false;
4480
+ type SameLetterCase<X extends string, Y extends string> = IsUpper<X> extends IsUpper<Y> ? true : IsLower<X> extends IsLower<Y> ? true : false;
4481
+ type CapitalizedWords<T extends ReadonlyArray<string>, Accumulator extends string = '', Normalize extends boolean | undefined = false> = T extends readonly [infer F extends string, ...infer R extends Array<string>] ? CapitalizedWords<R, `${Accumulator}${Capitalize<Normalize extends true ? Lowercase<F> : F>}`, Normalize> : Accumulator;
4482
+ type JoinLowercaseWords<T extends ReadonlyArray<string>, Joiner extends string, Accumulator extends string = ''> = T extends readonly [infer F extends string, ...infer R extends Array<string>] ? Accumulator extends '' ? JoinLowercaseWords<R, Joiner, `${Accumulator}${Lowercase<F>}`> : JoinLowercaseWords<R, Joiner, `${Accumulator}${Joiner}${Lowercase<F>}`> : Accumulator;
4483
+ type LastOfArray<T extends Array<any>> = T extends [...any, infer R] ? R : never;
4484
+ type RemoveLastOfArray<T extends Array<any>> = T extends [...infer F, any] ? F : never;
4485
+ interface CaseOptions {
4486
+ normalize?: boolean;
4487
+ }
4488
+ type SplitByCase<T, Separator extends string = Splitter, Accumulator extends Array<unknown> = []> = string extends Separator ? Array<string> : T extends `${infer F}${infer R}` ? [LastOfArray<Accumulator>] extends [never] ? SplitByCase<R, Separator, [F]> : LastOfArray<Accumulator> extends string ? R extends '' ? SplitByCase<R, Separator, [
4489
+ ...RemoveLastOfArray<Accumulator>,
4490
+ `${LastOfArray<Accumulator>}${F}`
4491
+ ]> : SameLetterCase<F, FirstOfString<R>> extends true ? F extends Separator ? FirstOfString<R> extends Separator ? SplitByCase<R, Separator, [...Accumulator, '']> : IsUpper<FirstOfString<R>> extends true ? SplitByCase<RemoveFirstOfString<R>, Separator, [
4492
+ ...Accumulator,
4493
+ FirstOfString<R>
4494
+ ]> : SplitByCase<R, Separator, [...Accumulator, '']> : SplitByCase<R, Separator, [
4495
+ ...RemoveLastOfArray<Accumulator>,
4496
+ `${LastOfArray<Accumulator>}${F}`
4497
+ ]> : IsLower<F> extends true ? SplitByCase<RemoveFirstOfString<R>, Separator, [
4498
+ ...RemoveLastOfArray<Accumulator>,
4499
+ `${LastOfArray<Accumulator>}${F}`,
4500
+ FirstOfString<R>
4501
+ ]> : SplitByCase<R, Separator, [...Accumulator, F]> : never : Accumulator extends [] ? T extends '' ? [] : Array<string> : Accumulator;
4502
+ type JoinByCase<T, Joiner extends string> = string extends T ? string : Array<string> extends T ? string : T extends string ? SplitByCase<T> extends ReadonlyArray<string> ? JoinLowercaseWords<SplitByCase<T>, Joiner> : never : T extends ReadonlyArray<string> ? JoinLowercaseWords<T, Joiner> : never;
4503
+ type PascalCase<T, Normalize extends boolean | undefined = false> = string extends T ? string : Array<string> extends T ? string : T extends string ? SplitByCase<T> extends ReadonlyArray<string> ? CapitalizedWords<SplitByCase<T>, '', Normalize> : never : T extends ReadonlyArray<string> ? CapitalizedWords<T, '', Normalize> : never;
4504
+ type CamelCase<T, Normalize extends boolean | undefined = false> = string extends T ? string : Array<string> extends T ? string : Uncapitalize<PascalCase<T, Normalize>>;
4505
+ type KebabCase<T extends ReadonlyArray<string> | string, Joiner extends string = '-'> = JoinByCase<T, Joiner>;
4506
+ type SnakeCase<T extends ReadonlyArray<string> | string> = JoinByCase<T, '_'>;
4507
+ type TrainCase<T, Normalize extends boolean | undefined = false, Joiner extends string = '-'> = string extends T ? string : Array<string> extends T ? string : T extends string ? SplitByCase<T> extends ReadonlyArray<string> ? CapitalizedWords<SplitByCase<T>, Joiner> : never : T extends ReadonlyArray<string> ? CapitalizedWords<T, Joiner, Normalize> : never;
4508
+ type FlatCase<T extends ReadonlyArray<string> | string, Joiner extends string = ''> = JoinByCase<T, Joiner>;
4509
+
4510
+ declare function isUppercase(char?: string): boolean | undefined;
4511
+ declare function splitByCase<T extends string>(str: T): SplitByCase<T>;
4512
+ declare function splitByCase<T extends string, Separator extends ReadonlyArray<string>>(str: T, separators: Separator): SplitByCase<T, Separator[number]>;
4513
+ declare function toUpperFirst<S extends string>(str: S): Capitalize<S>;
4514
+ declare function toLowerFirst<S extends string>(str: S): Uncapitalize<S>;
4515
+ declare function toPascalCase(): '';
4516
+ declare function toPascalCase<T extends ReadonlyArray<string> | string, UserCaseOptions extends CaseOptions = CaseOptions>(str: T, opts?: CaseOptions): PascalCase<T, UserCaseOptions['normalize']>;
4517
+ declare function toCamelCase(): '';
4518
+ declare function toCamelCase<T extends ReadonlyArray<string> | string, UserCaseOptions extends CaseOptions = CaseOptions>(str: T, opts?: UserCaseOptions): CamelCase<T, UserCaseOptions['normalize']>;
4519
+ declare function toKebabCase(): '';
4520
+ declare function toKebabCase<T extends ReadonlyArray<string> | string>(str: T): KebabCase<T>;
4521
+ declare function toKebabCase<T extends ReadonlyArray<string> | string, Joiner extends string>(str: T, joiner: Joiner): KebabCase<T, Joiner>;
4522
+ declare function toSnakeCase(): '';
4523
+ declare function toSnakeCase<T extends ReadonlyArray<string> | string>(str: T): SnakeCase<T>;
4524
+ declare function toFlatCase(): '';
4525
+ declare function toFlatCase<T extends ReadonlyArray<string> | string>(str: T): FlatCase<T>;
4526
+ declare function toTrainCase(): '';
4527
+ declare function toTrainCase<T extends ReadonlyArray<string> | string, UserCaseOptions extends CaseOptions = CaseOptions>(str: T, opts?: UserCaseOptions): TrainCase<T, UserCaseOptions['normalize']>;
4528
+ declare function toTitleCase(): '';
4529
+ declare function toTitleCase<T extends ReadonlyArray<string> | string, UserCaseOptions extends CaseOptions = CaseOptions>(str: T, opts?: UserCaseOptions): TrainCase<T, UserCaseOptions['normalize'], ' '>;
4530
+
4531
+ /**
4532
+ * Returns human readable file size.
4533
+ * @param bytes the file size in bytes
4534
+ * @param base the base (1000 or 1024)
4535
+ * @signature
4536
+ * P.humanReadableFileSize(bytes, base)
4537
+ * @example
4538
+ * P.humanReadableFileSize(1000) // => '1.0 kB'
4539
+ * P.humanReadableFileSize(2097152, 1024) // => '2.0 Mib'
4540
+ * @category String
4541
+ */
4542
+ declare function humanReadableFileSize(bytes: number, base?: 1000 | 1024): string;
4543
+
4544
+ /**
4545
+ * Random a non-cryptographic random string from characters a-zA-Z0-9.
4546
+ *
4547
+ * @param length the length of the random string
4548
+ * @returns the random string
4549
+ * @signature
4550
+ * P.randomString(length)
4551
+ * @example
4552
+ * P.randomString(5) // => aB92J
4553
+ * P.pipe(5, P.randomString) // => aB92J
4554
+ * @category String
4555
+ * @dataFirst
4556
+ */
4557
+ declare function randomString(length: number): string;
4558
+
4559
+ /**
4560
+ * Turn any string into a URL/DOM safe string.
4561
+ * @param str the string to slugify
4562
+ * @signature
4563
+ * P.slugify(str)
4564
+ * @example
4565
+ * P.slugify('FooBar') // => 'foobar'
4566
+ * P.slugify('This!-is*&%#@^up!') // => 'this-is-up'
4567
+ * @category String
4568
+ */
4569
+ declare function slugify(str: string): string;
4570
+
4571
+ /**
4572
+ * Converts a path string to an array of keys.
4573
+ * @param path a string path
4574
+ * @signature P.stringToPathArray(path)
4575
+ * @example P.stringToPathArray('a.b[0].c') // => ['a', 'b', 0, 'c']
4576
+ * @dataFirst
4577
+ * @category String
4578
+ */
4579
+ declare function stringToPath<Path extends string>(path: Path): StringToPath<Path>;
4580
+ type StringToPath<T extends string> = T extends '' ? [] : T extends `[${infer Head}].${infer Tail}` ? [Head, ...StringToPath<Tail>] : T extends `.${infer Head}${infer Tail}` ? [Head, ...StringToPath<Tail>] : T extends `${infer Head}${infer Tail}` ? [Head, ...StringToPath<Tail>] : [T];
4581
+
4582
+ /**
4583
+ * Gives a single-word string description of the (native) type of a value, returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not attempt to distinguish user Object types any further, reporting them all as 'Object'.
4584
+ * @param val
4585
+ * @signature
4586
+ * P.type(obj)
4587
+ * @example
4588
+ * P.type({}); //=> "Object"
4589
+ * P.type(1); //=> "Number"
4590
+ * P.type(false); //=> "Boolean"
4591
+ * P.type('s'); //=> "String"
4592
+ * P.type(null); //=> "Null"
4593
+ * P.type([]); //=> "Array"
4594
+ * P.type(/[A-z]/); //=> "RegExp"
4595
+ * P.type(() => {}); //=> "Function"
4596
+ * P.type(undefined); //=> "Undefined"
4597
+ * @category Type
4598
+ */
4599
+ declare function type(val: unknown): string;
4600
+
4601
+ declare const isBrowser: boolean;
4602
+
4603
+ export { type Joined, KEY_CODES, type LazyEvaluator, type StringToPath, add, addProp, allPass, anyPass, ceil, chunk, clamp, clone, concat, conditional, createPipe, debounce, differenceWith, divide, drop, dropFirstBy, dropLast, dropLastWhile, dropWhile, filter, find, findIndex, findLast, findLastIndex, first, firstBy, flatMap, flatMapToObj, flatten, flattenDeep, floor, forEach, forEachObj, fromKeys, fromPairs, groupBy, hasAtLeast, hasSubObject, humanReadableFileSize, identity, indexBy, intersectionWith, invert, isArray, isBoolean, isBrowser, isDate, isDeepEqual, isDefined, isEmpty, isError, isFunction, isIncludedIn, isNil, isNonNull, isNot, isNumber, isObject, isPromise, isString, isSymbol, isTruthy, isUppercase, join, keys, last, length, map, mapKeys, mapToObj, mapValues, maxBy, meanBy, merge, mergeAll, mergeDeep, minBy, multiply, noop, nthBy, omit, omitBy, once, only, partition, pathOr, pick, pickBy, pipe, prop, purry, randomString, range, rankBy, reduce, reject, reverse, round, sample, set, setPath, setPath_, shuffle, sleep, slugify, sort, sortBy, sortedIndex, sortedIndexBy, sortedIndexWith, sortedLastIndex, splice, splitAt, splitByCase, splitWhen, stringToPath, subtract, sumBy, swapIndices, swapProps, take, takeFirstBy, takeWhile, times, toCamelCase, toFlatCase, toKebabCase, toLowerFirst, toPairs, toPascalCase, toSnakeCase, toTitleCase, toTrainCase, toUpperFirst, type, uniq, uniqBy, uniqWith, values, zip, zipObj, zipWith };