@depup/remeda 2.33.6-depup.0

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 (705) hide show
  1. package/README.md +25 -0
  2. package/changes.json +5 -0
  3. package/dist/add.cjs +2 -0
  4. package/dist/add.cjs.map +1 -0
  5. package/dist/add.js +2 -0
  6. package/dist/add.js.map +1 -0
  7. package/dist/addProp.cjs +2 -0
  8. package/dist/addProp.cjs.map +1 -0
  9. package/dist/addProp.js +2 -0
  10. package/dist/addProp.js.map +1 -0
  11. package/dist/allPass.cjs +2 -0
  12. package/dist/allPass.cjs.map +1 -0
  13. package/dist/allPass.js +2 -0
  14. package/dist/allPass.js.map +1 -0
  15. package/dist/anyPass.cjs +2 -0
  16. package/dist/anyPass.cjs.map +1 -0
  17. package/dist/anyPass.js +2 -0
  18. package/dist/anyPass.js.map +1 -0
  19. package/dist/binarySearchCutoffIndex-CLQRwIY1.js +2 -0
  20. package/dist/binarySearchCutoffIndex-CLQRwIY1.js.map +1 -0
  21. package/dist/binarySearchCutoffIndex-DdLPjZiy.cjs +2 -0
  22. package/dist/binarySearchCutoffIndex-DdLPjZiy.cjs.map +1 -0
  23. package/dist/capitalize.cjs +2 -0
  24. package/dist/capitalize.cjs.map +1 -0
  25. package/dist/capitalize.js +2 -0
  26. package/dist/capitalize.js.map +1 -0
  27. package/dist/ceil.cjs +2 -0
  28. package/dist/ceil.cjs.map +1 -0
  29. package/dist/ceil.js +2 -0
  30. package/dist/ceil.js.map +1 -0
  31. package/dist/chunk.cjs +2 -0
  32. package/dist/chunk.cjs.map +1 -0
  33. package/dist/chunk.js +2 -0
  34. package/dist/chunk.js.map +1 -0
  35. package/dist/clamp.cjs +2 -0
  36. package/dist/clamp.cjs.map +1 -0
  37. package/dist/clamp.js +2 -0
  38. package/dist/clamp.js.map +1 -0
  39. package/dist/clone.cjs +2 -0
  40. package/dist/clone.cjs.map +1 -0
  41. package/dist/clone.js +2 -0
  42. package/dist/clone.js.map +1 -0
  43. package/dist/concat.cjs +2 -0
  44. package/dist/concat.cjs.map +1 -0
  45. package/dist/concat.js +2 -0
  46. package/dist/concat.js.map +1 -0
  47. package/dist/conditional.cjs +2 -0
  48. package/dist/conditional.cjs.map +1 -0
  49. package/dist/conditional.js +2 -0
  50. package/dist/conditional.js.map +1 -0
  51. package/dist/constant.cjs +2 -0
  52. package/dist/constant.cjs.map +1 -0
  53. package/dist/constant.js +2 -0
  54. package/dist/constant.js.map +1 -0
  55. package/dist/countBy.cjs +2 -0
  56. package/dist/countBy.cjs.map +1 -0
  57. package/dist/countBy.js +2 -0
  58. package/dist/countBy.js.map +1 -0
  59. package/dist/debounce.cjs +2 -0
  60. package/dist/debounce.cjs.map +1 -0
  61. package/dist/debounce.js +2 -0
  62. package/dist/debounce.js.map +1 -0
  63. package/dist/defaultTo.cjs +2 -0
  64. package/dist/defaultTo.cjs.map +1 -0
  65. package/dist/defaultTo.js +2 -0
  66. package/dist/defaultTo.js.map +1 -0
  67. package/dist/difference.cjs +2 -0
  68. package/dist/difference.cjs.map +1 -0
  69. package/dist/difference.js +2 -0
  70. package/dist/difference.js.map +1 -0
  71. package/dist/differenceWith.cjs +2 -0
  72. package/dist/differenceWith.cjs.map +1 -0
  73. package/dist/differenceWith.js +2 -0
  74. package/dist/differenceWith.js.map +1 -0
  75. package/dist/divide.cjs +2 -0
  76. package/dist/divide.cjs.map +1 -0
  77. package/dist/divide.js +2 -0
  78. package/dist/divide.js.map +1 -0
  79. package/dist/doNothing.cjs +2 -0
  80. package/dist/doNothing.cjs.map +1 -0
  81. package/dist/doNothing.js +2 -0
  82. package/dist/doNothing.js.map +1 -0
  83. package/dist/drop.cjs +2 -0
  84. package/dist/drop.cjs.map +1 -0
  85. package/dist/drop.js +2 -0
  86. package/dist/drop.js.map +1 -0
  87. package/dist/dropFirstBy.cjs +2 -0
  88. package/dist/dropFirstBy.cjs.map +1 -0
  89. package/dist/dropFirstBy.js +2 -0
  90. package/dist/dropFirstBy.js.map +1 -0
  91. package/dist/dropLast.cjs +2 -0
  92. package/dist/dropLast.cjs.map +1 -0
  93. package/dist/dropLast.js +2 -0
  94. package/dist/dropLast.js.map +1 -0
  95. package/dist/dropLastWhile.cjs +2 -0
  96. package/dist/dropLastWhile.cjs.map +1 -0
  97. package/dist/dropLastWhile.js +2 -0
  98. package/dist/dropLastWhile.js.map +1 -0
  99. package/dist/dropWhile.cjs +2 -0
  100. package/dist/dropWhile.cjs.map +1 -0
  101. package/dist/dropWhile.js +2 -0
  102. package/dist/dropWhile.js.map +1 -0
  103. package/dist/endsWith.cjs +2 -0
  104. package/dist/endsWith.cjs.map +1 -0
  105. package/dist/endsWith.js +2 -0
  106. package/dist/endsWith.js.map +1 -0
  107. package/dist/entries.cjs +2 -0
  108. package/dist/entries.cjs.map +1 -0
  109. package/dist/entries.js +2 -0
  110. package/dist/entries.js.map +1 -0
  111. package/dist/evolve.cjs +2 -0
  112. package/dist/evolve.cjs.map +1 -0
  113. package/dist/evolve.js +2 -0
  114. package/dist/evolve.js.map +1 -0
  115. package/dist/filter.cjs +2 -0
  116. package/dist/filter.cjs.map +1 -0
  117. package/dist/filter.js +2 -0
  118. package/dist/filter.js.map +1 -0
  119. package/dist/find.cjs +2 -0
  120. package/dist/find.cjs.map +1 -0
  121. package/dist/find.js +2 -0
  122. package/dist/find.js.map +1 -0
  123. package/dist/findIndex.cjs +2 -0
  124. package/dist/findIndex.cjs.map +1 -0
  125. package/dist/findIndex.js +2 -0
  126. package/dist/findIndex.js.map +1 -0
  127. package/dist/findLast.cjs +2 -0
  128. package/dist/findLast.cjs.map +1 -0
  129. package/dist/findLast.js +2 -0
  130. package/dist/findLast.js.map +1 -0
  131. package/dist/findLastIndex.cjs +2 -0
  132. package/dist/findLastIndex.cjs.map +1 -0
  133. package/dist/findLastIndex.js +2 -0
  134. package/dist/findLastIndex.js.map +1 -0
  135. package/dist/first.cjs +2 -0
  136. package/dist/first.cjs.map +1 -0
  137. package/dist/first.js +2 -0
  138. package/dist/first.js.map +1 -0
  139. package/dist/firstBy.cjs +2 -0
  140. package/dist/firstBy.cjs.map +1 -0
  141. package/dist/firstBy.js +2 -0
  142. package/dist/firstBy.js.map +1 -0
  143. package/dist/flat.cjs +2 -0
  144. package/dist/flat.cjs.map +1 -0
  145. package/dist/flat.js +2 -0
  146. package/dist/flat.js.map +1 -0
  147. package/dist/flatMap.cjs +2 -0
  148. package/dist/flatMap.cjs.map +1 -0
  149. package/dist/flatMap.js +2 -0
  150. package/dist/flatMap.js.map +1 -0
  151. package/dist/floor.cjs +2 -0
  152. package/dist/floor.cjs.map +1 -0
  153. package/dist/floor.js +2 -0
  154. package/dist/floor.js.map +1 -0
  155. package/dist/forEach.cjs +2 -0
  156. package/dist/forEach.cjs.map +1 -0
  157. package/dist/forEach.js +2 -0
  158. package/dist/forEach.js.map +1 -0
  159. package/dist/forEachObj.cjs +2 -0
  160. package/dist/forEachObj.cjs.map +1 -0
  161. package/dist/forEachObj.js +2 -0
  162. package/dist/forEachObj.js.map +1 -0
  163. package/dist/fromEntries.cjs +2 -0
  164. package/dist/fromEntries.cjs.map +1 -0
  165. package/dist/fromEntries.js +2 -0
  166. package/dist/fromEntries.js.map +1 -0
  167. package/dist/fromKeys.cjs +2 -0
  168. package/dist/fromKeys.cjs.map +1 -0
  169. package/dist/fromKeys.js +2 -0
  170. package/dist/fromKeys.js.map +1 -0
  171. package/dist/funnel.cjs +2 -0
  172. package/dist/funnel.cjs.map +1 -0
  173. package/dist/funnel.js +2 -0
  174. package/dist/funnel.js.map +1 -0
  175. package/dist/groupBy.cjs +2 -0
  176. package/dist/groupBy.cjs.map +1 -0
  177. package/dist/groupBy.js +2 -0
  178. package/dist/groupBy.js.map +1 -0
  179. package/dist/groupByProp.cjs +2 -0
  180. package/dist/groupByProp.cjs.map +1 -0
  181. package/dist/groupByProp.js +2 -0
  182. package/dist/groupByProp.js.map +1 -0
  183. package/dist/hasAtLeast.cjs +2 -0
  184. package/dist/hasAtLeast.cjs.map +1 -0
  185. package/dist/hasAtLeast.js +2 -0
  186. package/dist/hasAtLeast.js.map +1 -0
  187. package/dist/hasSubObject.cjs +2 -0
  188. package/dist/hasSubObject.cjs.map +1 -0
  189. package/dist/hasSubObject.js +2 -0
  190. package/dist/hasSubObject.js.map +1 -0
  191. package/dist/heap-14xVkDB1.cjs +2 -0
  192. package/dist/heap-14xVkDB1.cjs.map +1 -0
  193. package/dist/heap-OOe_F8_z.js +2 -0
  194. package/dist/heap-OOe_F8_z.js.map +1 -0
  195. package/dist/identity.cjs +2 -0
  196. package/dist/identity.cjs.map +1 -0
  197. package/dist/identity.js +2 -0
  198. package/dist/identity.js.map +1 -0
  199. package/dist/index.cjs +1 -0
  200. package/dist/index.d.cts +11948 -0
  201. package/dist/index.d.cts.map +1 -0
  202. package/dist/index.d.ts +11948 -0
  203. package/dist/index.d.ts.map +1 -0
  204. package/dist/index.js +1 -0
  205. package/dist/indexBy.cjs +2 -0
  206. package/dist/indexBy.cjs.map +1 -0
  207. package/dist/indexBy.js +2 -0
  208. package/dist/indexBy.js.map +1 -0
  209. package/dist/intersection.cjs +2 -0
  210. package/dist/intersection.cjs.map +1 -0
  211. package/dist/intersection.js +2 -0
  212. package/dist/intersection.js.map +1 -0
  213. package/dist/intersectionWith.cjs +2 -0
  214. package/dist/intersectionWith.cjs.map +1 -0
  215. package/dist/intersectionWith.js +2 -0
  216. package/dist/intersectionWith.js.map +1 -0
  217. package/dist/invert.cjs +2 -0
  218. package/dist/invert.cjs.map +1 -0
  219. package/dist/invert.js +2 -0
  220. package/dist/invert.js.map +1 -0
  221. package/dist/isArray.cjs +2 -0
  222. package/dist/isArray.cjs.map +1 -0
  223. package/dist/isArray.js +2 -0
  224. package/dist/isArray.js.map +1 -0
  225. package/dist/isBigInt.cjs +2 -0
  226. package/dist/isBigInt.cjs.map +1 -0
  227. package/dist/isBigInt.js +2 -0
  228. package/dist/isBigInt.js.map +1 -0
  229. package/dist/isBoolean.cjs +2 -0
  230. package/dist/isBoolean.cjs.map +1 -0
  231. package/dist/isBoolean.js +2 -0
  232. package/dist/isBoolean.js.map +1 -0
  233. package/dist/isDate.cjs +2 -0
  234. package/dist/isDate.cjs.map +1 -0
  235. package/dist/isDate.js +2 -0
  236. package/dist/isDate.js.map +1 -0
  237. package/dist/isDeepEqual.cjs +2 -0
  238. package/dist/isDeepEqual.cjs.map +1 -0
  239. package/dist/isDeepEqual.js +2 -0
  240. package/dist/isDeepEqual.js.map +1 -0
  241. package/dist/isDefined.cjs +2 -0
  242. package/dist/isDefined.cjs.map +1 -0
  243. package/dist/isDefined.js +2 -0
  244. package/dist/isDefined.js.map +1 -0
  245. package/dist/isEmpty.cjs +2 -0
  246. package/dist/isEmpty.cjs.map +1 -0
  247. package/dist/isEmpty.js +2 -0
  248. package/dist/isEmpty.js.map +1 -0
  249. package/dist/isEmptyish.cjs +2 -0
  250. package/dist/isEmptyish.cjs.map +1 -0
  251. package/dist/isEmptyish.js +2 -0
  252. package/dist/isEmptyish.js.map +1 -0
  253. package/dist/isError.cjs +2 -0
  254. package/dist/isError.cjs.map +1 -0
  255. package/dist/isError.js +2 -0
  256. package/dist/isError.js.map +1 -0
  257. package/dist/isFunction.cjs +2 -0
  258. package/dist/isFunction.cjs.map +1 -0
  259. package/dist/isFunction.js +2 -0
  260. package/dist/isFunction.js.map +1 -0
  261. package/dist/isIncludedIn.cjs +2 -0
  262. package/dist/isIncludedIn.cjs.map +1 -0
  263. package/dist/isIncludedIn.js +2 -0
  264. package/dist/isIncludedIn.js.map +1 -0
  265. package/dist/isNonNull.cjs +2 -0
  266. package/dist/isNonNull.cjs.map +1 -0
  267. package/dist/isNonNull.js +2 -0
  268. package/dist/isNonNull.js.map +1 -0
  269. package/dist/isNonNullish.cjs +2 -0
  270. package/dist/isNonNullish.cjs.map +1 -0
  271. package/dist/isNonNullish.js +2 -0
  272. package/dist/isNonNullish.js.map +1 -0
  273. package/dist/isNot.cjs +2 -0
  274. package/dist/isNot.cjs.map +1 -0
  275. package/dist/isNot.js +2 -0
  276. package/dist/isNot.js.map +1 -0
  277. package/dist/isNullish.cjs +2 -0
  278. package/dist/isNullish.cjs.map +1 -0
  279. package/dist/isNullish.js +2 -0
  280. package/dist/isNullish.js.map +1 -0
  281. package/dist/isNumber.cjs +2 -0
  282. package/dist/isNumber.cjs.map +1 -0
  283. package/dist/isNumber.js +2 -0
  284. package/dist/isNumber.js.map +1 -0
  285. package/dist/isObjectType.cjs +2 -0
  286. package/dist/isObjectType.cjs.map +1 -0
  287. package/dist/isObjectType.js +2 -0
  288. package/dist/isObjectType.js.map +1 -0
  289. package/dist/isPlainObject.cjs +2 -0
  290. package/dist/isPlainObject.cjs.map +1 -0
  291. package/dist/isPlainObject.js +2 -0
  292. package/dist/isPlainObject.js.map +1 -0
  293. package/dist/isPromise.cjs +2 -0
  294. package/dist/isPromise.cjs.map +1 -0
  295. package/dist/isPromise.js +2 -0
  296. package/dist/isPromise.js.map +1 -0
  297. package/dist/isShallowEqual.cjs +2 -0
  298. package/dist/isShallowEqual.cjs.map +1 -0
  299. package/dist/isShallowEqual.js +2 -0
  300. package/dist/isShallowEqual.js.map +1 -0
  301. package/dist/isStrictEqual.cjs +2 -0
  302. package/dist/isStrictEqual.cjs.map +1 -0
  303. package/dist/isStrictEqual.js +2 -0
  304. package/dist/isStrictEqual.js.map +1 -0
  305. package/dist/isString.cjs +2 -0
  306. package/dist/isString.cjs.map +1 -0
  307. package/dist/isString.js +2 -0
  308. package/dist/isString.js.map +1 -0
  309. package/dist/isSymbol.cjs +2 -0
  310. package/dist/isSymbol.cjs.map +1 -0
  311. package/dist/isSymbol.js +2 -0
  312. package/dist/isSymbol.js.map +1 -0
  313. package/dist/isTruthy.cjs +2 -0
  314. package/dist/isTruthy.cjs.map +1 -0
  315. package/dist/isTruthy.js +2 -0
  316. package/dist/isTruthy.js.map +1 -0
  317. package/dist/join.cjs +2 -0
  318. package/dist/join.cjs.map +1 -0
  319. package/dist/join.js +2 -0
  320. package/dist/join.js.map +1 -0
  321. package/dist/keys.cjs +2 -0
  322. package/dist/keys.cjs.map +1 -0
  323. package/dist/keys.js +2 -0
  324. package/dist/keys.js.map +1 -0
  325. package/dist/last.cjs +2 -0
  326. package/dist/last.cjs.map +1 -0
  327. package/dist/last.js +2 -0
  328. package/dist/last.js.map +1 -0
  329. package/dist/lazyDataLastImpl-DdpJofHC.cjs +2 -0
  330. package/dist/lazyDataLastImpl-DdpJofHC.cjs.map +1 -0
  331. package/dist/lazyDataLastImpl-DtF3cihj.js +2 -0
  332. package/dist/lazyDataLastImpl-DtF3cihj.js.map +1 -0
  333. package/dist/length.cjs +2 -0
  334. package/dist/length.cjs.map +1 -0
  335. package/dist/length.js +2 -0
  336. package/dist/length.js.map +1 -0
  337. package/dist/map.cjs +2 -0
  338. package/dist/map.cjs.map +1 -0
  339. package/dist/map.js +2 -0
  340. package/dist/map.js.map +1 -0
  341. package/dist/mapKeys.cjs +2 -0
  342. package/dist/mapKeys.cjs.map +1 -0
  343. package/dist/mapKeys.js +2 -0
  344. package/dist/mapKeys.js.map +1 -0
  345. package/dist/mapToObj.cjs +2 -0
  346. package/dist/mapToObj.cjs.map +1 -0
  347. package/dist/mapToObj.js +2 -0
  348. package/dist/mapToObj.js.map +1 -0
  349. package/dist/mapValues.cjs +2 -0
  350. package/dist/mapValues.cjs.map +1 -0
  351. package/dist/mapValues.js +2 -0
  352. package/dist/mapValues.js.map +1 -0
  353. package/dist/mapWithFeedback.cjs +2 -0
  354. package/dist/mapWithFeedback.cjs.map +1 -0
  355. package/dist/mapWithFeedback.js +2 -0
  356. package/dist/mapWithFeedback.js.map +1 -0
  357. package/dist/mean.cjs +2 -0
  358. package/dist/mean.cjs.map +1 -0
  359. package/dist/mean.js +2 -0
  360. package/dist/mean.js.map +1 -0
  361. package/dist/meanBy.cjs +2 -0
  362. package/dist/meanBy.cjs.map +1 -0
  363. package/dist/meanBy.js +2 -0
  364. package/dist/meanBy.js.map +1 -0
  365. package/dist/median.cjs +2 -0
  366. package/dist/median.cjs.map +1 -0
  367. package/dist/median.js +2 -0
  368. package/dist/median.js.map +1 -0
  369. package/dist/merge.cjs +2 -0
  370. package/dist/merge.cjs.map +1 -0
  371. package/dist/merge.js +2 -0
  372. package/dist/merge.js.map +1 -0
  373. package/dist/mergeAll.cjs +2 -0
  374. package/dist/mergeAll.cjs.map +1 -0
  375. package/dist/mergeAll.js +2 -0
  376. package/dist/mergeAll.js.map +1 -0
  377. package/dist/mergeDeep.cjs +2 -0
  378. package/dist/mergeDeep.cjs.map +1 -0
  379. package/dist/mergeDeep.js +2 -0
  380. package/dist/mergeDeep.js.map +1 -0
  381. package/dist/multiply.cjs +2 -0
  382. package/dist/multiply.cjs.map +1 -0
  383. package/dist/multiply.js +2 -0
  384. package/dist/multiply.js.map +1 -0
  385. package/dist/nthBy.cjs +2 -0
  386. package/dist/nthBy.cjs.map +1 -0
  387. package/dist/nthBy.js +2 -0
  388. package/dist/nthBy.js.map +1 -0
  389. package/dist/objOf.cjs +2 -0
  390. package/dist/objOf.cjs.map +1 -0
  391. package/dist/objOf.js +2 -0
  392. package/dist/objOf.js.map +1 -0
  393. package/dist/omit.cjs +2 -0
  394. package/dist/omit.cjs.map +1 -0
  395. package/dist/omit.js +2 -0
  396. package/dist/omit.js.map +1 -0
  397. package/dist/omitBy.cjs +2 -0
  398. package/dist/omitBy.cjs.map +1 -0
  399. package/dist/omitBy.js +2 -0
  400. package/dist/omitBy.js.map +1 -0
  401. package/dist/once.cjs +2 -0
  402. package/dist/once.cjs.map +1 -0
  403. package/dist/once.js +2 -0
  404. package/dist/once.js.map +1 -0
  405. package/dist/only.cjs +2 -0
  406. package/dist/only.cjs.map +1 -0
  407. package/dist/only.js +2 -0
  408. package/dist/only.js.map +1 -0
  409. package/dist/partialBind.cjs +2 -0
  410. package/dist/partialBind.cjs.map +1 -0
  411. package/dist/partialBind.js +2 -0
  412. package/dist/partialBind.js.map +1 -0
  413. package/dist/partialLastBind.cjs +2 -0
  414. package/dist/partialLastBind.cjs.map +1 -0
  415. package/dist/partialLastBind.js +2 -0
  416. package/dist/partialLastBind.js.map +1 -0
  417. package/dist/partition.cjs +2 -0
  418. package/dist/partition.cjs.map +1 -0
  419. package/dist/partition.js +2 -0
  420. package/dist/partition.js.map +1 -0
  421. package/dist/pathOr.cjs +2 -0
  422. package/dist/pathOr.cjs.map +1 -0
  423. package/dist/pathOr.js +2 -0
  424. package/dist/pathOr.js.map +1 -0
  425. package/dist/pick.cjs +2 -0
  426. package/dist/pick.cjs.map +1 -0
  427. package/dist/pick.js +2 -0
  428. package/dist/pick.js.map +1 -0
  429. package/dist/pickBy.cjs +2 -0
  430. package/dist/pickBy.cjs.map +1 -0
  431. package/dist/pickBy.js +2 -0
  432. package/dist/pickBy.js.map +1 -0
  433. package/dist/pipe.cjs +2 -0
  434. package/dist/pipe.cjs.map +1 -0
  435. package/dist/pipe.js +2 -0
  436. package/dist/pipe.js.map +1 -0
  437. package/dist/piped.cjs +2 -0
  438. package/dist/piped.cjs.map +1 -0
  439. package/dist/piped.js +2 -0
  440. package/dist/piped.js.map +1 -0
  441. package/dist/product.cjs +2 -0
  442. package/dist/product.cjs.map +1 -0
  443. package/dist/product.js +2 -0
  444. package/dist/product.js.map +1 -0
  445. package/dist/prop.cjs +2 -0
  446. package/dist/prop.cjs.map +1 -0
  447. package/dist/prop.js +2 -0
  448. package/dist/prop.js.map +1 -0
  449. package/dist/pullObject.cjs +2 -0
  450. package/dist/pullObject.cjs.map +1 -0
  451. package/dist/pullObject.js +2 -0
  452. package/dist/pullObject.js.map +1 -0
  453. package/dist/purry.cjs +2 -0
  454. package/dist/purry.cjs.map +1 -0
  455. package/dist/purry.js +2 -0
  456. package/dist/purry.js.map +1 -0
  457. package/dist/purryFromLazy-B-_oTxzb.js +2 -0
  458. package/dist/purryFromLazy-B-_oTxzb.js.map +1 -0
  459. package/dist/purryFromLazy-CwB5T8yd.cjs +2 -0
  460. package/dist/purryFromLazy-CwB5T8yd.cjs.map +1 -0
  461. package/dist/purryOn-D4wFIFMT.js +2 -0
  462. package/dist/purryOn-D4wFIFMT.js.map +1 -0
  463. package/dist/purryOn-DdnETb-0.cjs +2 -0
  464. package/dist/purryOn-DdnETb-0.cjs.map +1 -0
  465. package/dist/purryOrderRules-4JgY6z4X.js +2 -0
  466. package/dist/purryOrderRules-4JgY6z4X.js.map +1 -0
  467. package/dist/purryOrderRules-B8pzD03D.cjs +2 -0
  468. package/dist/purryOrderRules-B8pzD03D.cjs.map +1 -0
  469. package/dist/quickSelect-B4eZ0JeB.js +2 -0
  470. package/dist/quickSelect-B4eZ0JeB.js.map +1 -0
  471. package/dist/quickSelect-BwH5h4uh.cjs +2 -0
  472. package/dist/quickSelect-BwH5h4uh.cjs.map +1 -0
  473. package/dist/randomBigInt.cjs +2 -0
  474. package/dist/randomBigInt.cjs.map +1 -0
  475. package/dist/randomBigInt.js +2 -0
  476. package/dist/randomBigInt.js.map +1 -0
  477. package/dist/randomInteger.cjs +2 -0
  478. package/dist/randomInteger.cjs.map +1 -0
  479. package/dist/randomInteger.js +2 -0
  480. package/dist/randomInteger.js.map +1 -0
  481. package/dist/randomString.cjs +2 -0
  482. package/dist/randomString.cjs.map +1 -0
  483. package/dist/randomString.js +2 -0
  484. package/dist/randomString.js.map +1 -0
  485. package/dist/range.cjs +2 -0
  486. package/dist/range.cjs.map +1 -0
  487. package/dist/range.js +2 -0
  488. package/dist/range.js.map +1 -0
  489. package/dist/rankBy.cjs +2 -0
  490. package/dist/rankBy.cjs.map +1 -0
  491. package/dist/rankBy.js +2 -0
  492. package/dist/rankBy.js.map +1 -0
  493. package/dist/reduce.cjs +2 -0
  494. package/dist/reduce.cjs.map +1 -0
  495. package/dist/reduce.js +2 -0
  496. package/dist/reduce.js.map +1 -0
  497. package/dist/reverse.cjs +2 -0
  498. package/dist/reverse.cjs.map +1 -0
  499. package/dist/reverse.js +2 -0
  500. package/dist/reverse.js.map +1 -0
  501. package/dist/round.cjs +2 -0
  502. package/dist/round.cjs.map +1 -0
  503. package/dist/round.js +2 -0
  504. package/dist/round.js.map +1 -0
  505. package/dist/sample.cjs +2 -0
  506. package/dist/sample.cjs.map +1 -0
  507. package/dist/sample.js +2 -0
  508. package/dist/sample.js.map +1 -0
  509. package/dist/set.cjs +2 -0
  510. package/dist/set.cjs.map +1 -0
  511. package/dist/set.js +2 -0
  512. package/dist/set.js.map +1 -0
  513. package/dist/setPath.cjs +2 -0
  514. package/dist/setPath.cjs.map +1 -0
  515. package/dist/setPath.js +2 -0
  516. package/dist/setPath.js.map +1 -0
  517. package/dist/shuffle.cjs +2 -0
  518. package/dist/shuffle.cjs.map +1 -0
  519. package/dist/shuffle.js +2 -0
  520. package/dist/shuffle.js.map +1 -0
  521. package/dist/sliceString.cjs +2 -0
  522. package/dist/sliceString.cjs.map +1 -0
  523. package/dist/sliceString.js +2 -0
  524. package/dist/sliceString.js.map +1 -0
  525. package/dist/sort.cjs +2 -0
  526. package/dist/sort.cjs.map +1 -0
  527. package/dist/sort.js +2 -0
  528. package/dist/sort.js.map +1 -0
  529. package/dist/sortBy.cjs +2 -0
  530. package/dist/sortBy.cjs.map +1 -0
  531. package/dist/sortBy.js +2 -0
  532. package/dist/sortBy.js.map +1 -0
  533. package/dist/sortedIndex.cjs +2 -0
  534. package/dist/sortedIndex.cjs.map +1 -0
  535. package/dist/sortedIndex.js +2 -0
  536. package/dist/sortedIndex.js.map +1 -0
  537. package/dist/sortedIndexBy.cjs +2 -0
  538. package/dist/sortedIndexBy.cjs.map +1 -0
  539. package/dist/sortedIndexBy.js +2 -0
  540. package/dist/sortedIndexBy.js.map +1 -0
  541. package/dist/sortedIndexWith.cjs +2 -0
  542. package/dist/sortedIndexWith.cjs.map +1 -0
  543. package/dist/sortedIndexWith.js +2 -0
  544. package/dist/sortedIndexWith.js.map +1 -0
  545. package/dist/sortedLastIndex.cjs +2 -0
  546. package/dist/sortedLastIndex.cjs.map +1 -0
  547. package/dist/sortedLastIndex.js +2 -0
  548. package/dist/sortedLastIndex.js.map +1 -0
  549. package/dist/sortedLastIndexBy.cjs +2 -0
  550. package/dist/sortedLastIndexBy.cjs.map +1 -0
  551. package/dist/sortedLastIndexBy.js +2 -0
  552. package/dist/sortedLastIndexBy.js.map +1 -0
  553. package/dist/splice.cjs +2 -0
  554. package/dist/splice.cjs.map +1 -0
  555. package/dist/splice.js +2 -0
  556. package/dist/splice.js.map +1 -0
  557. package/dist/split.cjs +2 -0
  558. package/dist/split.cjs.map +1 -0
  559. package/dist/split.js +2 -0
  560. package/dist/split.js.map +1 -0
  561. package/dist/splitAt.cjs +2 -0
  562. package/dist/splitAt.cjs.map +1 -0
  563. package/dist/splitAt.js +2 -0
  564. package/dist/splitAt.js.map +1 -0
  565. package/dist/splitWhen.cjs +2 -0
  566. package/dist/splitWhen.cjs.map +1 -0
  567. package/dist/splitWhen.js +2 -0
  568. package/dist/splitWhen.js.map +1 -0
  569. package/dist/startsWith.cjs +2 -0
  570. package/dist/startsWith.cjs.map +1 -0
  571. package/dist/startsWith.js +2 -0
  572. package/dist/startsWith.js.map +1 -0
  573. package/dist/stringToPath.cjs +2 -0
  574. package/dist/stringToPath.cjs.map +1 -0
  575. package/dist/stringToPath.js +2 -0
  576. package/dist/stringToPath.js.map +1 -0
  577. package/dist/subtract.cjs +2 -0
  578. package/dist/subtract.cjs.map +1 -0
  579. package/dist/subtract.js +2 -0
  580. package/dist/subtract.js.map +1 -0
  581. package/dist/sum.cjs +2 -0
  582. package/dist/sum.cjs.map +1 -0
  583. package/dist/sum.js +2 -0
  584. package/dist/sum.js.map +1 -0
  585. package/dist/sumBy.cjs +2 -0
  586. package/dist/sumBy.cjs.map +1 -0
  587. package/dist/sumBy.js +2 -0
  588. package/dist/sumBy.js.map +1 -0
  589. package/dist/swapInPlace-BrVgf3c3.js +2 -0
  590. package/dist/swapInPlace-BrVgf3c3.js.map +1 -0
  591. package/dist/swapInPlace-IOnMIay9.cjs +2 -0
  592. package/dist/swapInPlace-IOnMIay9.cjs.map +1 -0
  593. package/dist/swapIndices.cjs +2 -0
  594. package/dist/swapIndices.cjs.map +1 -0
  595. package/dist/swapIndices.js +2 -0
  596. package/dist/swapIndices.js.map +1 -0
  597. package/dist/swapProps.cjs +2 -0
  598. package/dist/swapProps.cjs.map +1 -0
  599. package/dist/swapProps.js +2 -0
  600. package/dist/swapProps.js.map +1 -0
  601. package/dist/take.cjs +2 -0
  602. package/dist/take.cjs.map +1 -0
  603. package/dist/take.js +2 -0
  604. package/dist/take.js.map +1 -0
  605. package/dist/takeFirstBy.cjs +2 -0
  606. package/dist/takeFirstBy.cjs.map +1 -0
  607. package/dist/takeFirstBy.js +2 -0
  608. package/dist/takeFirstBy.js.map +1 -0
  609. package/dist/takeLast.cjs +2 -0
  610. package/dist/takeLast.cjs.map +1 -0
  611. package/dist/takeLast.js +2 -0
  612. package/dist/takeLast.js.map +1 -0
  613. package/dist/takeLastWhile.cjs +2 -0
  614. package/dist/takeLastWhile.cjs.map +1 -0
  615. package/dist/takeLastWhile.js +2 -0
  616. package/dist/takeLastWhile.js.map +1 -0
  617. package/dist/takeWhile.cjs +2 -0
  618. package/dist/takeWhile.cjs.map +1 -0
  619. package/dist/takeWhile.js +2 -0
  620. package/dist/takeWhile.js.map +1 -0
  621. package/dist/tap.cjs +2 -0
  622. package/dist/tap.cjs.map +1 -0
  623. package/dist/tap.js +2 -0
  624. package/dist/tap.js.map +1 -0
  625. package/dist/times.cjs +2 -0
  626. package/dist/times.cjs.map +1 -0
  627. package/dist/times.js +2 -0
  628. package/dist/times.js.map +1 -0
  629. package/dist/toCamelCase.cjs +2 -0
  630. package/dist/toCamelCase.cjs.map +1 -0
  631. package/dist/toCamelCase.js +2 -0
  632. package/dist/toCamelCase.js.map +1 -0
  633. package/dist/toKebabCase.cjs +2 -0
  634. package/dist/toKebabCase.cjs.map +1 -0
  635. package/dist/toKebabCase.js +2 -0
  636. package/dist/toKebabCase.js.map +1 -0
  637. package/dist/toLowerCase.cjs +2 -0
  638. package/dist/toLowerCase.cjs.map +1 -0
  639. package/dist/toLowerCase.js +2 -0
  640. package/dist/toLowerCase.js.map +1 -0
  641. package/dist/toSingle-qs9PC5sP.js +2 -0
  642. package/dist/toSingle-qs9PC5sP.js.map +1 -0
  643. package/dist/toSingle-z9yHVHGr.cjs +2 -0
  644. package/dist/toSingle-z9yHVHGr.cjs.map +1 -0
  645. package/dist/toSnakeCase.cjs +2 -0
  646. package/dist/toSnakeCase.cjs.map +1 -0
  647. package/dist/toSnakeCase.js +2 -0
  648. package/dist/toSnakeCase.js.map +1 -0
  649. package/dist/toTitleCase.cjs +2 -0
  650. package/dist/toTitleCase.cjs.map +1 -0
  651. package/dist/toTitleCase.js +2 -0
  652. package/dist/toTitleCase.js.map +1 -0
  653. package/dist/toUpperCase.cjs +2 -0
  654. package/dist/toUpperCase.cjs.map +1 -0
  655. package/dist/toUpperCase.js +2 -0
  656. package/dist/toUpperCase.js.map +1 -0
  657. package/dist/truncate.cjs +2 -0
  658. package/dist/truncate.cjs.map +1 -0
  659. package/dist/truncate.js +2 -0
  660. package/dist/truncate.js.map +1 -0
  661. package/dist/uncapitalize.cjs +2 -0
  662. package/dist/uncapitalize.cjs.map +1 -0
  663. package/dist/uncapitalize.js +2 -0
  664. package/dist/uncapitalize.js.map +1 -0
  665. package/dist/unique.cjs +2 -0
  666. package/dist/unique.cjs.map +1 -0
  667. package/dist/unique.js +2 -0
  668. package/dist/unique.js.map +1 -0
  669. package/dist/uniqueBy.cjs +2 -0
  670. package/dist/uniqueBy.cjs.map +1 -0
  671. package/dist/uniqueBy.js +2 -0
  672. package/dist/uniqueBy.js.map +1 -0
  673. package/dist/uniqueWith.cjs +2 -0
  674. package/dist/uniqueWith.cjs.map +1 -0
  675. package/dist/uniqueWith.js +2 -0
  676. package/dist/uniqueWith.js.map +1 -0
  677. package/dist/utilityEvaluators-BQqW5Ir5.js +2 -0
  678. package/dist/utilityEvaluators-BQqW5Ir5.js.map +1 -0
  679. package/dist/utilityEvaluators-CW0M8vMV.cjs +2 -0
  680. package/dist/utilityEvaluators-CW0M8vMV.cjs.map +1 -0
  681. package/dist/values.cjs +2 -0
  682. package/dist/values.cjs.map +1 -0
  683. package/dist/values.js +2 -0
  684. package/dist/values.js.map +1 -0
  685. package/dist/when.cjs +2 -0
  686. package/dist/when.cjs.map +1 -0
  687. package/dist/when.js +2 -0
  688. package/dist/when.js.map +1 -0
  689. package/dist/withPrecision-CDZ-Oor7.js +2 -0
  690. package/dist/withPrecision-CDZ-Oor7.js.map +1 -0
  691. package/dist/withPrecision-DED4FjDo.cjs +2 -0
  692. package/dist/withPrecision-DED4FjDo.cjs.map +1 -0
  693. package/dist/words-CDCUnuNz.cjs +3 -0
  694. package/dist/words-CDCUnuNz.cjs.map +1 -0
  695. package/dist/words-Dv8LmnKC.js +3 -0
  696. package/dist/words-Dv8LmnKC.js.map +1 -0
  697. package/dist/zip.cjs +2 -0
  698. package/dist/zip.cjs.map +1 -0
  699. package/dist/zip.js +2 -0
  700. package/dist/zip.js.map +1 -0
  701. package/dist/zipWith.cjs +2 -0
  702. package/dist/zipWith.cjs.map +1 -0
  703. package/dist/zipWith.js +2 -0
  704. package/dist/zipWith.js.map +1 -0
  705. package/package.json +104 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objOf.cjs","names":["purry"],"sources":["../src/objOf.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Creates an object containing a single `key:value` pair.\n *\n * @param value - The object value.\n * @param key - The property name.\n * @signature\n * objOf(value, key)\n * @example\n * objOf(10, 'a') // => { a: 10 }\n * @category Object\n */\nexport function objOf<T, K extends string>(value: T, key: K): Record<K, T>;\n\n/**\n * Creates an object containing a single `key:value` pair.\n *\n * @param key - The property name.\n * @signature\n * objOf(key)(value)\n * @example\n * pipe(10, objOf('a')) // => { a: 10 }\n * @category Object\n */\nexport function objOf<T, K extends string>(key: K): (value: T) => Record<K, T>;\n\nexport function objOf(...args: readonly unknown[]): unknown {\n return purry(objOfImplementation, args);\n}\n\nconst objOfImplementation = <T, K extends string>(\n value: T,\n key: K,\n): Record<K, T> =>\n // @ts-expect-error [ts2322] - I'm not sure how to get the type right here...\n ({ [key]: value });\n"],"mappings":"kGA2BA,SAAgB,EAAM,GAAG,EAAmC,CAC1D,OAAOA,EAAAA,MAAM,EAAqB,EAAK,CAGzC,MAAM,GACJ,EACA,KAGC,EAAG,GAAM,EAAO"}
package/dist/objOf.js ADDED
@@ -0,0 +1,2 @@
1
+ import{purry as e}from"./purry.js";function t(...t){return e(n,t)}const n=(e,t)=>({[t]:e});export{t as objOf};
2
+ //# sourceMappingURL=objOf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objOf.js","names":[],"sources":["../src/objOf.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Creates an object containing a single `key:value` pair.\n *\n * @param value - The object value.\n * @param key - The property name.\n * @signature\n * objOf(value, key)\n * @example\n * objOf(10, 'a') // => { a: 10 }\n * @category Object\n */\nexport function objOf<T, K extends string>(value: T, key: K): Record<K, T>;\n\n/**\n * Creates an object containing a single `key:value` pair.\n *\n * @param key - The property name.\n * @signature\n * objOf(key)(value)\n * @example\n * pipe(10, objOf('a')) // => { a: 10 }\n * @category Object\n */\nexport function objOf<T, K extends string>(key: K): (value: T) => Record<K, T>;\n\nexport function objOf(...args: readonly unknown[]): unknown {\n return purry(objOfImplementation, args);\n}\n\nconst objOfImplementation = <T, K extends string>(\n value: T,\n key: K,\n): Record<K, T> =>\n // @ts-expect-error [ts2322] - I'm not sure how to get the type right here...\n ({ [key]: value });\n"],"mappings":"mCA2BA,SAAgB,EAAM,GAAG,EAAmC,CAC1D,OAAO,EAAM,EAAqB,EAAK,CAGzC,MAAM,GACJ,EACA,KAGC,EAAG,GAAM,EAAO"}
package/dist/omit.cjs ADDED
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`),t=require(`./hasAtLeast.cjs`);function n(...t){return e.purry(r,t)}function r(e,n){if(!t.hasAtLeast(n,1))return{...e};if(!t.hasAtLeast(n,2)){let{[n[0]]:t,...r}=e;return r}let r={...e};for(let e of n)delete r[e];return r}exports.omit=n;
2
+ //# sourceMappingURL=omit.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"omit.cjs","names":["purry","hasAtLeast"],"sources":["../src/omit.ts"],"sourcesContent":["import type { EmptyObject, IsNever, KeysOfUnion } from \"type-fest\";\nimport { hasAtLeast } from \"./hasAtLeast\";\nimport type { IsBounded } from \"./internal/types/IsBounded\";\nimport type { IsBoundedRecord } from \"./internal/types/IsBoundedRecord\";\nimport type { PartitionByUnion } from \"./internal/types/PartitionByUnion\";\nimport type { SimplifiedWritable } from \"./internal/types/SimplifiedWritable\";\nimport type { TupleParts } from \"./internal/types/TupleParts\";\nimport { purry } from \"./purry\";\n\ntype OmitFromArray<T, Keys extends readonly PropertyKey[]> =\n // Distribute unions for both object types and key arrays.\n T extends unknown\n ? Keys extends unknown\n ? // The output is always writable because we always create a new object!\n SimplifiedWritable<\n IsNever<Extract<Keys[number], keyof T>> extends true\n ? // When none of the keys belong to T we can short-circuit and\n // simply return T as-is because `omit` would do nothing.\n T\n : IsBoundedRecord<T> extends true\n ? OmitBounded<T, Keys>\n : OmitUnbounded<T, Keys>\n >\n : never\n : never;\n\ntype OmitBounded<T, Keys extends readonly PropertyKey[]> =\n // We build our output by first considering any key present in the keys array\n // as being omitted. This object would contain all keys that are unaffected at\n // all by this omit operation.\n FixEmpty<Omit<T, Keys[number]>> &\n // But we might be missing keys that are optional in the keys tuple (and\n // thus might not be removed). Because these keys are optional, their props\n // in the output also need to be optional.\n Partial<\n Pick<\n T,\n Exclude<\n // Find all keys that can either be omitted or not, these are all keys\n // in unions in the required parts of the keys tuple (the prefix and\n // the suffix), as well as all keys in the optional parts and the rest\n // item.\n | PartitionByUnion<TupleParts<Keys>[\"required\"]>[\"union\"]\n | TupleParts<Keys>[\"optional\"][number]\n | TupleParts<Keys>[\"item\"]\n | PartitionByUnion<TupleParts<Keys>[\"suffix\"]>[\"union\"],\n // We then need to remove from these any items which *also* are\n // ensured to always exist in the keys tuple, these are the elements\n // of the required parts of the tuple which are singular (not unions).\n | PartitionByUnion<TupleParts<Keys>[\"required\"]>[\"singular\"]\n | PartitionByUnion<TupleParts<Keys>[\"suffix\"]>[\"singular\"]\n >\n >\n >;\n\n/**\n * The built-in `Omit` type doesn't handle unbounded records correctly! When\n * omitting an unbounded key the result should be untouched as we can't tell\n * what got removed, and can't represent an object that had \"something\" removed\n * from it, but instead it returns `{}`(?!) The same thing applies when a key\n * is only optionally omitted for the same reasons. This is why we don't use\n * `Omit` at all for the unbounded case.\n *\n * @see https://www.typescriptlang.org/play/?#code/C4TwDgpgBAqgdgIwPYFc4BMLqgXigeQFsBLYAHgCUIBjJAJ3TIGdg7i4BzAGigCIALCABshSXgD4eLNp3EBuAFAB6JVDUA9APxA\n */\ntype OmitUnbounded<T, Keys extends readonly PropertyKey[]> = T &\n // Any key we know for sure is being omitted needs to become \"impossible\" to\n // access; for an unbounded record this means merging it with a bounded record\n // with `never` value for these keys.\n Record<\n Bounded<\n | PartitionByUnion<TupleParts<Keys>[\"required\"]>[\"singular\"]\n | PartitionByUnion<TupleParts<Keys>[\"suffix\"]>[\"singular\"]\n >,\n never\n >;\n\n/**\n * When `Omit` omits **all** keys from a bounded record it results in `{}` which\n * doesn't match what we'd expect to be returned in terms of a useful type as\n * the output of `Omit`.\n */\ntype FixEmpty<T> = IsNever<keyof T> extends true ? EmptyObject : T;\n\n/**\n * Filter a union of types, leaving only those that are bounded. e.g.,\n * `Bounded<\"a\" | number>` results in `\"a\"`.\n */\ntype Bounded<T> = T extends unknown\n ? IsBounded<T> extends true\n ? T\n : never\n : never;\n\n/**\n * Returns a partial copy of an object omitting the keys specified.\n *\n * @param keys - The property names.\n * @signature\n * omit(keys)(obj);\n * @example\n * pipe({ a: 1, b: 2, c: 3, d: 4 }, omit(['a', 'd'])) // => { b: 2, c: 3 }\n * @dataLast\n * @category Object\n */\nexport function omit<T, const Keys extends readonly KeysOfUnion<T>[]>(\n keys: Keys,\n): (data: T) => OmitFromArray<T, Keys>;\n\n/**\n * Returns a partial copy of an object omitting the keys specified.\n *\n * @param data - The object.\n * @param keys - The property names.\n * @signature\n * omit(obj, keys);\n * @example\n * omit({ a: 1, b: 2, c: 3, d: 4 }, ['a', 'd']) // => { b: 2, c: 3 }\n * @dataFirst\n * @category Object\n */\nexport function omit<T, const Keys extends readonly KeysOfUnion<T>[]>(\n data: T,\n keys: Keys,\n): OmitFromArray<T, Keys>;\n\nexport function omit(...args: readonly unknown[]): unknown {\n return purry(omitImplementation, args);\n}\n\nfunction omitImplementation<\n T extends object,\n Keys extends readonly (keyof T)[],\n>(data: T, keys: Keys): OmitFromArray<T, Keys> {\n if (!hasAtLeast(keys, 1)) {\n // No props to omit at all!\n // @ts-expect-error [ts2322] - TypeScript can't connect the fact that the\n // keys array is empty and infer the expected output, and then infer that we\n // return it correctly here.\n return { ...data };\n }\n\n if (!hasAtLeast(keys, 2)) {\n // Only one prop to omit so we can let the runtime engine deal with\n // removing it efficiently.\n const { [keys[0]]: _omitted, ...remaining } = data;\n\n // @ts-expect-error [ts2322] - TypeScript can't compute the expected output\n // correctly and then infer that we return it correctly here.\n return remaining;\n }\n\n // Multiple props to omit so we have to use a loop to omit all of them.\n const out = { ...data };\n for (const key of keys) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete -- This is intentional! It is the most effective way to allow the runtime engine to optimize the object without creating excessive copies for every omitted key.\n delete out[key];\n }\n\n // @ts-expect-error [ts2322] - The type is too complex and TypeScript can't\n // \"follow\" the iterative algorithm to ensure the output makes sense.\n return out;\n}\n"],"mappings":"gIA8HA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAOA,EAAAA,MAAM,EAAoB,EAAK,CAGxC,SAAS,EAGP,EAAS,EAAoC,CAC7C,GAAI,CAACC,EAAAA,WAAW,EAAM,EAAE,CAKtB,MAAO,CAAE,GAAG,EAAM,CAGpB,GAAI,CAACA,EAAAA,WAAW,EAAM,EAAE,CAAE,CAGxB,GAAM,EAAG,EAAK,IAAK,EAAU,GAAG,GAAc,EAI9C,OAAO,EAIT,IAAM,EAAM,CAAE,GAAG,EAAM,CACvB,IAAK,IAAM,KAAO,EAEhB,OAAO,EAAI,GAKb,OAAO"}
package/dist/omit.js ADDED
@@ -0,0 +1,2 @@
1
+ import{purry as e}from"./purry.js";import{hasAtLeast as t}from"./hasAtLeast.js";function n(...t){return e(r,t)}function r(e,n){if(!t(n,1))return{...e};if(!t(n,2)){let{[n[0]]:t,...r}=e;return r}let r={...e};for(let e of n)delete r[e];return r}export{n as omit};
2
+ //# sourceMappingURL=omit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"omit.js","names":[],"sources":["../src/omit.ts"],"sourcesContent":["import type { EmptyObject, IsNever, KeysOfUnion } from \"type-fest\";\nimport { hasAtLeast } from \"./hasAtLeast\";\nimport type { IsBounded } from \"./internal/types/IsBounded\";\nimport type { IsBoundedRecord } from \"./internal/types/IsBoundedRecord\";\nimport type { PartitionByUnion } from \"./internal/types/PartitionByUnion\";\nimport type { SimplifiedWritable } from \"./internal/types/SimplifiedWritable\";\nimport type { TupleParts } from \"./internal/types/TupleParts\";\nimport { purry } from \"./purry\";\n\ntype OmitFromArray<T, Keys extends readonly PropertyKey[]> =\n // Distribute unions for both object types and key arrays.\n T extends unknown\n ? Keys extends unknown\n ? // The output is always writable because we always create a new object!\n SimplifiedWritable<\n IsNever<Extract<Keys[number], keyof T>> extends true\n ? // When none of the keys belong to T we can short-circuit and\n // simply return T as-is because `omit` would do nothing.\n T\n : IsBoundedRecord<T> extends true\n ? OmitBounded<T, Keys>\n : OmitUnbounded<T, Keys>\n >\n : never\n : never;\n\ntype OmitBounded<T, Keys extends readonly PropertyKey[]> =\n // We build our output by first considering any key present in the keys array\n // as being omitted. This object would contain all keys that are unaffected at\n // all by this omit operation.\n FixEmpty<Omit<T, Keys[number]>> &\n // But we might be missing keys that are optional in the keys tuple (and\n // thus might not be removed). Because these keys are optional, their props\n // in the output also need to be optional.\n Partial<\n Pick<\n T,\n Exclude<\n // Find all keys that can either be omitted or not, these are all keys\n // in unions in the required parts of the keys tuple (the prefix and\n // the suffix), as well as all keys in the optional parts and the rest\n // item.\n | PartitionByUnion<TupleParts<Keys>[\"required\"]>[\"union\"]\n | TupleParts<Keys>[\"optional\"][number]\n | TupleParts<Keys>[\"item\"]\n | PartitionByUnion<TupleParts<Keys>[\"suffix\"]>[\"union\"],\n // We then need to remove from these any items which *also* are\n // ensured to always exist in the keys tuple, these are the elements\n // of the required parts of the tuple which are singular (not unions).\n | PartitionByUnion<TupleParts<Keys>[\"required\"]>[\"singular\"]\n | PartitionByUnion<TupleParts<Keys>[\"suffix\"]>[\"singular\"]\n >\n >\n >;\n\n/**\n * The built-in `Omit` type doesn't handle unbounded records correctly! When\n * omitting an unbounded key the result should be untouched as we can't tell\n * what got removed, and can't represent an object that had \"something\" removed\n * from it, but instead it returns `{}`(?!) The same thing applies when a key\n * is only optionally omitted for the same reasons. This is why we don't use\n * `Omit` at all for the unbounded case.\n *\n * @see https://www.typescriptlang.org/play/?#code/C4TwDgpgBAqgdgIwPYFc4BMLqgXigeQFsBLYAHgCUIBjJAJ3TIGdg7i4BzAGigCIALCABshSXgD4eLNp3EBuAFAB6JVDUA9APxA\n */\ntype OmitUnbounded<T, Keys extends readonly PropertyKey[]> = T &\n // Any key we know for sure is being omitted needs to become \"impossible\" to\n // access; for an unbounded record this means merging it with a bounded record\n // with `never` value for these keys.\n Record<\n Bounded<\n | PartitionByUnion<TupleParts<Keys>[\"required\"]>[\"singular\"]\n | PartitionByUnion<TupleParts<Keys>[\"suffix\"]>[\"singular\"]\n >,\n never\n >;\n\n/**\n * When `Omit` omits **all** keys from a bounded record it results in `{}` which\n * doesn't match what we'd expect to be returned in terms of a useful type as\n * the output of `Omit`.\n */\ntype FixEmpty<T> = IsNever<keyof T> extends true ? EmptyObject : T;\n\n/**\n * Filter a union of types, leaving only those that are bounded. e.g.,\n * `Bounded<\"a\" | number>` results in `\"a\"`.\n */\ntype Bounded<T> = T extends unknown\n ? IsBounded<T> extends true\n ? T\n : never\n : never;\n\n/**\n * Returns a partial copy of an object omitting the keys specified.\n *\n * @param keys - The property names.\n * @signature\n * omit(keys)(obj);\n * @example\n * pipe({ a: 1, b: 2, c: 3, d: 4 }, omit(['a', 'd'])) // => { b: 2, c: 3 }\n * @dataLast\n * @category Object\n */\nexport function omit<T, const Keys extends readonly KeysOfUnion<T>[]>(\n keys: Keys,\n): (data: T) => OmitFromArray<T, Keys>;\n\n/**\n * Returns a partial copy of an object omitting the keys specified.\n *\n * @param data - The object.\n * @param keys - The property names.\n * @signature\n * omit(obj, keys);\n * @example\n * omit({ a: 1, b: 2, c: 3, d: 4 }, ['a', 'd']) // => { b: 2, c: 3 }\n * @dataFirst\n * @category Object\n */\nexport function omit<T, const Keys extends readonly KeysOfUnion<T>[]>(\n data: T,\n keys: Keys,\n): OmitFromArray<T, Keys>;\n\nexport function omit(...args: readonly unknown[]): unknown {\n return purry(omitImplementation, args);\n}\n\nfunction omitImplementation<\n T extends object,\n Keys extends readonly (keyof T)[],\n>(data: T, keys: Keys): OmitFromArray<T, Keys> {\n if (!hasAtLeast(keys, 1)) {\n // No props to omit at all!\n // @ts-expect-error [ts2322] - TypeScript can't connect the fact that the\n // keys array is empty and infer the expected output, and then infer that we\n // return it correctly here.\n return { ...data };\n }\n\n if (!hasAtLeast(keys, 2)) {\n // Only one prop to omit so we can let the runtime engine deal with\n // removing it efficiently.\n const { [keys[0]]: _omitted, ...remaining } = data;\n\n // @ts-expect-error [ts2322] - TypeScript can't compute the expected output\n // correctly and then infer that we return it correctly here.\n return remaining;\n }\n\n // Multiple props to omit so we have to use a loop to omit all of them.\n const out = { ...data };\n for (const key of keys) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete -- This is intentional! It is the most effective way to allow the runtime engine to optimize the object without creating excessive copies for every omitted key.\n delete out[key];\n }\n\n // @ts-expect-error [ts2322] - The type is too complex and TypeScript can't\n // \"follow\" the iterative algorithm to ensure the output makes sense.\n return out;\n}\n"],"mappings":"gFA8HA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAO,EAAM,EAAoB,EAAK,CAGxC,SAAS,EAGP,EAAS,EAAoC,CAC7C,GAAI,CAAC,EAAW,EAAM,EAAE,CAKtB,MAAO,CAAE,GAAG,EAAM,CAGpB,GAAI,CAAC,EAAW,EAAM,EAAE,CAAE,CAGxB,GAAM,EAAG,EAAK,IAAK,EAAU,GAAG,GAAc,EAI9C,OAAO,EAIT,IAAM,EAAM,CAAE,GAAG,EAAM,CACvB,IAAK,IAAM,KAAO,EAEhB,OAAO,EAAI,GAKb,OAAO"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`);function t(...t){return e.purry(n,t)}function n(e,t){let n={...e};for(let[r,i]of Object.entries(n))t(i,r,e)&&delete n[r];return n}exports.omitBy=t;
2
+ //# sourceMappingURL=omitBy.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"omitBy.cjs","names":["purry"],"sources":["../src/omitBy.ts"],"sourcesContent":["import type { IsNever, Or, Simplify } from \"type-fest\";\nimport type { EnumerableStringKeyOf } from \"./internal/types/EnumerableStringKeyOf\";\nimport type { EnumerableStringKeyedValueOf } from \"./internal/types/EnumerableStringKeyedValueOf\";\nimport type { IsBoundedRecord } from \"./internal/types/IsBoundedRecord\";\nimport { purry } from \"./purry\";\n\n// Symbols are not passed to the predicate (because they can't be enumerated\n// with the `Object.entries` function) and the output object is built from a\n// shallow copy of the input; meaning symbols would just be passed through as-\n// is.\ntype PickSymbolKeys<T extends object> = {\n -readonly [P in keyof T as P extends symbol ? P : never]: T[P];\n};\n\n// When we don't use a type-predicate we can't say anything about what props\n// would be omitted from the output, so we need to assume any of them could be\n// filtered out. This means that we effectively make all (enumerable) keys\n// optional.\ntype PartialEnumerableKeys<T extends object> =\n // `extends unknown` is always going to be the case and is used to convert any\n // union into a [distributive conditional type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).\n T extends unknown\n ? Simplify<\n IsBoundedRecord<T> extends true\n ? PickSymbolKeys<T> & {\n -readonly [P in keyof T as P extends symbol\n ? never\n : P]?: Required<T>[P];\n }\n : // This is the type you'd get from doing:\n // `Object.fromEntries(Object.entries(x))`.\n Record<EnumerableStringKeyOf<T>, EnumerableStringKeyedValueOf<T>>\n >\n : never;\n\n// When the predicate is a type-guard we have more information to work with when\n// constructing the type of the output object. We can safely remove any property\n// which value would always be true for the predicate, AND we can also\n// assume that properties that are rejected by the predicate perfectly would\n// **always** show up in the output object. Hence to build the output object we\n// need to build and merge 2 output objects: One for the properties which have a\n// value of at type that would always yield a `false` result from the predicate,\n// these are the \"matches\", which would not change the \"optionality\" of the\n// input object's props, and one for partial matches which would also make the\n// props optional (as they could have a value that would be filtered out).\ntype PartialEnumerableKeysNarrowed<T extends object, S> = Simplify<\n ExactProps<T, S> & PartialProps<T, S> & PickSymbolKeys<T>\n>;\n\n// The exact case, props here would always be part of the output object\ntype ExactProps<T, S> = {\n -readonly [P in keyof T as IsExactProp<T, P, S> extends true\n ? P\n : never]: Exclude<T[P], S>;\n};\n\n// The partial case, props here might be part of the output object, but might\n// not be, hence they are optional.\ntype PartialProps<T, S> = {\n -readonly [P in keyof T as IsPartialProp<T, P, S> extends true\n ? P\n : never]?: Exclude<T[P], S>;\n};\n\n// If the input object's value type extends itself when the type-guard is\n// excluded from it we can safely assume that the predicate would always return\n// `false` for any value of that property.\ntype IsExactProp<T, P extends keyof T, S> = P extends symbol\n ? // Symbols are passed through via the PickSymbolKeys type\n false\n : T[P] extends Exclude<T[P], S>\n ? S extends T[P]\n ? // If S extends the T[P] it means the type the predicate is narrowing to\n // can't narrow the rejected value any further, so we can't say what\n // would happen for a concrete value in runtime (e.g. if T[P] is\n // `number` and S is `1`: `Exclude<number, 1> === number`.\n false\n : true\n : false;\n\n// ...and if the input object's value type isn't an exact match, but still has\n// some partial match (i.g. the extracted type-guard isn't completely disjoint)\n// then we can assume that the property can sometimes return true, and sometimes\n// false when passed to the predicate, hence it should be optional in the\n// output.\ntype IsPartialProp<T, P extends keyof T, S> = P extends symbol\n ? // Symbols are passed through via the PickSymbolKeys type\n false\n : Or<IsExactProp<T, P, S>, IsNever<Exclude<Required<T>[P], S>>> extends true\n ? false\n : true;\n\n/**\n * Creates a shallow copy of the data, and then removes any keys that the\n * predicate rejects. Symbol keys are not passed to the predicate and would be\n * passed through to the output as-is.\n *\n * See `pickBy` for a complementary function which starts with an empty object\n * and adds the entries that the predicate accepts. Because it is additive,\n * symbol keys will not be passed through to the output object.\n *\n * @param data - The target object.\n * @param predicate - A function that takes the value, key, and the data itself\n * and returns `true` if the entry shouldn't be part of the output object, or\n * `false` to keep it. If the function is a type-guard on the value the output\n * type would be narrowed accordingly.\n * @returns A shallow copy of the input object with the rejected entries\n * removed.\n * @signature omitBy(data, predicate)\n * @example\n * omitBy({a: 1, b: 2, A: 3, B: 4}, (val, key) => key.toUpperCase() === key) // => {a: 1, b: 2}\n * @dataFirst\n * @category Object\n */\nexport function omitBy<\n T extends object,\n S extends EnumerableStringKeyedValueOf<T>,\n>(\n data: T,\n predicate: (\n value: EnumerableStringKeyedValueOf<T>,\n key: EnumerableStringKeyOf<T>,\n data: T,\n ) => value is S,\n): PartialEnumerableKeysNarrowed<T, S>;\nexport function omitBy<T extends object>(\n data: T,\n predicate: (\n value: EnumerableStringKeyedValueOf<T>,\n key: EnumerableStringKeyOf<T>,\n data: T,\n ) => boolean,\n): PartialEnumerableKeys<T>;\n\n/**\n * Returns a partial copy of an object omitting the keys matching predicate.\n *\n * @param predicate - The predicate.\n * @signature omitBy(fn)(object)\n * @example\n * omitBy((val, key) => key.toUpperCase() === key)({a: 1, b: 2, A: 3, B: 4}) // => {a: 1, b: 2}\n * @dataLast\n * @category Object\n */\nexport function omitBy<\n T extends object,\n S extends EnumerableStringKeyedValueOf<T>,\n>(\n predicate: (\n value: EnumerableStringKeyedValueOf<T>,\n key: EnumerableStringKeyOf<T>,\n data: T,\n ) => value is S,\n): (data: T) => PartialEnumerableKeysNarrowed<T, S>;\nexport function omitBy<T extends object>(\n predicate: (\n value: EnumerableStringKeyedValueOf<T>,\n key: EnumerableStringKeyOf<T>,\n data: T,\n ) => boolean,\n): (data: T) => PartialEnumerableKeys<T>;\n\nexport function omitBy(...args: readonly unknown[]): unknown {\n return purry(omitByImplementation, args);\n}\n\nfunction omitByImplementation<T extends object>(\n data: T,\n predicate: (value: unknown, key: string, data: T) => boolean,\n): Record<string, unknown> {\n const out: Partial<Record<string, unknown>> = { ...data };\n\n for (const [key, value] of Object.entries(out)) {\n if (predicate(value, key, data)) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete -- This is the best way to do it!\n delete out[key];\n }\n }\n\n return out;\n}\n"],"mappings":"kGAkKA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAOA,EAAAA,MAAM,EAAsB,EAAK,CAG1C,SAAS,EACP,EACA,EACyB,CACzB,IAAM,EAAwC,CAAE,GAAG,EAAM,CAEzD,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAI,CACxC,EAAU,EAAO,EAAK,EAAK,EAE7B,OAAO,EAAI,GAIf,OAAO"}
package/dist/omitBy.js ADDED
@@ -0,0 +1,2 @@
1
+ import{purry as e}from"./purry.js";function t(...t){return e(n,t)}function n(e,t){let n={...e};for(let[r,i]of Object.entries(n))t(i,r,e)&&delete n[r];return n}export{t as omitBy};
2
+ //# sourceMappingURL=omitBy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"omitBy.js","names":[],"sources":["../src/omitBy.ts"],"sourcesContent":["import type { IsNever, Or, Simplify } from \"type-fest\";\nimport type { EnumerableStringKeyOf } from \"./internal/types/EnumerableStringKeyOf\";\nimport type { EnumerableStringKeyedValueOf } from \"./internal/types/EnumerableStringKeyedValueOf\";\nimport type { IsBoundedRecord } from \"./internal/types/IsBoundedRecord\";\nimport { purry } from \"./purry\";\n\n// Symbols are not passed to the predicate (because they can't be enumerated\n// with the `Object.entries` function) and the output object is built from a\n// shallow copy of the input; meaning symbols would just be passed through as-\n// is.\ntype PickSymbolKeys<T extends object> = {\n -readonly [P in keyof T as P extends symbol ? P : never]: T[P];\n};\n\n// When we don't use a type-predicate we can't say anything about what props\n// would be omitted from the output, so we need to assume any of them could be\n// filtered out. This means that we effectively make all (enumerable) keys\n// optional.\ntype PartialEnumerableKeys<T extends object> =\n // `extends unknown` is always going to be the case and is used to convert any\n // union into a [distributive conditional type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).\n T extends unknown\n ? Simplify<\n IsBoundedRecord<T> extends true\n ? PickSymbolKeys<T> & {\n -readonly [P in keyof T as P extends symbol\n ? never\n : P]?: Required<T>[P];\n }\n : // This is the type you'd get from doing:\n // `Object.fromEntries(Object.entries(x))`.\n Record<EnumerableStringKeyOf<T>, EnumerableStringKeyedValueOf<T>>\n >\n : never;\n\n// When the predicate is a type-guard we have more information to work with when\n// constructing the type of the output object. We can safely remove any property\n// which value would always be true for the predicate, AND we can also\n// assume that properties that are rejected by the predicate perfectly would\n// **always** show up in the output object. Hence to build the output object we\n// need to build and merge 2 output objects: One for the properties which have a\n// value of at type that would always yield a `false` result from the predicate,\n// these are the \"matches\", which would not change the \"optionality\" of the\n// input object's props, and one for partial matches which would also make the\n// props optional (as they could have a value that would be filtered out).\ntype PartialEnumerableKeysNarrowed<T extends object, S> = Simplify<\n ExactProps<T, S> & PartialProps<T, S> & PickSymbolKeys<T>\n>;\n\n// The exact case, props here would always be part of the output object\ntype ExactProps<T, S> = {\n -readonly [P in keyof T as IsExactProp<T, P, S> extends true\n ? P\n : never]: Exclude<T[P], S>;\n};\n\n// The partial case, props here might be part of the output object, but might\n// not be, hence they are optional.\ntype PartialProps<T, S> = {\n -readonly [P in keyof T as IsPartialProp<T, P, S> extends true\n ? P\n : never]?: Exclude<T[P], S>;\n};\n\n// If the input object's value type extends itself when the type-guard is\n// excluded from it we can safely assume that the predicate would always return\n// `false` for any value of that property.\ntype IsExactProp<T, P extends keyof T, S> = P extends symbol\n ? // Symbols are passed through via the PickSymbolKeys type\n false\n : T[P] extends Exclude<T[P], S>\n ? S extends T[P]\n ? // If S extends the T[P] it means the type the predicate is narrowing to\n // can't narrow the rejected value any further, so we can't say what\n // would happen for a concrete value in runtime (e.g. if T[P] is\n // `number` and S is `1`: `Exclude<number, 1> === number`.\n false\n : true\n : false;\n\n// ...and if the input object's value type isn't an exact match, but still has\n// some partial match (i.g. the extracted type-guard isn't completely disjoint)\n// then we can assume that the property can sometimes return true, and sometimes\n// false when passed to the predicate, hence it should be optional in the\n// output.\ntype IsPartialProp<T, P extends keyof T, S> = P extends symbol\n ? // Symbols are passed through via the PickSymbolKeys type\n false\n : Or<IsExactProp<T, P, S>, IsNever<Exclude<Required<T>[P], S>>> extends true\n ? false\n : true;\n\n/**\n * Creates a shallow copy of the data, and then removes any keys that the\n * predicate rejects. Symbol keys are not passed to the predicate and would be\n * passed through to the output as-is.\n *\n * See `pickBy` for a complementary function which starts with an empty object\n * and adds the entries that the predicate accepts. Because it is additive,\n * symbol keys will not be passed through to the output object.\n *\n * @param data - The target object.\n * @param predicate - A function that takes the value, key, and the data itself\n * and returns `true` if the entry shouldn't be part of the output object, or\n * `false` to keep it. If the function is a type-guard on the value the output\n * type would be narrowed accordingly.\n * @returns A shallow copy of the input object with the rejected entries\n * removed.\n * @signature omitBy(data, predicate)\n * @example\n * omitBy({a: 1, b: 2, A: 3, B: 4}, (val, key) => key.toUpperCase() === key) // => {a: 1, b: 2}\n * @dataFirst\n * @category Object\n */\nexport function omitBy<\n T extends object,\n S extends EnumerableStringKeyedValueOf<T>,\n>(\n data: T,\n predicate: (\n value: EnumerableStringKeyedValueOf<T>,\n key: EnumerableStringKeyOf<T>,\n data: T,\n ) => value is S,\n): PartialEnumerableKeysNarrowed<T, S>;\nexport function omitBy<T extends object>(\n data: T,\n predicate: (\n value: EnumerableStringKeyedValueOf<T>,\n key: EnumerableStringKeyOf<T>,\n data: T,\n ) => boolean,\n): PartialEnumerableKeys<T>;\n\n/**\n * Returns a partial copy of an object omitting the keys matching predicate.\n *\n * @param predicate - The predicate.\n * @signature omitBy(fn)(object)\n * @example\n * omitBy((val, key) => key.toUpperCase() === key)({a: 1, b: 2, A: 3, B: 4}) // => {a: 1, b: 2}\n * @dataLast\n * @category Object\n */\nexport function omitBy<\n T extends object,\n S extends EnumerableStringKeyedValueOf<T>,\n>(\n predicate: (\n value: EnumerableStringKeyedValueOf<T>,\n key: EnumerableStringKeyOf<T>,\n data: T,\n ) => value is S,\n): (data: T) => PartialEnumerableKeysNarrowed<T, S>;\nexport function omitBy<T extends object>(\n predicate: (\n value: EnumerableStringKeyedValueOf<T>,\n key: EnumerableStringKeyOf<T>,\n data: T,\n ) => boolean,\n): (data: T) => PartialEnumerableKeys<T>;\n\nexport function omitBy(...args: readonly unknown[]): unknown {\n return purry(omitByImplementation, args);\n}\n\nfunction omitByImplementation<T extends object>(\n data: T,\n predicate: (value: unknown, key: string, data: T) => boolean,\n): Record<string, unknown> {\n const out: Partial<Record<string, unknown>> = { ...data };\n\n for (const [key, value] of Object.entries(out)) {\n if (predicate(value, key, data)) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete -- This is the best way to do it!\n delete out[key];\n }\n }\n\n return out;\n}\n"],"mappings":"mCAkKA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAO,EAAM,EAAsB,EAAK,CAG1C,SAAS,EACP,EACA,EACyB,CACzB,IAAM,EAAwC,CAAE,GAAG,EAAM,CAEzD,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAI,CACxC,EAAU,EAAO,EAAK,EAAK,EAE7B,OAAO,EAAI,GAIf,OAAO"}
package/dist/once.cjs ADDED
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){let t=!1,n;return()=>(t||=(n=e(),!0),n)}exports.once=e;
2
+ //# sourceMappingURL=once.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"once.cjs","names":[],"sources":["../src/once.ts"],"sourcesContent":["/**\n * Creates a function that is restricted to invoking `func` once. Repeat calls to the function return the value of the first invocation.\n *\n * @param fn - The function to wrap.\n * @signature once(fn)\n * @example\n * const initialize = once(createApplication);\n * initialize();\n * initialize();\n * // => `createApplication` is invoked once\n * @category Function\n */\nexport function once<T>(fn: () => T): () => T {\n let called = false;\n let ret: T;\n return () => {\n if (!called) {\n ret = fn();\n called = true;\n }\n return ret;\n };\n}\n"],"mappings":"mEAYA,SAAgB,EAAQ,EAAsB,CAC5C,IAAI,EAAS,GACT,EACJ,WACE,AAEE,KADA,EAAM,GAAI,CACD,IAEJ"}
package/dist/once.js ADDED
@@ -0,0 +1,2 @@
1
+ function e(e){let t=!1,n;return()=>(t||=(n=e(),!0),n)}export{e as once};
2
+ //# sourceMappingURL=once.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"once.js","names":[],"sources":["../src/once.ts"],"sourcesContent":["/**\n * Creates a function that is restricted to invoking `func` once. Repeat calls to the function return the value of the first invocation.\n *\n * @param fn - The function to wrap.\n * @signature once(fn)\n * @example\n * const initialize = once(createApplication);\n * initialize();\n * initialize();\n * // => `createApplication` is invoked once\n * @category Function\n */\nexport function once<T>(fn: () => T): () => T {\n let called = false;\n let ret: T;\n return () => {\n if (!called) {\n ret = fn();\n called = true;\n }\n return ret;\n };\n}\n"],"mappings":"AAYA,SAAgB,EAAQ,EAAsB,CAC5C,IAAI,EAAS,GACT,EACJ,WACE,AAEE,KADA,EAAM,GAAI,CACD,IAEJ"}
package/dist/only.cjs ADDED
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`);function t(...t){return e.purry(n,t)}const n=e=>e.length===1?e[0]:void 0;exports.only=t;
2
+ //# sourceMappingURL=only.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"only.cjs","names":["purry"],"sources":["../src/only.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\ntype Only<T extends IterableContainer> = T extends\n | readonly [...unknown[], unknown, unknown]\n | readonly []\n | readonly [unknown, ...unknown[], unknown]\n | readonly [unknown, unknown, ...unknown[]]\n ? undefined\n : T extends readonly [unknown]\n ? T[number]\n : T[number] | undefined;\n\n/**\n * Returns the first and only element of `array`, or undefined otherwise.\n *\n * @param array - The target array.\n * @signature\n * only(array)\n * @example\n * only([]) // => undefined\n * only([1]) // => 1\n * only([1, 2]) // => undefined\n * @dataFirst\n * @category Array\n */\nexport function only<T extends IterableContainer>(array: Readonly<T>): Only<T>;\n\n/**\n * Returns the first and only element of `array`, or undefined otherwise.\n *\n * @signature\n * only()(array)\n * @example\n * pipe([], only()); // => undefined\n * pipe([1], only()); // => 1\n * pipe([1, 2], only()); // => undefined\n * @dataLast\n * @category Array\n */\nexport function only<T extends IterableContainer>(): (\n array: Readonly<T>,\n) => Only<T>;\n\nexport function only(...args: readonly unknown[]): unknown {\n return purry(onlyImplementation, args);\n}\n\nconst onlyImplementation = <T>(array: readonly T[]): T | undefined =>\n array.length === 1 ? array[0] : undefined;\n"],"mappings":"kGA4CA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAOA,EAAAA,MAAM,EAAoB,EAAK,CAGxC,MAAM,EAAyB,GAC7B,EAAM,SAAW,EAAI,EAAM,GAAK,IAAA"}
package/dist/only.js ADDED
@@ -0,0 +1,2 @@
1
+ import{purry as e}from"./purry.js";function t(...t){return e(n,t)}const n=e=>e.length===1?e[0]:void 0;export{t as only};
2
+ //# sourceMappingURL=only.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"only.js","names":[],"sources":["../src/only.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\ntype Only<T extends IterableContainer> = T extends\n | readonly [...unknown[], unknown, unknown]\n | readonly []\n | readonly [unknown, ...unknown[], unknown]\n | readonly [unknown, unknown, ...unknown[]]\n ? undefined\n : T extends readonly [unknown]\n ? T[number]\n : T[number] | undefined;\n\n/**\n * Returns the first and only element of `array`, or undefined otherwise.\n *\n * @param array - The target array.\n * @signature\n * only(array)\n * @example\n * only([]) // => undefined\n * only([1]) // => 1\n * only([1, 2]) // => undefined\n * @dataFirst\n * @category Array\n */\nexport function only<T extends IterableContainer>(array: Readonly<T>): Only<T>;\n\n/**\n * Returns the first and only element of `array`, or undefined otherwise.\n *\n * @signature\n * only()(array)\n * @example\n * pipe([], only()); // => undefined\n * pipe([1], only()); // => 1\n * pipe([1, 2], only()); // => undefined\n * @dataLast\n * @category Array\n */\nexport function only<T extends IterableContainer>(): (\n array: Readonly<T>,\n) => Only<T>;\n\nexport function only(...args: readonly unknown[]): unknown {\n return purry(onlyImplementation, args);\n}\n\nconst onlyImplementation = <T>(array: readonly T[]): T | undefined =>\n array.length === 1 ? array[0] : undefined;\n"],"mappings":"mCA4CA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAO,EAAM,EAAoB,EAAK,CAGxC,MAAM,EAAyB,GAC7B,EAAM,SAAW,EAAI,EAAM,GAAK,IAAA"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e,...t){return(...n)=>e(...t,...n)}exports.partialBind=e;
2
+ //# sourceMappingURL=partialBind.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partialBind.cjs","names":[],"sources":["../src/partialBind.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { RemedaTypeError } from \"./internal/types/RemedaTypeError\";\nimport type { StrictFunction } from \"./internal/types/StrictFunction\";\nimport type { TupleSplits } from \"./internal/types/TupleSplits\";\n\ntype PartialBindError<\n Message extends string,\n Metadata = never,\n> = RemedaTypeError<\"partialBind\", Message, { metadata: Metadata }>;\n\ntype TuplePrefix<T extends IterableContainer> = TupleSplits<T>[\"left\"];\n\ntype RemovePrefix<\n T extends IterableContainer,\n Prefix extends TuplePrefix<T>,\n> = Prefix extends readonly []\n ? T\n : T extends readonly [infer THead, ...infer TRest]\n ? Prefix extends readonly [infer _PrefixHead, ...infer PrefixRest]\n ? // PrefixHead extends THead.\n RemovePrefix<TRest, PrefixRest>\n : // Prefix (as a whole) extends readonly THead[].\n // Prefix could possibly be empty, so this has to be THead?.\n [THead?, ...RemovePrefix<TRest, Prefix>]\n : // T has an optional or rest parameter last. If T is a parameter list,\n // this can only happen if we have optional arguments or a rest param;\n // both cases are similar.\n T extends readonly [(infer _THead)?, ...infer TRest]\n ? Prefix extends readonly [infer _PrefixHead, ...infer PrefixRest]\n ? // PrefixHead extends THead.\n RemovePrefix<TRest, PrefixRest>\n : // Prefix (as a whole) extends [THead?, ...TRest].\n TRest\n : // We got passed a parameter list that isn't what we expected; this is\n // an internal error.\n PartialBindError<\"Function parameter list has unexpected shape\", T>;\n\n/**\n * Creates a function that calls `func` with `partial` put before the arguments\n * it receives.\n *\n * Can be thought of as \"freezing\" some portion of a function's arguments,\n * resulting in a new function with a simplified signature.\n *\n * @param func - The function to wrap.\n * @param partial - The arguments to put before.\n * @returns A partially bound function.\n * @signature\n * partialBind(func, ...partial);\n * @example\n * const fn = (x: number, y: number, z: number) => x * 100 + y * 10 + z;\n * const partialFn = partialBind(fn, 1, 2);\n * partialFn(3); //=> 123\n *\n * const logWithPrefix = partialBind(console.log, \"[prefix]\");\n * logWithPrefix(\"hello\"); //=> \"[prefix] hello\"\n * @dataFirst\n * @category Function\n * @see partialLastBind\n */\nexport function partialBind<\n F extends StrictFunction,\n PrefixArgs extends TuplePrefix<Parameters<F>>,\n RemovedPrefix extends RemovePrefix<Parameters<F>, PrefixArgs>,\n>(\n func: F,\n ...partial: PrefixArgs\n): (\n ...rest: RemovedPrefix extends IterableContainer ? RemovedPrefix : never\n) => ReturnType<F> {\n // @ts-expect-error [ts2345, ts2322] -- TypeScript infers the generic sub-\n // types too eagerly, making itself blind to the fact that the types match\n // here.\n return (...rest) => func(...partial, ...rest);\n}\n"],"mappings":"mEA4DA,SAAgB,EAKd,EACA,GAAG,EAGc,CAIjB,OAAQ,GAAG,IAAS,EAAK,GAAG,EAAS,GAAG,EAAK"}
@@ -0,0 +1,2 @@
1
+ function e(e,...t){return(...n)=>e(...t,...n)}export{e as partialBind};
2
+ //# sourceMappingURL=partialBind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partialBind.js","names":[],"sources":["../src/partialBind.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { RemedaTypeError } from \"./internal/types/RemedaTypeError\";\nimport type { StrictFunction } from \"./internal/types/StrictFunction\";\nimport type { TupleSplits } from \"./internal/types/TupleSplits\";\n\ntype PartialBindError<\n Message extends string,\n Metadata = never,\n> = RemedaTypeError<\"partialBind\", Message, { metadata: Metadata }>;\n\ntype TuplePrefix<T extends IterableContainer> = TupleSplits<T>[\"left\"];\n\ntype RemovePrefix<\n T extends IterableContainer,\n Prefix extends TuplePrefix<T>,\n> = Prefix extends readonly []\n ? T\n : T extends readonly [infer THead, ...infer TRest]\n ? Prefix extends readonly [infer _PrefixHead, ...infer PrefixRest]\n ? // PrefixHead extends THead.\n RemovePrefix<TRest, PrefixRest>\n : // Prefix (as a whole) extends readonly THead[].\n // Prefix could possibly be empty, so this has to be THead?.\n [THead?, ...RemovePrefix<TRest, Prefix>]\n : // T has an optional or rest parameter last. If T is a parameter list,\n // this can only happen if we have optional arguments or a rest param;\n // both cases are similar.\n T extends readonly [(infer _THead)?, ...infer TRest]\n ? Prefix extends readonly [infer _PrefixHead, ...infer PrefixRest]\n ? // PrefixHead extends THead.\n RemovePrefix<TRest, PrefixRest>\n : // Prefix (as a whole) extends [THead?, ...TRest].\n TRest\n : // We got passed a parameter list that isn't what we expected; this is\n // an internal error.\n PartialBindError<\"Function parameter list has unexpected shape\", T>;\n\n/**\n * Creates a function that calls `func` with `partial` put before the arguments\n * it receives.\n *\n * Can be thought of as \"freezing\" some portion of a function's arguments,\n * resulting in a new function with a simplified signature.\n *\n * @param func - The function to wrap.\n * @param partial - The arguments to put before.\n * @returns A partially bound function.\n * @signature\n * partialBind(func, ...partial);\n * @example\n * const fn = (x: number, y: number, z: number) => x * 100 + y * 10 + z;\n * const partialFn = partialBind(fn, 1, 2);\n * partialFn(3); //=> 123\n *\n * const logWithPrefix = partialBind(console.log, \"[prefix]\");\n * logWithPrefix(\"hello\"); //=> \"[prefix] hello\"\n * @dataFirst\n * @category Function\n * @see partialLastBind\n */\nexport function partialBind<\n F extends StrictFunction,\n PrefixArgs extends TuplePrefix<Parameters<F>>,\n RemovedPrefix extends RemovePrefix<Parameters<F>, PrefixArgs>,\n>(\n func: F,\n ...partial: PrefixArgs\n): (\n ...rest: RemovedPrefix extends IterableContainer ? RemovedPrefix : never\n) => ReturnType<F> {\n // @ts-expect-error [ts2345, ts2322] -- TypeScript infers the generic sub-\n // types too eagerly, making itself blind to the fact that the types match\n // here.\n return (...rest) => func(...partial, ...rest);\n}\n"],"mappings":"AA4DA,SAAgB,EAKd,EACA,GAAG,EAGc,CAIjB,OAAQ,GAAG,IAAS,EAAK,GAAG,EAAS,GAAG,EAAK"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e,...t){return(...n)=>e(...n,...t)}exports.partialLastBind=e;
2
+ //# sourceMappingURL=partialLastBind.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partialLastBind.cjs","names":[],"sources":["../src/partialLastBind.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { RemedaTypeError } from \"./internal/types/RemedaTypeError\";\nimport type { StrictFunction } from \"./internal/types/StrictFunction\";\nimport type { TupleSplits } from \"./internal/types/TupleSplits\";\n\ntype PartialLastBindError<\n Message extends string,\n Metadata = never,\n> = RemedaTypeError<\"partialLastBind\", Message, { metadata: Metadata }>;\n\ntype TupleSuffix<T extends IterableContainer> = TupleSplits<T>[\"right\"];\n\ntype RemoveSuffix<\n T extends IterableContainer,\n Suffix extends TupleSuffix<T>,\n> = Suffix extends readonly []\n ? T\n : T extends readonly [...infer TRest, infer TLast]\n ? Suffix extends readonly [...infer SuffixRest, infer _SuffixLast]\n ? // SuffixLast extends TLast.\n RemoveSuffix<TRest, SuffixRest>\n : // Suffix (as a whole) extends readonly TLast[].\n // Suffix could possibly be empty, so this has to be TLast?.\n [...RemoveSuffix<TRest, Suffix>, TLast?]\n : // T has an optional or rest parameter last. If T is a parameter list,\n // this can only happen if we have optional arguments or a rest param;\n // both cases are similar.\n T extends readonly [...infer TRest, (infer _TLast)?]\n ? Suffix extends readonly [...infer SuffixRest, infer _SuffixLast]\n ? // SuffixLast extends TLast.\n RemoveSuffix<TRest, SuffixRest>\n : // Suffix (as a whole) extends [...TRest, TLast?].\n TRest\n : // We got passed a parameter list that isn't what we expected; this\n // is an internal error.\n PartialLastBindError<\"Function parameter list has unexpected shape\", T>;\n\n/**\n * Creates a function that calls `func` with `partial` put after the arguments\n * it receives. Note that this doesn't support functions with both optional\n * and rest parameters.\n *\n * Can be thought of as \"freezing\" some portion of a function's arguments,\n * resulting in a new function with a simplified signature.\n *\n * Useful for converting a data-first function to a data-last one.\n *\n * @param func - The function to wrap.\n * @param partial - The arguments to put after.\n * @returns A partially bound function.\n * @signature\n * partialLastBind(func, ...partial);\n * @example\n * const fn = (x: number, y: number, z: number) => x * 100 + y * 10 + z;\n * const partialFn = partialLastBind(fn, 2, 3);\n * partialFn(1); //=> 123\n *\n * const parseBinary = partialLastBind(parseInt, \"2\");\n * parseBinary(\"101\"); //=> 5\n *\n * pipe(\n * { a: 1 },\n * // instead of (arg) => JSON.stringify(arg, null, 2)\n * partialLastBind(JSON.stringify, null, 2),\n * ); //=> '{\\n \"a\": 1\\n}'\n * @dataFirst\n * @category Function\n * @see partialBind\n */\nexport function partialLastBind<\n F extends StrictFunction,\n SuffixArgs extends TupleSuffix<Parameters<F>>,\n RemovedSuffix extends RemoveSuffix<Parameters<F>, SuffixArgs>,\n>(\n func: F,\n ...partial: SuffixArgs\n): (\n ...rest: RemovedSuffix extends IterableContainer ? RemovedSuffix : never\n) => ReturnType<F> {\n // @ts-expect-error [ts2345, ts2322] -- TypeScript infers the generic sub-\n // types too eagerly, making itself blind to the fact that the types match\n // here.\n return (...rest) => func(...rest, ...partial);\n}\n"],"mappings":"mEAqEA,SAAgB,EAKd,EACA,GAAG,EAGc,CAIjB,OAAQ,GAAG,IAAS,EAAK,GAAG,EAAM,GAAG,EAAQ"}
@@ -0,0 +1,2 @@
1
+ function e(e,...t){return(...n)=>e(...n,...t)}export{e as partialLastBind};
2
+ //# sourceMappingURL=partialLastBind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partialLastBind.js","names":[],"sources":["../src/partialLastBind.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { RemedaTypeError } from \"./internal/types/RemedaTypeError\";\nimport type { StrictFunction } from \"./internal/types/StrictFunction\";\nimport type { TupleSplits } from \"./internal/types/TupleSplits\";\n\ntype PartialLastBindError<\n Message extends string,\n Metadata = never,\n> = RemedaTypeError<\"partialLastBind\", Message, { metadata: Metadata }>;\n\ntype TupleSuffix<T extends IterableContainer> = TupleSplits<T>[\"right\"];\n\ntype RemoveSuffix<\n T extends IterableContainer,\n Suffix extends TupleSuffix<T>,\n> = Suffix extends readonly []\n ? T\n : T extends readonly [...infer TRest, infer TLast]\n ? Suffix extends readonly [...infer SuffixRest, infer _SuffixLast]\n ? // SuffixLast extends TLast.\n RemoveSuffix<TRest, SuffixRest>\n : // Suffix (as a whole) extends readonly TLast[].\n // Suffix could possibly be empty, so this has to be TLast?.\n [...RemoveSuffix<TRest, Suffix>, TLast?]\n : // T has an optional or rest parameter last. If T is a parameter list,\n // this can only happen if we have optional arguments or a rest param;\n // both cases are similar.\n T extends readonly [...infer TRest, (infer _TLast)?]\n ? Suffix extends readonly [...infer SuffixRest, infer _SuffixLast]\n ? // SuffixLast extends TLast.\n RemoveSuffix<TRest, SuffixRest>\n : // Suffix (as a whole) extends [...TRest, TLast?].\n TRest\n : // We got passed a parameter list that isn't what we expected; this\n // is an internal error.\n PartialLastBindError<\"Function parameter list has unexpected shape\", T>;\n\n/**\n * Creates a function that calls `func` with `partial` put after the arguments\n * it receives. Note that this doesn't support functions with both optional\n * and rest parameters.\n *\n * Can be thought of as \"freezing\" some portion of a function's arguments,\n * resulting in a new function with a simplified signature.\n *\n * Useful for converting a data-first function to a data-last one.\n *\n * @param func - The function to wrap.\n * @param partial - The arguments to put after.\n * @returns A partially bound function.\n * @signature\n * partialLastBind(func, ...partial);\n * @example\n * const fn = (x: number, y: number, z: number) => x * 100 + y * 10 + z;\n * const partialFn = partialLastBind(fn, 2, 3);\n * partialFn(1); //=> 123\n *\n * const parseBinary = partialLastBind(parseInt, \"2\");\n * parseBinary(\"101\"); //=> 5\n *\n * pipe(\n * { a: 1 },\n * // instead of (arg) => JSON.stringify(arg, null, 2)\n * partialLastBind(JSON.stringify, null, 2),\n * ); //=> '{\\n \"a\": 1\\n}'\n * @dataFirst\n * @category Function\n * @see partialBind\n */\nexport function partialLastBind<\n F extends StrictFunction,\n SuffixArgs extends TupleSuffix<Parameters<F>>,\n RemovedSuffix extends RemoveSuffix<Parameters<F>, SuffixArgs>,\n>(\n func: F,\n ...partial: SuffixArgs\n): (\n ...rest: RemovedSuffix extends IterableContainer ? RemovedSuffix : never\n) => ReturnType<F> {\n // @ts-expect-error [ts2345, ts2322] -- TypeScript infers the generic sub-\n // types too eagerly, making itself blind to the fact that the types match\n // here.\n return (...rest) => func(...rest, ...partial);\n}\n"],"mappings":"AAqEA,SAAgB,EAKd,EACA,GAAG,EAGc,CAIjB,OAAQ,GAAG,IAAS,EAAK,GAAG,EAAM,GAAG,EAAQ"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`);function t(...t){return e.purry(n,t)}const n=(e,t)=>{let n=[[],[]];for(let[r,i]of e.entries())t(i,r,e)?n[0].push(i):n[1].push(i);return n};exports.partition=t;
2
+ //# sourceMappingURL=partition.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partition.cjs","names":["purry"],"sources":["../src/partition.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Splits a collection into two groups, the first of which contains elements the\n * `predicate` type guard passes, and the second one containing the rest.\n *\n * @param data - The items to split.\n * @param predicate - A function to execute for each element in the array. It\n * should return `true` to add the element to the first partition, and and\n * `false` to add the element to the other partition. A type-predicate can also\n * be used to narrow the result.\n * @returns A 2-tuple of arrays where the first array contains the elements that\n * passed the predicate, and the second array contains the elements that did\n * not. The items are in the same order as they were in the original array.\n * @signature\n * partition(data, predicate)\n * @example\n * partition(\n * ['one', 'two', 'forty two'],\n * x => x.length === 3,\n * ); // => [['one', 'two'], ['forty two']]\n * @dataFirst\n * @category Array\n */\nexport function partition<T, S extends T>(\n data: readonly T[],\n predicate: (value: T, index: number, data: readonly T[]) => value is S,\n): [S[], Exclude<T, S>[]];\nexport function partition<T>(\n data: readonly T[],\n predicate: (value: T, index: number, data: readonly T[]) => boolean,\n): [T[], T[]];\n\n/**\n * Splits a collection into two groups, the first of which contains elements the\n * `predicate` type guard passes, and the second one containing the rest.\n *\n * @param predicate - A function to execute for each element in the array. It\n * should return `true` to add the element to the first partition, and and\n * `false` to add the element to the other partition. A type-predicate can also\n * be used to narrow the result.\n * @returns A 2-tuple of arrays where the first array contains the elements that\n * passed the predicate, and the second array contains the elements that did\n * not. The items are in the same order as they were in the original array.\n * @signature\n * partition(predicate)(data)\n * @example\n * pipe(\n * ['one', 'two', 'forty two'],\n * partition(x => x.length === 3),\n * ); // => [['one', 'two'], ['forty two']]\n * @dataLast\n * @category Array\n */\nexport function partition<T, S extends T>(\n predicate: (value: T, index: number, data: readonly T[]) => value is S,\n): (data: readonly T[]) => [S[], Exclude<T, S>[]];\nexport function partition<T>(\n predicate: (value: T, index: number, data: readonly T[]) => boolean,\n): (data: readonly T[]) => [T[], T[]];\n\nexport function partition(...args: readonly unknown[]): unknown {\n return purry(partitionImplementation, args);\n}\n\nconst partitionImplementation = <T, S extends T>(\n data: readonly T[],\n predicate: (value: T, index: number, data: readonly T[]) => value is S,\n): [S[], T[]] => {\n const ret: [S[], T[]] = [[], []];\n for (const [index, item] of data.entries()) {\n if (predicate(item, index, data)) {\n ret[0].push(item);\n } else {\n ret[1].push(item);\n }\n }\n return ret;\n};\n"],"mappings":"kGA6DA,SAAgB,EAAU,GAAG,EAAmC,CAC9D,OAAOA,EAAAA,MAAM,EAAyB,EAAK,CAG7C,MAAM,GACJ,EACA,IACe,CACf,IAAM,EAAkB,CAAC,EAAE,CAAE,EAAE,CAAC,CAChC,IAAK,GAAM,CAAC,EAAO,KAAS,EAAK,SAAS,CACpC,EAAU,EAAM,EAAO,EAAK,CAC9B,EAAI,GAAG,KAAK,EAAK,CAEjB,EAAI,GAAG,KAAK,EAAK,CAGrB,OAAO"}
@@ -0,0 +1,2 @@
1
+ import{purry as e}from"./purry.js";function t(...t){return e(n,t)}const n=(e,t)=>{let n=[[],[]];for(let[r,i]of e.entries())t(i,r,e)?n[0].push(i):n[1].push(i);return n};export{t as partition};
2
+ //# sourceMappingURL=partition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partition.js","names":[],"sources":["../src/partition.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Splits a collection into two groups, the first of which contains elements the\n * `predicate` type guard passes, and the second one containing the rest.\n *\n * @param data - The items to split.\n * @param predicate - A function to execute for each element in the array. It\n * should return `true` to add the element to the first partition, and and\n * `false` to add the element to the other partition. A type-predicate can also\n * be used to narrow the result.\n * @returns A 2-tuple of arrays where the first array contains the elements that\n * passed the predicate, and the second array contains the elements that did\n * not. The items are in the same order as they were in the original array.\n * @signature\n * partition(data, predicate)\n * @example\n * partition(\n * ['one', 'two', 'forty two'],\n * x => x.length === 3,\n * ); // => [['one', 'two'], ['forty two']]\n * @dataFirst\n * @category Array\n */\nexport function partition<T, S extends T>(\n data: readonly T[],\n predicate: (value: T, index: number, data: readonly T[]) => value is S,\n): [S[], Exclude<T, S>[]];\nexport function partition<T>(\n data: readonly T[],\n predicate: (value: T, index: number, data: readonly T[]) => boolean,\n): [T[], T[]];\n\n/**\n * Splits a collection into two groups, the first of which contains elements the\n * `predicate` type guard passes, and the second one containing the rest.\n *\n * @param predicate - A function to execute for each element in the array. It\n * should return `true` to add the element to the first partition, and and\n * `false` to add the element to the other partition. A type-predicate can also\n * be used to narrow the result.\n * @returns A 2-tuple of arrays where the first array contains the elements that\n * passed the predicate, and the second array contains the elements that did\n * not. The items are in the same order as they were in the original array.\n * @signature\n * partition(predicate)(data)\n * @example\n * pipe(\n * ['one', 'two', 'forty two'],\n * partition(x => x.length === 3),\n * ); // => [['one', 'two'], ['forty two']]\n * @dataLast\n * @category Array\n */\nexport function partition<T, S extends T>(\n predicate: (value: T, index: number, data: readonly T[]) => value is S,\n): (data: readonly T[]) => [S[], Exclude<T, S>[]];\nexport function partition<T>(\n predicate: (value: T, index: number, data: readonly T[]) => boolean,\n): (data: readonly T[]) => [T[], T[]];\n\nexport function partition(...args: readonly unknown[]): unknown {\n return purry(partitionImplementation, args);\n}\n\nconst partitionImplementation = <T, S extends T>(\n data: readonly T[],\n predicate: (value: T, index: number, data: readonly T[]) => value is S,\n): [S[], T[]] => {\n const ret: [S[], T[]] = [[], []];\n for (const [index, item] of data.entries()) {\n if (predicate(item, index, data)) {\n ret[0].push(item);\n } else {\n ret[1].push(item);\n }\n }\n return ret;\n};\n"],"mappings":"mCA6DA,SAAgB,EAAU,GAAG,EAAmC,CAC9D,OAAO,EAAM,EAAyB,EAAK,CAG7C,MAAM,GACJ,EACA,IACe,CACf,IAAM,EAAkB,CAAC,EAAE,CAAE,EAAE,CAAC,CAChC,IAAK,GAAM,CAAC,EAAO,KAAS,EAAK,SAAS,CACpC,EAAU,EAAM,EAAO,EAAK,CAC9B,EAAI,GAAG,KAAK,EAAK,CAEjB,EAAI,GAAG,KAAK,EAAK,CAGrB,OAAO"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`);function t(...t){return e.purry(n,t)}function n(e,t,n){let r=e;for(let e of t){if(r==null)break;r=r[e]}return r??n}exports.pathOr=t;
2
+ //# sourceMappingURL=pathOr.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathOr.cjs","names":["purry"],"sources":["../src/pathOr.ts"],"sourcesContent":["/* eslint-disable jsdoc/require-param, jsdoc/require-example, jsdoc/require-description -- allow us to deprecate all overloads of the function, not just those that have the docblock directly above them. */\n\nimport { purry } from \"./purry\";\n\n/**\n * Given a union of indexable types `T`, we derive an indexable type\n * containing all of the keys of each variant of `T`. If a key is\n * present in multiple variants of `T`, then the corresponding type in\n * `Pathable<T>` will be the intersection of all types for that key.\n *\n * @example\n * type T1 = Pathable<{a: number} | {a: string; b: boolean}>\n * // {a: number | string; b: boolean}\n *\n * type T2 = Pathable<{a?: {b: string}}\n * // {a: {b: string} | undefined}\n *\n * type T3 = Pathable<{a: string} | number>\n * // {a: string}\n *\n * type T4 = Pathable<{a: number} | {a: string} | {b: boolean}>\n * // {a: number | string; b: boolean}\n *\n * This type lets us answer the questions:\n * - Given some object of type `T`, what keys might this object have?\n * - If this object did happen to have a particular key, what values\n * might that key have?\n */\ntype Pathable<T> = { [K in AllKeys<T>]: TypesForKey<T, K> };\n\ntype AllKeys<T> = T extends infer I ? keyof I : never;\ntype TypesForKey<T, K extends PropertyKey> = T extends infer I\n ? K extends keyof I\n ? I[K]\n : never\n : never;\n\n// Like Required<T>, but also removes explicit null and undefined typings */\ntype StrictlyRequired<T> = { [K in keyof T]-?: NonNullable<T[K]> };\n\n/**\n * Given some `A` which is a key of at least one variant of `T`, derive\n * `T[A]` for the cases where `A` is present in `T`, and `T[A]` is not\n * null or undefined.\n */\ntype PathValue1<T, A extends keyof Pathable<T>> = StrictlyRequired<\n Pathable<T>\n>[A];\n/** All possible options after successfully reaching `T[A]`. */\ntype Pathable1<T, A extends keyof Pathable<T>> = Pathable<PathValue1<T, A>>;\n\n/** As `PathValue1`, but for `T[A][B]`. */\ntype PathValue2<\n T,\n A extends keyof Pathable<T>,\n B extends keyof Pathable1<T, A>,\n> = StrictlyRequired<Pathable1<T, A>>[B];\n/** As `Pathable1`, but for `T[A][B]`. */\ntype Pathable2<\n T,\n A extends keyof Pathable<T>,\n B extends keyof Pathable1<T, A>,\n> = Pathable<PathValue2<T, A, B>>;\n\n/** As `PathValue1`, but for `T[A][B][C]`. */\ntype PathValue3<\n T,\n A extends keyof Pathable<T>,\n B extends keyof Pathable1<T, A>,\n C extends keyof Pathable2<T, A, B>,\n> = StrictlyRequired<Pathable2<T, A, B>>[C];\n\n/**\n * Gets the value at `path` of `object`. If the resolved value is `null` or `undefined`, the `defaultValue` is returned in its place.\n *\n * **DEPRECATED**: Use `defaultTo(prop(object, ...path), defaultValue)`\n * instead!\n *\n * @param object - The target object.\n * @param path - The path of the property to get.\n * @param defaultValue - The default value.\n * @signature pathOr(object, array, defaultValue)\n * @example\n * pathOr({x: 10}, ['y'], 2) // 2\n * pathOr({y: 10}, ['y'], 2) // 10\n * @dataFirst\n * @category Object\n * @deprecated Use `defaultTo(prop(object, ...path), defaultValue)` instead.\n */\nexport function pathOr<T, A extends keyof Pathable<T>>(\n object: T,\n path: readonly [A],\n defaultValue: PathValue1<T, A>,\n): PathValue1<T, A>;\n\n/**\n * @deprecated Use `defaultTo(prop(object, ...path), defaultValue)` instead.\n */\nexport function pathOr<\n T,\n A extends keyof Pathable<T>,\n B extends keyof Pathable1<T, A>,\n>(\n object: T,\n path: readonly [A, B],\n defaultValue: PathValue2<T, A, B>,\n): PathValue2<T, A, B>;\n\n/**\n * @deprecated Use `defaultTo(prop(object, ...path), defaultValue)` instead.\n */\nexport function pathOr<\n T,\n A extends keyof Pathable<T>,\n B extends keyof Pathable1<T, A>,\n C extends keyof Pathable2<T, A, B>,\n>(\n object: T,\n path: readonly [A, B, C],\n defaultValue: PathValue3<T, A, B, C>,\n): PathValue3<T, A, B, C>;\n\n/**\n * Gets the value at `path` of `object`. If the resolved value is `undefined`, the `defaultValue` is returned in its place.\n *\n * **DEPRECATED**: Use `($) => defaultTo(prop($, ...path), defaultValue)`\n * instead, or if already inside a `pipe`, replace the call to `pathOr` with:\n * `pipe(..., prop(...path), defaultTo(defaultValue), ...)`.\n *\n * @param path - The path of the property to get.\n * @param defaultValue - The default value.\n * @signature pathOr(array, defaultValue)(object)\n * @example\n * pipe({x: 10}, pathOr(['y'], 2)) // 2\n * pipe({y: 10}, pathOr(['y'], 2)) // 10\n * @dataLast\n * @category Object\n * @deprecated Use `($) => defaultTo(prop($, ...path), defaultValue)` instead,\n * or if already inside a `pipe`, replace the call to `pathOr` with:\n * `pipe(..., prop(...path), defaultTo(defaultValue), ...)`.\n */\nexport function pathOr<T, A extends keyof Pathable<T>>(\n path: readonly [A],\n defaultValue: PathValue1<T, A>,\n): (object: T) => PathValue1<T, A>;\n\n/**\n * @deprecated Use `($) => defaultTo(prop($, ...path), defaultValue)` instead,\n * or if already inside a `pipe`, replace the call to `pathOr` with:\n * `pipe(..., prop(...path), defaultTo(defaultValue), ...)`.\n */\nexport function pathOr<\n T,\n A extends keyof Pathable<T>,\n B extends keyof Pathable1<T, A>,\n>(\n path: readonly [A, B],\n defaultValue: PathValue2<T, A, B>,\n): (object: T) => PathValue2<T, A, B>;\n\n/**\n * @deprecated Use `($) => defaultTo(prop($, ...path), defaultValue)` instead,\n * or if already inside a `pipe`, replace the call to `pathOr` with:\n * `pipe(..., prop(...path), defaultTo(defaultValue), ...)`.\n */\nexport function pathOr<\n T,\n A extends keyof Pathable<T>,\n B extends keyof Pathable1<T, A>,\n C extends keyof Pathable2<T, A, B>,\n>(\n path: readonly [A, B, C],\n defaultValue: PathValue3<T, A, B, C>,\n): (object: T) => PathValue3<T, A, B, C>;\n\n// TODO [>2]: Remove this function!\nexport function pathOr(...args: readonly unknown[]): unknown {\n return purry(pathOrImplementation, args);\n}\n\nfunction pathOrImplementation(\n data: unknown,\n path: readonly PropertyKey[],\n defaultValue: unknown,\n): unknown {\n let current = data;\n for (const prop of path) {\n if (current === null || current === undefined) {\n break;\n }\n current = (current as Record<PropertyKey, unknown>)[prop];\n }\n\n return current ?? defaultValue;\n}\n"],"mappings":"kGAgLA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAOA,EAAAA,MAAM,EAAsB,EAAK,CAG1C,SAAS,EACP,EACA,EACA,EACS,CACT,IAAI,EAAU,EACd,IAAK,IAAM,KAAQ,EAAM,CACvB,GAAI,GAAY,KACd,MAEF,EAAW,EAAyC,GAGtD,OAAO,GAAW"}
package/dist/pathOr.js ADDED
@@ -0,0 +1,2 @@
1
+ import{purry as e}from"./purry.js";function t(...t){return e(n,t)}function n(e,t,n){let r=e;for(let e of t){if(r==null)break;r=r[e]}return r??n}export{t as pathOr};
2
+ //# sourceMappingURL=pathOr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathOr.js","names":[],"sources":["../src/pathOr.ts"],"sourcesContent":["/* eslint-disable jsdoc/require-param, jsdoc/require-example, jsdoc/require-description -- allow us to deprecate all overloads of the function, not just those that have the docblock directly above them. */\n\nimport { purry } from \"./purry\";\n\n/**\n * Given a union of indexable types `T`, we derive an indexable type\n * containing all of the keys of each variant of `T`. If a key is\n * present in multiple variants of `T`, then the corresponding type in\n * `Pathable<T>` will be the intersection of all types for that key.\n *\n * @example\n * type T1 = Pathable<{a: number} | {a: string; b: boolean}>\n * // {a: number | string; b: boolean}\n *\n * type T2 = Pathable<{a?: {b: string}}\n * // {a: {b: string} | undefined}\n *\n * type T3 = Pathable<{a: string} | number>\n * // {a: string}\n *\n * type T4 = Pathable<{a: number} | {a: string} | {b: boolean}>\n * // {a: number | string; b: boolean}\n *\n * This type lets us answer the questions:\n * - Given some object of type `T`, what keys might this object have?\n * - If this object did happen to have a particular key, what values\n * might that key have?\n */\ntype Pathable<T> = { [K in AllKeys<T>]: TypesForKey<T, K> };\n\ntype AllKeys<T> = T extends infer I ? keyof I : never;\ntype TypesForKey<T, K extends PropertyKey> = T extends infer I\n ? K extends keyof I\n ? I[K]\n : never\n : never;\n\n// Like Required<T>, but also removes explicit null and undefined typings */\ntype StrictlyRequired<T> = { [K in keyof T]-?: NonNullable<T[K]> };\n\n/**\n * Given some `A` which is a key of at least one variant of `T`, derive\n * `T[A]` for the cases where `A` is present in `T`, and `T[A]` is not\n * null or undefined.\n */\ntype PathValue1<T, A extends keyof Pathable<T>> = StrictlyRequired<\n Pathable<T>\n>[A];\n/** All possible options after successfully reaching `T[A]`. */\ntype Pathable1<T, A extends keyof Pathable<T>> = Pathable<PathValue1<T, A>>;\n\n/** As `PathValue1`, but for `T[A][B]`. */\ntype PathValue2<\n T,\n A extends keyof Pathable<T>,\n B extends keyof Pathable1<T, A>,\n> = StrictlyRequired<Pathable1<T, A>>[B];\n/** As `Pathable1`, but for `T[A][B]`. */\ntype Pathable2<\n T,\n A extends keyof Pathable<T>,\n B extends keyof Pathable1<T, A>,\n> = Pathable<PathValue2<T, A, B>>;\n\n/** As `PathValue1`, but for `T[A][B][C]`. */\ntype PathValue3<\n T,\n A extends keyof Pathable<T>,\n B extends keyof Pathable1<T, A>,\n C extends keyof Pathable2<T, A, B>,\n> = StrictlyRequired<Pathable2<T, A, B>>[C];\n\n/**\n * Gets the value at `path` of `object`. If the resolved value is `null` or `undefined`, the `defaultValue` is returned in its place.\n *\n * **DEPRECATED**: Use `defaultTo(prop(object, ...path), defaultValue)`\n * instead!\n *\n * @param object - The target object.\n * @param path - The path of the property to get.\n * @param defaultValue - The default value.\n * @signature pathOr(object, array, defaultValue)\n * @example\n * pathOr({x: 10}, ['y'], 2) // 2\n * pathOr({y: 10}, ['y'], 2) // 10\n * @dataFirst\n * @category Object\n * @deprecated Use `defaultTo(prop(object, ...path), defaultValue)` instead.\n */\nexport function pathOr<T, A extends keyof Pathable<T>>(\n object: T,\n path: readonly [A],\n defaultValue: PathValue1<T, A>,\n): PathValue1<T, A>;\n\n/**\n * @deprecated Use `defaultTo(prop(object, ...path), defaultValue)` instead.\n */\nexport function pathOr<\n T,\n A extends keyof Pathable<T>,\n B extends keyof Pathable1<T, A>,\n>(\n object: T,\n path: readonly [A, B],\n defaultValue: PathValue2<T, A, B>,\n): PathValue2<T, A, B>;\n\n/**\n * @deprecated Use `defaultTo(prop(object, ...path), defaultValue)` instead.\n */\nexport function pathOr<\n T,\n A extends keyof Pathable<T>,\n B extends keyof Pathable1<T, A>,\n C extends keyof Pathable2<T, A, B>,\n>(\n object: T,\n path: readonly [A, B, C],\n defaultValue: PathValue3<T, A, B, C>,\n): PathValue3<T, A, B, C>;\n\n/**\n * Gets the value at `path` of `object`. If the resolved value is `undefined`, the `defaultValue` is returned in its place.\n *\n * **DEPRECATED**: Use `($) => defaultTo(prop($, ...path), defaultValue)`\n * instead, or if already inside a `pipe`, replace the call to `pathOr` with:\n * `pipe(..., prop(...path), defaultTo(defaultValue), ...)`.\n *\n * @param path - The path of the property to get.\n * @param defaultValue - The default value.\n * @signature pathOr(array, defaultValue)(object)\n * @example\n * pipe({x: 10}, pathOr(['y'], 2)) // 2\n * pipe({y: 10}, pathOr(['y'], 2)) // 10\n * @dataLast\n * @category Object\n * @deprecated Use `($) => defaultTo(prop($, ...path), defaultValue)` instead,\n * or if already inside a `pipe`, replace the call to `pathOr` with:\n * `pipe(..., prop(...path), defaultTo(defaultValue), ...)`.\n */\nexport function pathOr<T, A extends keyof Pathable<T>>(\n path: readonly [A],\n defaultValue: PathValue1<T, A>,\n): (object: T) => PathValue1<T, A>;\n\n/**\n * @deprecated Use `($) => defaultTo(prop($, ...path), defaultValue)` instead,\n * or if already inside a `pipe`, replace the call to `pathOr` with:\n * `pipe(..., prop(...path), defaultTo(defaultValue), ...)`.\n */\nexport function pathOr<\n T,\n A extends keyof Pathable<T>,\n B extends keyof Pathable1<T, A>,\n>(\n path: readonly [A, B],\n defaultValue: PathValue2<T, A, B>,\n): (object: T) => PathValue2<T, A, B>;\n\n/**\n * @deprecated Use `($) => defaultTo(prop($, ...path), defaultValue)` instead,\n * or if already inside a `pipe`, replace the call to `pathOr` with:\n * `pipe(..., prop(...path), defaultTo(defaultValue), ...)`.\n */\nexport function pathOr<\n T,\n A extends keyof Pathable<T>,\n B extends keyof Pathable1<T, A>,\n C extends keyof Pathable2<T, A, B>,\n>(\n path: readonly [A, B, C],\n defaultValue: PathValue3<T, A, B, C>,\n): (object: T) => PathValue3<T, A, B, C>;\n\n// TODO [>2]: Remove this function!\nexport function pathOr(...args: readonly unknown[]): unknown {\n return purry(pathOrImplementation, args);\n}\n\nfunction pathOrImplementation(\n data: unknown,\n path: readonly PropertyKey[],\n defaultValue: unknown,\n): unknown {\n let current = data;\n for (const prop of path) {\n if (current === null || current === undefined) {\n break;\n }\n current = (current as Record<PropertyKey, unknown>)[prop];\n }\n\n return current ?? defaultValue;\n}\n"],"mappings":"mCAgLA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAO,EAAM,EAAsB,EAAK,CAG1C,SAAS,EACP,EACA,EACA,EACS,CACT,IAAI,EAAU,EACd,IAAK,IAAM,KAAQ,EAAM,CACvB,GAAI,GAAY,KACd,MAEF,EAAW,EAAyC,GAGtD,OAAO,GAAW"}
package/dist/pick.cjs ADDED
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`);function t(...t){return e.purry(n,t)}function n(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}exports.pick=t;
2
+ //# sourceMappingURL=pick.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pick.cjs","names":["purry"],"sources":["../src/pick.ts"],"sourcesContent":["import type { EmptyObject, IsNever, KeysOfUnion, Writable } from \"type-fest\";\nimport type { IsBounded } from \"./internal/types/IsBounded\";\nimport type { IsBoundedRecord } from \"./internal/types/IsBoundedRecord\";\nimport type { PartitionByUnion } from \"./internal/types/PartitionByUnion\";\nimport type { TupleParts } from \"./internal/types/TupleParts\";\nimport { purry } from \"./purry\";\n\ntype PickFromArray<T, Keys extends readonly KeysOfUnion<T>[]> =\n // Distribute unions for both object types and key arrays.\n T extends unknown\n ? Keys extends unknown\n ? // When T is a union (or when Keys is empty) the picked props might\n // not exist in some of its sub-types, e.g.,\n // `pick(... as { a: string } | { b: number }, ['a'])`,\n // if we simply let the regular \"constructive\" logic run, the\n // resulting type would be `{}` which doesn't behave like an empty\n // object! instead, we want to use a more explicit *empty* type.\n IsNever<Extract<Keys[number], keyof T>> extends true\n ? EmptyObject\n : // Remove `readonly` modifiers from picked props since we return a\n // new, mutable, object. We don't wrap the result with `Simplify` to\n // flatten it because `Writable` does the same thing implicitly.\n Writable<\n IsBoundedRecord<T> extends true\n ? PickBoundedFromArray<T, Keys>\n : PickUnbounded<T, Extract<Keys[number], keyof T>>\n >\n : never\n : never;\n\n/**\n * Bounded records have bounded keys and result in a bounded output. The only\n * question left is whether to add the prop as-is, or make it optional. This\n * can be determined by the part of the keys array the prop is defined in, and\n * the way that element is defined: if the array contains a singular literal\n * key in either the required prefix or the suffix, we know that prop should be\n * picked as-is, otherwise, the key might not be present in the keys array so it\n * can only be picked optionally.\n */\ntype PickBoundedFromArray<T, Keys extends readonly KeysOfUnion<T>[]> =\n // Literal keys in the prefix/suffix are guaranteed present.\n Pick<\n T,\n // When T is a union the keys need to be narrowed to just those that are\n // keys of the specific sub-type being built\n Extract<\n | PartitionByUnion<TupleParts<Keys>[\"required\"]>[\"singular\"]\n | PartitionByUnion<TupleParts<Keys>[\"suffix\"]>[\"singular\"],\n keyof T\n >\n > &\n // Union keys, optional elements, and rest elements are optional.\n Partial<\n Pick<\n T,\n // When T is a union the keys need to be narrowed to just those that are\n // keys of the specific sub-type being built.\n Extract<\n | PartitionByUnion<TupleParts<Keys>[\"required\"]>[\"union\"]\n // TODO: the optional part of the keys array will always be empty because its impossible to provide the pick function with a tuple with optional elements; this is because optional elements are always implicitly `undefined` too; which breaks the constraint that all keys are keys of T (`undefined` is not a key of anything). We can lift this restriction by supporting `undefined` in the runtime and relaxing the type constraint to allow it, but this relaxed constraint enables a niche feature (optional tuple elements) at the expense of better type-safety for the more common cases of fixed tuples and arrays. Anyway... if we ever change it, this part of the output type will ensure the output is still correct:\n | TupleParts<Keys>[\"optional\"][number]\n | TupleParts<Keys>[\"item\"]\n | PartitionByUnion<TupleParts<Keys>[\"suffix\"]>[\"union\"],\n keyof T\n >\n >\n >;\n\n/**\n * The built-in `Pick` is weird when it comes to picking bounded keys from\n * unbounded records. It reconstructs the output object regardless of the shape\n * of the input: `Pick<Record<string, \"world\">, \"hello\">` results in the type\n * `{ hello: \"world\" }`, but you'd expect it to be optional because we don't\n * know if the record contains a `hello` prop or not!\n *\n * !Important: We assume T is unbounded and don't test for it!\n *\n * See: https://www.typescriptlang.org/play/?#code/PTAEE0HsFcHIBNQFMAeAHJBjALqAGqNpKAEZKigAGA3qABZIA2jkA-AFygBEA7pAE6N4XUAF9KAGlLRcAQ0ayAzgChsATwz5QAXlAAFAJaYA1gB4ASlgHxTi7PwMA7AOZTeAoVwB8bhs0jeANzKIBSgAHqsykA.\n */\ntype PickUnbounded<T, Keys extends keyof T> =\n IsBounded<Keys> extends true ? Partial<Pick<T, Keys>> : Pick<T, Keys>;\n\n/**\n * Creates an object composed of the picked `data` properties.\n *\n * @param keys - The property names.\n * @signature pick([prop1, prop2])(object)\n * @example\n * pipe({ a: 1, b: 2, c: 3, d: 4 }, pick(['a', 'd'])) // => { a: 1, d: 4 }\n * @dataLast\n * @category Object\n */\nexport function pick<\n T extends object,\n const Keys extends readonly KeysOfUnion<T>[],\n>(keys: Keys): (data: T) => PickFromArray<T, Keys>;\n\n/**\n * Creates an object composed of the picked `data` properties.\n *\n * @param data - The target object.\n * @param keys - The property names.\n * @signature pick(object, [prop1, prop2])\n * @example\n * pick({ a: 1, b: 2, c: 3, d: 4 }, ['a', 'd']) // => { a: 1, d: 4 }\n * @dataFirst\n * @category Object\n */\nexport function pick<\n T extends object,\n const Keys extends readonly KeysOfUnion<T>[],\n>(data: T, keys: Keys): PickFromArray<T, Keys>;\n\nexport function pick(...args: readonly unknown[]): unknown {\n return purry(pickImplementation, args);\n}\n\nfunction pickImplementation<\n T extends object,\n Keys extends readonly (keyof T)[],\n>(object: T, keys: Keys): PickFromArray<T, Keys> {\n const out: Partial<Pick<T, Keys[number]>> = {};\n for (const key of keys) {\n if (key in object) {\n out[key] = object[key];\n }\n }\n // @ts-expect-error [ts2322] - We build the type incrementally, there's no way to make typescript infer that we \"finished\" building the object and to treat it as such.\n return out;\n}\n"],"mappings":"kGAiHA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAOA,EAAAA,MAAM,EAAoB,EAAK,CAGxC,SAAS,EAGP,EAAW,EAAoC,CAC/C,IAAM,EAAsC,EAAE,CAC9C,IAAK,IAAM,KAAO,EACZ,KAAO,IACT,EAAI,GAAO,EAAO,IAItB,OAAO"}
package/dist/pick.js ADDED
@@ -0,0 +1,2 @@
1
+ import{purry as e}from"./purry.js";function t(...t){return e(n,t)}function n(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}export{t as pick};
2
+ //# sourceMappingURL=pick.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pick.js","names":[],"sources":["../src/pick.ts"],"sourcesContent":["import type { EmptyObject, IsNever, KeysOfUnion, Writable } from \"type-fest\";\nimport type { IsBounded } from \"./internal/types/IsBounded\";\nimport type { IsBoundedRecord } from \"./internal/types/IsBoundedRecord\";\nimport type { PartitionByUnion } from \"./internal/types/PartitionByUnion\";\nimport type { TupleParts } from \"./internal/types/TupleParts\";\nimport { purry } from \"./purry\";\n\ntype PickFromArray<T, Keys extends readonly KeysOfUnion<T>[]> =\n // Distribute unions for both object types and key arrays.\n T extends unknown\n ? Keys extends unknown\n ? // When T is a union (or when Keys is empty) the picked props might\n // not exist in some of its sub-types, e.g.,\n // `pick(... as { a: string } | { b: number }, ['a'])`,\n // if we simply let the regular \"constructive\" logic run, the\n // resulting type would be `{}` which doesn't behave like an empty\n // object! instead, we want to use a more explicit *empty* type.\n IsNever<Extract<Keys[number], keyof T>> extends true\n ? EmptyObject\n : // Remove `readonly` modifiers from picked props since we return a\n // new, mutable, object. We don't wrap the result with `Simplify` to\n // flatten it because `Writable` does the same thing implicitly.\n Writable<\n IsBoundedRecord<T> extends true\n ? PickBoundedFromArray<T, Keys>\n : PickUnbounded<T, Extract<Keys[number], keyof T>>\n >\n : never\n : never;\n\n/**\n * Bounded records have bounded keys and result in a bounded output. The only\n * question left is whether to add the prop as-is, or make it optional. This\n * can be determined by the part of the keys array the prop is defined in, and\n * the way that element is defined: if the array contains a singular literal\n * key in either the required prefix or the suffix, we know that prop should be\n * picked as-is, otherwise, the key might not be present in the keys array so it\n * can only be picked optionally.\n */\ntype PickBoundedFromArray<T, Keys extends readonly KeysOfUnion<T>[]> =\n // Literal keys in the prefix/suffix are guaranteed present.\n Pick<\n T,\n // When T is a union the keys need to be narrowed to just those that are\n // keys of the specific sub-type being built\n Extract<\n | PartitionByUnion<TupleParts<Keys>[\"required\"]>[\"singular\"]\n | PartitionByUnion<TupleParts<Keys>[\"suffix\"]>[\"singular\"],\n keyof T\n >\n > &\n // Union keys, optional elements, and rest elements are optional.\n Partial<\n Pick<\n T,\n // When T is a union the keys need to be narrowed to just those that are\n // keys of the specific sub-type being built.\n Extract<\n | PartitionByUnion<TupleParts<Keys>[\"required\"]>[\"union\"]\n // TODO: the optional part of the keys array will always be empty because its impossible to provide the pick function with a tuple with optional elements; this is because optional elements are always implicitly `undefined` too; which breaks the constraint that all keys are keys of T (`undefined` is not a key of anything). We can lift this restriction by supporting `undefined` in the runtime and relaxing the type constraint to allow it, but this relaxed constraint enables a niche feature (optional tuple elements) at the expense of better type-safety for the more common cases of fixed tuples and arrays. Anyway... if we ever change it, this part of the output type will ensure the output is still correct:\n | TupleParts<Keys>[\"optional\"][number]\n | TupleParts<Keys>[\"item\"]\n | PartitionByUnion<TupleParts<Keys>[\"suffix\"]>[\"union\"],\n keyof T\n >\n >\n >;\n\n/**\n * The built-in `Pick` is weird when it comes to picking bounded keys from\n * unbounded records. It reconstructs the output object regardless of the shape\n * of the input: `Pick<Record<string, \"world\">, \"hello\">` results in the type\n * `{ hello: \"world\" }`, but you'd expect it to be optional because we don't\n * know if the record contains a `hello` prop or not!\n *\n * !Important: We assume T is unbounded and don't test for it!\n *\n * See: https://www.typescriptlang.org/play/?#code/PTAEE0HsFcHIBNQFMAeAHJBjALqAGqNpKAEZKigAGA3qABZIA2jkA-AFygBEA7pAE6N4XUAF9KAGlLRcAQ0ayAzgChsATwz5QAXlAAFAJaYA1gB4ASlgHxTi7PwMA7AOZTeAoVwB8bhs0jeANzKIBSgAHqsykA.\n */\ntype PickUnbounded<T, Keys extends keyof T> =\n IsBounded<Keys> extends true ? Partial<Pick<T, Keys>> : Pick<T, Keys>;\n\n/**\n * Creates an object composed of the picked `data` properties.\n *\n * @param keys - The property names.\n * @signature pick([prop1, prop2])(object)\n * @example\n * pipe({ a: 1, b: 2, c: 3, d: 4 }, pick(['a', 'd'])) // => { a: 1, d: 4 }\n * @dataLast\n * @category Object\n */\nexport function pick<\n T extends object,\n const Keys extends readonly KeysOfUnion<T>[],\n>(keys: Keys): (data: T) => PickFromArray<T, Keys>;\n\n/**\n * Creates an object composed of the picked `data` properties.\n *\n * @param data - The target object.\n * @param keys - The property names.\n * @signature pick(object, [prop1, prop2])\n * @example\n * pick({ a: 1, b: 2, c: 3, d: 4 }, ['a', 'd']) // => { a: 1, d: 4 }\n * @dataFirst\n * @category Object\n */\nexport function pick<\n T extends object,\n const Keys extends readonly KeysOfUnion<T>[],\n>(data: T, keys: Keys): PickFromArray<T, Keys>;\n\nexport function pick(...args: readonly unknown[]): unknown {\n return purry(pickImplementation, args);\n}\n\nfunction pickImplementation<\n T extends object,\n Keys extends readonly (keyof T)[],\n>(object: T, keys: Keys): PickFromArray<T, Keys> {\n const out: Partial<Pick<T, Keys[number]>> = {};\n for (const key of keys) {\n if (key in object) {\n out[key] = object[key];\n }\n }\n // @ts-expect-error [ts2322] - We build the type incrementally, there's no way to make typescript infer that we \"finished\" building the object and to treat it as such.\n return out;\n}\n"],"mappings":"mCAiHA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAO,EAAM,EAAoB,EAAK,CAGxC,SAAS,EAGP,EAAW,EAAoC,CAC/C,IAAM,EAAsC,EAAE,CAC9C,IAAK,IAAM,KAAO,EACZ,KAAO,IACT,EAAI,GAAO,EAAO,IAItB,OAAO"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`);function t(...t){return e.purry(n,t)}function n(e,t){let n={};for(let[r,i]of Object.entries(e))t(i,r,e)&&(n[r]=i);return n}exports.pickBy=t;
2
+ //# sourceMappingURL=pickBy.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pickBy.cjs","names":["purry"],"sources":["../src/pickBy.ts"],"sourcesContent":["import type { IsNever, Simplify } from \"type-fest\";\nimport type { EnumerableStringKeyOf } from \"./internal/types/EnumerableStringKeyOf\";\nimport type { EnumerableStringKeyedValueOf } from \"./internal/types/EnumerableStringKeyedValueOf\";\nimport type { IsBoundedRecord } from \"./internal/types/IsBoundedRecord\";\nimport type { ToString } from \"./internal/types/ToString\";\nimport { purry } from \"./purry\";\n\n// When the predicate isn't a type-guard we don't know which properties would be\n// part of the output and which wouldn't so we can only safely downgrade the\n// whole object to a Partial of the input.\ntype EnumeratedPartial<T> = T extends unknown\n ? Simplify<\n IsBoundedRecord<T> extends true\n ? {\n // Object.entries returns keys as strings.\n -readonly [P in keyof T as ToString<P>]?: Required<T>[P];\n }\n : // For unbounded records (a simple Record with primitive `string` or\n // `number` keys) the return type here could technically be T; but for\n // cases where the record is unbounded but is more complex (like\n // `symbol` keys) we want to \"reconstruct\" the record from just its\n // enumerable components (which are the ones accessible via\n // `Object.entries`).\n Record<EnumerableStringKeyOf<T>, EnumerableStringKeyedValueOf<T>>\n >\n : never;\n\n// When the predicate is a type-guard we have more information to work with when\n// constructing the type of the output object. We can safely remove any property\n// which value would never come up true for the predicate, AND we can also\n// assume that properties that match the predicate perfectly would **always**\n// show up in the output object. Hence to build the output object we need to\n// build and merge 2 output objects: One for the properties which have a value\n// of at type that would always yield a `true` result from the predicate, these\n// are the \"matches\", which would not change the \"optionality\" of the input\n// object's props, and one for partial matches which would also make the props\n// optional (as they could have a value that would be filtered out).\ntype EnumeratedPartialNarrowed<T, S> = T extends unknown\n ? Simplify<\n IsBoundedRecord<T> extends true\n ? ExactProps<T, S> & PartialProps<T, S>\n : // For unbounded records we need to \"reconstruct\" the record and\n // narrow the value types. Similar to the non-narrowed case, we need\n // to also ignore `symbol` keys and any values that are only relevant\n // to them.\n Record<\n EnumerableStringKeyOf<T>,\n Extract<EnumerableStringKeyedValueOf<T>, S>\n >\n >\n : never;\n\n// The exact case, props here would always be part of the output object\ntype ExactProps<T, S> = {\n // Object.entries returns keys as strings.\n -readonly [P in keyof T as ToString<\n IsExactProp<T, P, S> extends true ? P : never\n >]: Extract<Required<T>[P], S>;\n};\n\n// The partial case, props here might be part of the output object, but might\n// not be, hence they are optional.\ntype PartialProps<T, S> = {\n // Object.entries returns keys as strings.\n -readonly [P in keyof T as ToString<\n IsPartialProp<T, P, S> extends true ? P : never\n >]?: IsNever<Extract<T[P], S>> extends true\n ? // If the result of extracting S from T[P] is never but S still extends\n // it, it means that T[P] is too wide and S can't be extracted from it:\n // e.g. if T[P] is `number` S is `1` then `Extract<number, 1> === never`.\n // For these cases we can return S directly as the type as it's already\n // very narrowed compared to T[P].\n S extends T[P]\n ? S\n : never\n : Extract<T[P], S>;\n};\n\n// If the input object's value type extends itself when the type-guard is\n// extracted from it we can safely assume that the predicate would always return\n// true for any value of that property.\ntype IsExactProp<T, P extends keyof T, S> =\n T[P] extends Extract<T[P], S> ? true : false;\n\n// ...and if the input object's value type isn't an exact match, but still has\n// some partial match (i.g. the extracted type-guard isn't completely disjoint)\n// then we can assume that the property can sometimes return true, and sometimes\n// false when passed to the predicate, hence it should be optional in the\n// output.\ntype IsPartialProp<T, P extends keyof T, S> =\n IsExactProp<T, P, S> extends true\n ? false\n : IsNever<Extract<T[P], S>> extends true\n ? S extends T[P]\n ? // If the result of extracting S from T[P] is never but S still\n // extends it, it means that T[P] is too wide and S can't be\n // extracted from it: e.g. if T[P] is `number` S is `1` then\n // `Extract<number, 1> === never`, but `1` extends `number`. We need\n // to handle these cases when we extract the value too (see above).\n true\n : false\n : true;\n\n/**\n * Iterates over the entries of `data` and reconstructs the object using only\n * entries that `predicate` accepts. Symbol keys are not passed to the predicate\n * and would be filtered out from the output object.\n *\n * See `omitBy` for a complementary function which starts with a shallow copy of\n * the input object and removes the entries that the predicate rejects. Because\n * it is subtractive symbol keys would be copied over to the output object.\n * See also `entries`, `filter`, and `fromEntries` which could be used to build\n * your own version of `pickBy` if you need more control (though the resulting\n * type might be less precise).\n *\n * @param data - The target object.\n * @param predicate - A function that takes the value, key, and the data itself\n * and returns true if the entry should be part of the output object, or `false`\n * to remove it. If the function is a type-guard on the value the output type\n * would be narrowed accordingly.\n * @returns A shallow copy of the input object with the rejected entries\n * removed.\n * @signature pickBy(data, predicate)\n * @example\n * pickBy({a: 1, b: 2, A: 3, B: 4}, (val, key) => key.toUpperCase() === key) // => {A: 3, B: 4}\n * @dataFirst\n * @category Object\n */\nexport function pickBy<\n T extends object,\n S extends EnumerableStringKeyedValueOf<T>,\n>(\n data: T,\n predicate: (\n value: EnumerableStringKeyedValueOf<T>,\n key: EnumerableStringKeyOf<T>,\n data: T,\n ) => value is S,\n): EnumeratedPartialNarrowed<T, S>;\nexport function pickBy<T extends object>(\n data: T,\n predicate: (\n value: EnumerableStringKeyedValueOf<T>,\n key: EnumerableStringKeyOf<T>,\n data: T,\n ) => boolean,\n): EnumeratedPartial<T>;\n\n/**\n * Iterates over the entries of `data` and reconstructs the object using only\n * entries that `predicate` accepts. Symbol keys are not passed to the predicate\n * and would be filtered out from the output object.\n *\n * See `omitBy` for a complementary function which starts with a shallow copy of\n * the input object and removes the entries that the predicate rejects. Because\n * it is subtractive symbol keys would be copied over to the output object.\n * See also `entries`, `filter`, and `fromEntries` which could be used to build\n * your own version of `pickBy` if you need more control (though the resulting\n * type might be less precise).\n *\n * @param predicate - A function that takes the value, key, and the data itself\n * and returns true if the entry should be part of the output object, or `false`\n * to remove it. If the function is a type-guard on the value the output type\n * would be narrowed accordingly.\n * @signature\n * pickBy(predicate)(data)\n * @example\n * pipe({a: 1, b: 2, A: 3, B: 4}, pickBy((val, key) => key.toUpperCase() === key)); // => {A: 3, B: 4}\n * @dataLast\n * @category Object\n */\nexport function pickBy<\n T extends object,\n S extends EnumerableStringKeyedValueOf<T>,\n>(\n predicate: (\n value: EnumerableStringKeyedValueOf<T>,\n key: EnumerableStringKeyOf<T>,\n data: T,\n ) => value is S,\n): (data: T) => EnumeratedPartialNarrowed<T, S>;\nexport function pickBy<T extends object>(\n predicate: (\n value: EnumerableStringKeyedValueOf<T>,\n key: EnumerableStringKeyOf<T>,\n data: T,\n ) => boolean,\n): (data: T) => EnumeratedPartial<T>;\n\nexport function pickBy(...args: readonly unknown[]): unknown {\n return purry(pickByImplementation, args);\n}\n\nfunction pickByImplementation<T extends object>(\n data: T,\n predicate: (value: unknown, key: string, data: T) => boolean,\n): Record<string, unknown> {\n const out: Partial<Record<string, unknown>> = {};\n\n for (const [key, value] of Object.entries(data)) {\n if (predicate(value, key, data)) {\n out[key] = value;\n }\n }\n\n return out;\n}\n"],"mappings":"kGA6LA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAOA,EAAAA,MAAM,EAAsB,EAAK,CAG1C,SAAS,EACP,EACA,EACyB,CACzB,IAAM,EAAwC,EAAE,CAEhD,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAK,CACzC,EAAU,EAAO,EAAK,EAAK,GAC7B,EAAI,GAAO,GAIf,OAAO"}
package/dist/pickBy.js ADDED
@@ -0,0 +1,2 @@
1
+ import{purry as e}from"./purry.js";function t(...t){return e(n,t)}function n(e,t){let n={};for(let[r,i]of Object.entries(e))t(i,r,e)&&(n[r]=i);return n}export{t as pickBy};
2
+ //# sourceMappingURL=pickBy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pickBy.js","names":[],"sources":["../src/pickBy.ts"],"sourcesContent":["import type { IsNever, Simplify } from \"type-fest\";\nimport type { EnumerableStringKeyOf } from \"./internal/types/EnumerableStringKeyOf\";\nimport type { EnumerableStringKeyedValueOf } from \"./internal/types/EnumerableStringKeyedValueOf\";\nimport type { IsBoundedRecord } from \"./internal/types/IsBoundedRecord\";\nimport type { ToString } from \"./internal/types/ToString\";\nimport { purry } from \"./purry\";\n\n// When the predicate isn't a type-guard we don't know which properties would be\n// part of the output and which wouldn't so we can only safely downgrade the\n// whole object to a Partial of the input.\ntype EnumeratedPartial<T> = T extends unknown\n ? Simplify<\n IsBoundedRecord<T> extends true\n ? {\n // Object.entries returns keys as strings.\n -readonly [P in keyof T as ToString<P>]?: Required<T>[P];\n }\n : // For unbounded records (a simple Record with primitive `string` or\n // `number` keys) the return type here could technically be T; but for\n // cases where the record is unbounded but is more complex (like\n // `symbol` keys) we want to \"reconstruct\" the record from just its\n // enumerable components (which are the ones accessible via\n // `Object.entries`).\n Record<EnumerableStringKeyOf<T>, EnumerableStringKeyedValueOf<T>>\n >\n : never;\n\n// When the predicate is a type-guard we have more information to work with when\n// constructing the type of the output object. We can safely remove any property\n// which value would never come up true for the predicate, AND we can also\n// assume that properties that match the predicate perfectly would **always**\n// show up in the output object. Hence to build the output object we need to\n// build and merge 2 output objects: One for the properties which have a value\n// of at type that would always yield a `true` result from the predicate, these\n// are the \"matches\", which would not change the \"optionality\" of the input\n// object's props, and one for partial matches which would also make the props\n// optional (as they could have a value that would be filtered out).\ntype EnumeratedPartialNarrowed<T, S> = T extends unknown\n ? Simplify<\n IsBoundedRecord<T> extends true\n ? ExactProps<T, S> & PartialProps<T, S>\n : // For unbounded records we need to \"reconstruct\" the record and\n // narrow the value types. Similar to the non-narrowed case, we need\n // to also ignore `symbol` keys and any values that are only relevant\n // to them.\n Record<\n EnumerableStringKeyOf<T>,\n Extract<EnumerableStringKeyedValueOf<T>, S>\n >\n >\n : never;\n\n// The exact case, props here would always be part of the output object\ntype ExactProps<T, S> = {\n // Object.entries returns keys as strings.\n -readonly [P in keyof T as ToString<\n IsExactProp<T, P, S> extends true ? P : never\n >]: Extract<Required<T>[P], S>;\n};\n\n// The partial case, props here might be part of the output object, but might\n// not be, hence they are optional.\ntype PartialProps<T, S> = {\n // Object.entries returns keys as strings.\n -readonly [P in keyof T as ToString<\n IsPartialProp<T, P, S> extends true ? P : never\n >]?: IsNever<Extract<T[P], S>> extends true\n ? // If the result of extracting S from T[P] is never but S still extends\n // it, it means that T[P] is too wide and S can't be extracted from it:\n // e.g. if T[P] is `number` S is `1` then `Extract<number, 1> === never`.\n // For these cases we can return S directly as the type as it's already\n // very narrowed compared to T[P].\n S extends T[P]\n ? S\n : never\n : Extract<T[P], S>;\n};\n\n// If the input object's value type extends itself when the type-guard is\n// extracted from it we can safely assume that the predicate would always return\n// true for any value of that property.\ntype IsExactProp<T, P extends keyof T, S> =\n T[P] extends Extract<T[P], S> ? true : false;\n\n// ...and if the input object's value type isn't an exact match, but still has\n// some partial match (i.g. the extracted type-guard isn't completely disjoint)\n// then we can assume that the property can sometimes return true, and sometimes\n// false when passed to the predicate, hence it should be optional in the\n// output.\ntype IsPartialProp<T, P extends keyof T, S> =\n IsExactProp<T, P, S> extends true\n ? false\n : IsNever<Extract<T[P], S>> extends true\n ? S extends T[P]\n ? // If the result of extracting S from T[P] is never but S still\n // extends it, it means that T[P] is too wide and S can't be\n // extracted from it: e.g. if T[P] is `number` S is `1` then\n // `Extract<number, 1> === never`, but `1` extends `number`. We need\n // to handle these cases when we extract the value too (see above).\n true\n : false\n : true;\n\n/**\n * Iterates over the entries of `data` and reconstructs the object using only\n * entries that `predicate` accepts. Symbol keys are not passed to the predicate\n * and would be filtered out from the output object.\n *\n * See `omitBy` for a complementary function which starts with a shallow copy of\n * the input object and removes the entries that the predicate rejects. Because\n * it is subtractive symbol keys would be copied over to the output object.\n * See also `entries`, `filter`, and `fromEntries` which could be used to build\n * your own version of `pickBy` if you need more control (though the resulting\n * type might be less precise).\n *\n * @param data - The target object.\n * @param predicate - A function that takes the value, key, and the data itself\n * and returns true if the entry should be part of the output object, or `false`\n * to remove it. If the function is a type-guard on the value the output type\n * would be narrowed accordingly.\n * @returns A shallow copy of the input object with the rejected entries\n * removed.\n * @signature pickBy(data, predicate)\n * @example\n * pickBy({a: 1, b: 2, A: 3, B: 4}, (val, key) => key.toUpperCase() === key) // => {A: 3, B: 4}\n * @dataFirst\n * @category Object\n */\nexport function pickBy<\n T extends object,\n S extends EnumerableStringKeyedValueOf<T>,\n>(\n data: T,\n predicate: (\n value: EnumerableStringKeyedValueOf<T>,\n key: EnumerableStringKeyOf<T>,\n data: T,\n ) => value is S,\n): EnumeratedPartialNarrowed<T, S>;\nexport function pickBy<T extends object>(\n data: T,\n predicate: (\n value: EnumerableStringKeyedValueOf<T>,\n key: EnumerableStringKeyOf<T>,\n data: T,\n ) => boolean,\n): EnumeratedPartial<T>;\n\n/**\n * Iterates over the entries of `data` and reconstructs the object using only\n * entries that `predicate` accepts. Symbol keys are not passed to the predicate\n * and would be filtered out from the output object.\n *\n * See `omitBy` for a complementary function which starts with a shallow copy of\n * the input object and removes the entries that the predicate rejects. Because\n * it is subtractive symbol keys would be copied over to the output object.\n * See also `entries`, `filter`, and `fromEntries` which could be used to build\n * your own version of `pickBy` if you need more control (though the resulting\n * type might be less precise).\n *\n * @param predicate - A function that takes the value, key, and the data itself\n * and returns true if the entry should be part of the output object, or `false`\n * to remove it. If the function is a type-guard on the value the output type\n * would be narrowed accordingly.\n * @signature\n * pickBy(predicate)(data)\n * @example\n * pipe({a: 1, b: 2, A: 3, B: 4}, pickBy((val, key) => key.toUpperCase() === key)); // => {A: 3, B: 4}\n * @dataLast\n * @category Object\n */\nexport function pickBy<\n T extends object,\n S extends EnumerableStringKeyedValueOf<T>,\n>(\n predicate: (\n value: EnumerableStringKeyedValueOf<T>,\n key: EnumerableStringKeyOf<T>,\n data: T,\n ) => value is S,\n): (data: T) => EnumeratedPartialNarrowed<T, S>;\nexport function pickBy<T extends object>(\n predicate: (\n value: EnumerableStringKeyedValueOf<T>,\n key: EnumerableStringKeyOf<T>,\n data: T,\n ) => boolean,\n): (data: T) => EnumeratedPartial<T>;\n\nexport function pickBy(...args: readonly unknown[]): unknown {\n return purry(pickByImplementation, args);\n}\n\nfunction pickByImplementation<T extends object>(\n data: T,\n predicate: (value: unknown, key: string, data: T) => boolean,\n): Record<string, unknown> {\n const out: Partial<Record<string, unknown>> = {};\n\n for (const [key, value] of Object.entries(data)) {\n if (predicate(value, key, data)) {\n out[key] = value;\n }\n }\n\n return out;\n}\n"],"mappings":"mCA6LA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAO,EAAM,EAAsB,EAAK,CAG1C,SAAS,EACP,EACA,EACyB,CACzB,IAAM,EAAwC,EAAE,CAEhD,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAK,CACzC,EAAU,EAAO,EAAK,EAAK,GAC7B,EAAI,GAAO,GAIf,OAAO"}
package/dist/pipe.cjs ADDED
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./utilityEvaluators-CW0M8vMV.cjs`);function t(e,...t){let a=e,o=t.map(e=>`lazy`in e?r(e):void 0),s=0;for(;s<t.length;){if(o[s]===void 0||!i(a)){let e=t[s];a=e(a),s+=1;continue}let e=[];for(let n=s;n<t.length;n++){let t=o[n];if(t===void 0||(e.push(t),t.isSingle))break}let r=[];for(let t of a)if(n(t,r,e))break;let{isSingle:c}=e.at(-1);a=c?r[0]:r,s+=e.length}return a}function n(t,r,i){if(i.length===0)return r.push(t),!1;let a=t,o=e.t,s=!1;for(let[e,t]of i.entries()){let{index:c,items:l}=t;if(l.push(a),o=t(a,c,l),t.index+=1,o.hasNext){if(o.hasMany??!1){for(let t of o.next)if(n(t,r,i.slice(e+1)))return!0;return s}a=o.next}if(!o.hasNext)break;o.done&&(s=!0)}return o.hasNext&&r.push(a),s}function r(e){let{lazy:t,lazyArgs:n}=e,r=t(...n);return Object.assign(r,{isSingle:t.single??!1,index:0,items:[]})}function i(e){return typeof e==`string`||typeof e==`object`&&!!e&&Symbol.iterator in e}exports.pipe=t;
2
+ //# sourceMappingURL=pipe.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipe.cjs","names":["SKIP_ITEM"],"sources":["../src/pipe.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable jsdoc/check-param-names -- we don't document the op params, it'd be redundant */\n\nimport type { LazyDefinition } from \"./internal/types/LazyDefinition\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport type { LazyResult } from \"./internal/types/LazyResult\";\nimport { SKIP_ITEM } from \"./internal/utilityEvaluators\";\n\ntype PreparedLazyFunction = LazyEvaluator & {\n readonly isSingle: boolean;\n\n // These are intentionally mutable, they maintain the lazy piped state.\n index: number;\n items: unknown[];\n};\n\ntype LazyFunction = LazyDefinition & ((input: unknown) => unknown);\n\n/**\n * Performs left-to-right function composition, passing data through functions\n * in sequence. Each function receives the output of the previous function,\n * creating a readable top-to-bottom data flow that matches how the\n * transformation is executed. This enables converting deeply nested function\n * calls into clear, sequential steps without temporary variables.\n *\n * When consecutive functions with a `lazy` tag (e.g., `map`, `filter`, `take`,\n * `drop`, `forEach`, etc...) are used together, they process data item-by-item\n * rather than creating intermediate arrays. This enables early termination\n * when only partial results are needed, improving performance for large\n * datasets and expensive operations.\n *\n * Functions are only evaluated lazily when their data-last form is used\n * directly in the pipe. To disable lazy evaluation, use data-first calls via\n * arrow functions: `($) => map($, callback)` instead of `map(callback)`.\n *\n * Any function can be used in pipes, not just Remeda utilities. For creating\n * custom functions with currying and lazy evaluation support, see the `purry`\n * utility.\n *\n * A \"headless\" variant `piped` is available for creating reusable pipe\n * functions without initial data.\n *\n * IMPORTANT: During lazy evaluation, callbacks using the third parameter (the\n * input array) receive only items processed up to that point, not the complete\n * array.\n *\n * @param data - The input data.\n * @param functions - A sequence of functions that take one argument and\n * return a value.\n * @signature\n * pipe(data, ...functions);\n * @example\n * pipe([1, 2, 3], map(multiply(3))); //=> [3, 6, 9]\n *\n * // = Early termination with lazy evaluation =\n * pipe(\n * hugeArray,\n * map(expensiveComputation),\n * filter(complexPredicate),\n * // Only processes items until 2 results are found, then stops.\n * // Most of hugeArray never gets processed.\n * take(2),\n * );\n *\n * // = Custom logic within a pipe =\n * pipe(\n * input,\n * toLowerCase(),\n * normalize,\n * ($) => validate($, CONFIG),\n * split(\",\"),\n * unique(),\n * );\n *\n * // = Migrating nested transformations to pipes =\n * // Nested\n * const result = prop(\n * mapValues(groupByProp(users, \"department\"), length()),\n * \"engineering\",\n * );\n *\n * // Piped\n * const result = pipe(\n * users,\n * groupByProp(\"department\"),\n * mapValues(length()),\n * prop(\"engineering\"),\n * );\n *\n * // = Using the 3rd param of a callback =\n * // The following would print out `data` in its entirety for each value\n * // of `data`.\n * forEach([1, 2, 3, 4], (_item, _index, data) => {\n * console.log(data);\n * }); //=> \"[1, 2, 3, 4]\" logged 4 times\n *\n * // But with `pipe` data would only contain the items up to the current\n * // index\n * pipe([1, 2, 3, 4], forEach((_item, _index, data) => {\n * console.log(data);\n * })); //=> \"[1]\", \"[1, 2]\", \"[1, 2, 3]\", \"[1, 2, 3, 4]\"\n * @dataFirst\n * @category Function\n */\nexport function pipe<A>(data: A): A;\n\nexport function pipe<A, B>(data: A, funcA: (input: A) => B): B;\n\nexport function pipe<A, B, C>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n): C;\n\nexport function pipe<A, B, C, D>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n): D;\n\nexport function pipe<A, B, C, D, E>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n): E;\n\nexport function pipe<A, B, C, D, E, F>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n): F;\n\nexport function pipe<A, B, C, D, E, F, G>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n): G;\n\nexport function pipe<A, B, C, D, E, F, G, H>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n): H;\n\nexport function pipe<A, B, C, D, E, F, G, H, I>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n): I;\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n): J;\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n): K;\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n funcK: (input: K) => L,\n): L;\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n funcK: (input: K) => L,\n funcL: (input: L) => M,\n): M;\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n funcK: (input: K) => L,\n funcL: (input: L) => M,\n funcM: (input: M) => N,\n): N;\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n funcK: (input: K) => L,\n funcL: (input: L) => M,\n funcM: (input: M) => N,\n funcN: (input: N) => O,\n): O;\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n funcK: (input: K) => L,\n funcL: (input: L) => M,\n funcM: (input: M) => N,\n funcN: (input: N) => O,\n funcO: (input: O) => P,\n): P;\n\nexport function pipe(\n input: unknown,\n ...functions: readonly (LazyFunction | ((value: any) => unknown))[]\n): any {\n let output = input;\n\n const lazyFunctions = functions.map((op) =>\n \"lazy\" in op ? prepareLazyFunction(op) : undefined,\n );\n\n let functionIndex = 0;\n while (functionIndex < functions.length) {\n const lazyFunction = lazyFunctions[functionIndex];\n if (lazyFunction === undefined || !isIterable(output)) {\n const func = functions[functionIndex]!;\n output = func(output);\n functionIndex += 1;\n continue;\n }\n\n const lazySequence: PreparedLazyFunction[] = [];\n for (let index = functionIndex; index < functions.length; index++) {\n const lazyOp = lazyFunctions[index];\n if (lazyOp === undefined) {\n break;\n }\n\n lazySequence.push(lazyOp);\n if (lazyOp.isSingle) {\n break;\n }\n }\n\n const accumulator: unknown[] = [];\n\n for (const value of output) {\n const shouldExitEarly = processItem(value, accumulator, lazySequence);\n if (shouldExitEarly) {\n break;\n }\n }\n\n const { isSingle } = lazySequence.at(-1)!;\n output = isSingle ? accumulator[0] : accumulator;\n functionIndex += lazySequence.length;\n }\n return output;\n}\n\nfunction processItem(\n item: unknown,\n // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types -- Intentionally mutable, we use the accumulator directly to accumulate the results.\n accumulator: unknown[],\n // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types -- Intentionally mutable, the lazy sequence is stateful and contains the state needed to compute the next value lazily.\n lazySequence: readonly PreparedLazyFunction[],\n): boolean {\n if (lazySequence.length === 0) {\n accumulator.push(item);\n return false;\n }\n\n let currentItem = item;\n\n let lazyResult: LazyResult<any> = SKIP_ITEM;\n let isDone = false;\n for (const [functionsIndex, lazyFn] of lazySequence.entries()) {\n const { index, items } = lazyFn;\n items.push(currentItem);\n lazyResult = lazyFn(currentItem, index, items);\n lazyFn.index += 1;\n if (lazyResult.hasNext) {\n if (lazyResult.hasMany ?? false) {\n for (const subItem of lazyResult.next as readonly unknown[]) {\n const subResult = processItem(\n subItem,\n accumulator,\n lazySequence.slice(functionsIndex + 1),\n );\n if (subResult) {\n return true;\n }\n }\n return isDone;\n }\n currentItem = lazyResult.next;\n }\n if (!lazyResult.hasNext) {\n break;\n }\n // process remaining functions in the pipe\n // but don't process remaining elements in the input array\n if (lazyResult.done) {\n isDone = true;\n }\n }\n if (lazyResult.hasNext) {\n accumulator.push(currentItem);\n }\n return isDone;\n}\n\nfunction prepareLazyFunction(func: LazyFunction): PreparedLazyFunction {\n const { lazy, lazyArgs } = func;\n const fn = lazy(...lazyArgs);\n return Object.assign(fn, {\n isSingle: lazy.single ?? false,\n index: 0,\n items: [] as unknown[],\n });\n}\n\nfunction isIterable(something: unknown): something is Iterable<unknown> {\n // Check for null and undefined to avoid errors when accessing Symbol.iterator\n return (\n typeof something === \"string\" ||\n (typeof something === \"object\" &&\n something !== null &&\n Symbol.iterator in something)\n );\n}\n"],"mappings":"uHA2RA,SAAgB,EACd,EACA,GAAG,EACE,CACL,IAAI,EAAS,EAEP,EAAgB,EAAU,IAAK,GACnC,SAAU,EAAK,EAAoB,EAAG,CAAG,IAAA,GAC1C,CAEG,EAAgB,EACpB,KAAO,EAAgB,EAAU,QAAQ,CAEvC,GADqB,EAAc,KACd,IAAA,IAAa,CAAC,EAAW,EAAO,CAAE,CACrD,IAAM,EAAO,EAAU,GACvB,EAAS,EAAK,EAAO,CACrB,GAAiB,EACjB,SAGF,IAAM,EAAuC,EAAE,CAC/C,IAAK,IAAI,EAAQ,EAAe,EAAQ,EAAU,OAAQ,IAAS,CACjE,IAAM,EAAS,EAAc,GAM7B,GALI,IAAW,IAAA,KAIf,EAAa,KAAK,EAAO,CACrB,EAAO,UACT,MAIJ,IAAM,EAAyB,EAAE,CAEjC,IAAK,IAAM,KAAS,EAElB,GADwB,EAAY,EAAO,EAAa,EAAa,CAEnE,MAIJ,GAAM,CAAE,YAAa,EAAa,GAAG,GAAG,CACxC,EAAS,EAAW,EAAY,GAAK,EACrC,GAAiB,EAAa,OAEhC,OAAO,EAGT,SAAS,EACP,EAEA,EAEA,EACS,CACT,GAAI,EAAa,SAAW,EAE1B,OADA,EAAY,KAAK,EAAK,CACf,GAGT,IAAI,EAAc,EAEd,EAA8BA,EAAAA,EAC9B,EAAS,GACb,IAAK,GAAM,CAAC,EAAgB,KAAW,EAAa,SAAS,CAAE,CAC7D,GAAM,CAAE,QAAO,SAAU,EAIzB,GAHA,EAAM,KAAK,EAAY,CACvB,EAAa,EAAO,EAAa,EAAO,EAAM,CAC9C,EAAO,OAAS,EACZ,EAAW,QAAS,CACtB,GAAI,EAAW,SAAW,GAAO,CAC/B,IAAK,IAAM,KAAW,EAAW,KAM/B,GALkB,EAChB,EACA,EACA,EAAa,MAAM,EAAiB,EAAE,CACvC,CAEC,MAAO,GAGX,OAAO,EAET,EAAc,EAAW,KAE3B,GAAI,CAAC,EAAW,QACd,MAIE,EAAW,OACb,EAAS,IAMb,OAHI,EAAW,SACb,EAAY,KAAK,EAAY,CAExB,EAGT,SAAS,EAAoB,EAA0C,CACrE,GAAM,CAAE,OAAM,YAAa,EACrB,EAAK,EAAK,GAAG,EAAS,CAC5B,OAAO,OAAO,OAAO,EAAI,CACvB,SAAU,EAAK,QAAU,GACzB,MAAO,EACP,MAAO,EAAE,CACV,CAAC,CAGJ,SAAS,EAAW,EAAoD,CAEtE,OACE,OAAO,GAAc,UACpB,OAAO,GAAc,YACpB,GACA,OAAO,YAAY"}
package/dist/pipe.js ADDED
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./utilityEvaluators-BQqW5Ir5.js";function t(e,...t){let a=e,o=t.map(e=>`lazy`in e?r(e):void 0),s=0;for(;s<t.length;){if(o[s]===void 0||!i(a)){let e=t[s];a=e(a),s+=1;continue}let e=[];for(let n=s;n<t.length;n++){let t=o[n];if(t===void 0||(e.push(t),t.isSingle))break}let r=[];for(let t of a)if(n(t,r,e))break;let{isSingle:c}=e.at(-1);a=c?r[0]:r,s+=e.length}return a}function n(t,r,i){if(i.length===0)return r.push(t),!1;let a=t,o=e,s=!1;for(let[e,t]of i.entries()){let{index:c,items:l}=t;if(l.push(a),o=t(a,c,l),t.index+=1,o.hasNext){if(o.hasMany??!1){for(let t of o.next)if(n(t,r,i.slice(e+1)))return!0;return s}a=o.next}if(!o.hasNext)break;o.done&&(s=!0)}return o.hasNext&&r.push(a),s}function r(e){let{lazy:t,lazyArgs:n}=e,r=t(...n);return Object.assign(r,{isSingle:t.single??!1,index:0,items:[]})}function i(e){return typeof e==`string`||typeof e==`object`&&!!e&&Symbol.iterator in e}export{t as pipe};
2
+ //# sourceMappingURL=pipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipe.js","names":[],"sources":["../src/pipe.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable jsdoc/check-param-names -- we don't document the op params, it'd be redundant */\n\nimport type { LazyDefinition } from \"./internal/types/LazyDefinition\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport type { LazyResult } from \"./internal/types/LazyResult\";\nimport { SKIP_ITEM } from \"./internal/utilityEvaluators\";\n\ntype PreparedLazyFunction = LazyEvaluator & {\n readonly isSingle: boolean;\n\n // These are intentionally mutable, they maintain the lazy piped state.\n index: number;\n items: unknown[];\n};\n\ntype LazyFunction = LazyDefinition & ((input: unknown) => unknown);\n\n/**\n * Performs left-to-right function composition, passing data through functions\n * in sequence. Each function receives the output of the previous function,\n * creating a readable top-to-bottom data flow that matches how the\n * transformation is executed. This enables converting deeply nested function\n * calls into clear, sequential steps without temporary variables.\n *\n * When consecutive functions with a `lazy` tag (e.g., `map`, `filter`, `take`,\n * `drop`, `forEach`, etc...) are used together, they process data item-by-item\n * rather than creating intermediate arrays. This enables early termination\n * when only partial results are needed, improving performance for large\n * datasets and expensive operations.\n *\n * Functions are only evaluated lazily when their data-last form is used\n * directly in the pipe. To disable lazy evaluation, use data-first calls via\n * arrow functions: `($) => map($, callback)` instead of `map(callback)`.\n *\n * Any function can be used in pipes, not just Remeda utilities. For creating\n * custom functions with currying and lazy evaluation support, see the `purry`\n * utility.\n *\n * A \"headless\" variant `piped` is available for creating reusable pipe\n * functions without initial data.\n *\n * IMPORTANT: During lazy evaluation, callbacks using the third parameter (the\n * input array) receive only items processed up to that point, not the complete\n * array.\n *\n * @param data - The input data.\n * @param functions - A sequence of functions that take one argument and\n * return a value.\n * @signature\n * pipe(data, ...functions);\n * @example\n * pipe([1, 2, 3], map(multiply(3))); //=> [3, 6, 9]\n *\n * // = Early termination with lazy evaluation =\n * pipe(\n * hugeArray,\n * map(expensiveComputation),\n * filter(complexPredicate),\n * // Only processes items until 2 results are found, then stops.\n * // Most of hugeArray never gets processed.\n * take(2),\n * );\n *\n * // = Custom logic within a pipe =\n * pipe(\n * input,\n * toLowerCase(),\n * normalize,\n * ($) => validate($, CONFIG),\n * split(\",\"),\n * unique(),\n * );\n *\n * // = Migrating nested transformations to pipes =\n * // Nested\n * const result = prop(\n * mapValues(groupByProp(users, \"department\"), length()),\n * \"engineering\",\n * );\n *\n * // Piped\n * const result = pipe(\n * users,\n * groupByProp(\"department\"),\n * mapValues(length()),\n * prop(\"engineering\"),\n * );\n *\n * // = Using the 3rd param of a callback =\n * // The following would print out `data` in its entirety for each value\n * // of `data`.\n * forEach([1, 2, 3, 4], (_item, _index, data) => {\n * console.log(data);\n * }); //=> \"[1, 2, 3, 4]\" logged 4 times\n *\n * // But with `pipe` data would only contain the items up to the current\n * // index\n * pipe([1, 2, 3, 4], forEach((_item, _index, data) => {\n * console.log(data);\n * })); //=> \"[1]\", \"[1, 2]\", \"[1, 2, 3]\", \"[1, 2, 3, 4]\"\n * @dataFirst\n * @category Function\n */\nexport function pipe<A>(data: A): A;\n\nexport function pipe<A, B>(data: A, funcA: (input: A) => B): B;\n\nexport function pipe<A, B, C>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n): C;\n\nexport function pipe<A, B, C, D>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n): D;\n\nexport function pipe<A, B, C, D, E>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n): E;\n\nexport function pipe<A, B, C, D, E, F>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n): F;\n\nexport function pipe<A, B, C, D, E, F, G>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n): G;\n\nexport function pipe<A, B, C, D, E, F, G, H>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n): H;\n\nexport function pipe<A, B, C, D, E, F, G, H, I>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n): I;\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n): J;\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n): K;\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n funcK: (input: K) => L,\n): L;\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n funcK: (input: K) => L,\n funcL: (input: L) => M,\n): M;\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n funcK: (input: K) => L,\n funcL: (input: L) => M,\n funcM: (input: M) => N,\n): N;\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n funcK: (input: K) => L,\n funcL: (input: L) => M,\n funcM: (input: M) => N,\n funcN: (input: N) => O,\n): O;\n\nexport function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(\n data: A,\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n funcK: (input: K) => L,\n funcL: (input: L) => M,\n funcM: (input: M) => N,\n funcN: (input: N) => O,\n funcO: (input: O) => P,\n): P;\n\nexport function pipe(\n input: unknown,\n ...functions: readonly (LazyFunction | ((value: any) => unknown))[]\n): any {\n let output = input;\n\n const lazyFunctions = functions.map((op) =>\n \"lazy\" in op ? prepareLazyFunction(op) : undefined,\n );\n\n let functionIndex = 0;\n while (functionIndex < functions.length) {\n const lazyFunction = lazyFunctions[functionIndex];\n if (lazyFunction === undefined || !isIterable(output)) {\n const func = functions[functionIndex]!;\n output = func(output);\n functionIndex += 1;\n continue;\n }\n\n const lazySequence: PreparedLazyFunction[] = [];\n for (let index = functionIndex; index < functions.length; index++) {\n const lazyOp = lazyFunctions[index];\n if (lazyOp === undefined) {\n break;\n }\n\n lazySequence.push(lazyOp);\n if (lazyOp.isSingle) {\n break;\n }\n }\n\n const accumulator: unknown[] = [];\n\n for (const value of output) {\n const shouldExitEarly = processItem(value, accumulator, lazySequence);\n if (shouldExitEarly) {\n break;\n }\n }\n\n const { isSingle } = lazySequence.at(-1)!;\n output = isSingle ? accumulator[0] : accumulator;\n functionIndex += lazySequence.length;\n }\n return output;\n}\n\nfunction processItem(\n item: unknown,\n // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types -- Intentionally mutable, we use the accumulator directly to accumulate the results.\n accumulator: unknown[],\n // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types -- Intentionally mutable, the lazy sequence is stateful and contains the state needed to compute the next value lazily.\n lazySequence: readonly PreparedLazyFunction[],\n): boolean {\n if (lazySequence.length === 0) {\n accumulator.push(item);\n return false;\n }\n\n let currentItem = item;\n\n let lazyResult: LazyResult<any> = SKIP_ITEM;\n let isDone = false;\n for (const [functionsIndex, lazyFn] of lazySequence.entries()) {\n const { index, items } = lazyFn;\n items.push(currentItem);\n lazyResult = lazyFn(currentItem, index, items);\n lazyFn.index += 1;\n if (lazyResult.hasNext) {\n if (lazyResult.hasMany ?? false) {\n for (const subItem of lazyResult.next as readonly unknown[]) {\n const subResult = processItem(\n subItem,\n accumulator,\n lazySequence.slice(functionsIndex + 1),\n );\n if (subResult) {\n return true;\n }\n }\n return isDone;\n }\n currentItem = lazyResult.next;\n }\n if (!lazyResult.hasNext) {\n break;\n }\n // process remaining functions in the pipe\n // but don't process remaining elements in the input array\n if (lazyResult.done) {\n isDone = true;\n }\n }\n if (lazyResult.hasNext) {\n accumulator.push(currentItem);\n }\n return isDone;\n}\n\nfunction prepareLazyFunction(func: LazyFunction): PreparedLazyFunction {\n const { lazy, lazyArgs } = func;\n const fn = lazy(...lazyArgs);\n return Object.assign(fn, {\n isSingle: lazy.single ?? false,\n index: 0,\n items: [] as unknown[],\n });\n}\n\nfunction isIterable(something: unknown): something is Iterable<unknown> {\n // Check for null and undefined to avoid errors when accessing Symbol.iterator\n return (\n typeof something === \"string\" ||\n (typeof something === \"object\" &&\n something !== null &&\n Symbol.iterator in something)\n );\n}\n"],"mappings":"oDA2RA,SAAgB,EACd,EACA,GAAG,EACE,CACL,IAAI,EAAS,EAEP,EAAgB,EAAU,IAAK,GACnC,SAAU,EAAK,EAAoB,EAAG,CAAG,IAAA,GAC1C,CAEG,EAAgB,EACpB,KAAO,EAAgB,EAAU,QAAQ,CAEvC,GADqB,EAAc,KACd,IAAA,IAAa,CAAC,EAAW,EAAO,CAAE,CACrD,IAAM,EAAO,EAAU,GACvB,EAAS,EAAK,EAAO,CACrB,GAAiB,EACjB,SAGF,IAAM,EAAuC,EAAE,CAC/C,IAAK,IAAI,EAAQ,EAAe,EAAQ,EAAU,OAAQ,IAAS,CACjE,IAAM,EAAS,EAAc,GAM7B,GALI,IAAW,IAAA,KAIf,EAAa,KAAK,EAAO,CACrB,EAAO,UACT,MAIJ,IAAM,EAAyB,EAAE,CAEjC,IAAK,IAAM,KAAS,EAElB,GADwB,EAAY,EAAO,EAAa,EAAa,CAEnE,MAIJ,GAAM,CAAE,YAAa,EAAa,GAAG,GAAG,CACxC,EAAS,EAAW,EAAY,GAAK,EACrC,GAAiB,EAAa,OAEhC,OAAO,EAGT,SAAS,EACP,EAEA,EAEA,EACS,CACT,GAAI,EAAa,SAAW,EAE1B,OADA,EAAY,KAAK,EAAK,CACf,GAGT,IAAI,EAAc,EAEd,EAA8B,EAC9B,EAAS,GACb,IAAK,GAAM,CAAC,EAAgB,KAAW,EAAa,SAAS,CAAE,CAC7D,GAAM,CAAE,QAAO,SAAU,EAIzB,GAHA,EAAM,KAAK,EAAY,CACvB,EAAa,EAAO,EAAa,EAAO,EAAM,CAC9C,EAAO,OAAS,EACZ,EAAW,QAAS,CACtB,GAAI,EAAW,SAAW,GAAO,CAC/B,IAAK,IAAM,KAAW,EAAW,KAM/B,GALkB,EAChB,EACA,EACA,EAAa,MAAM,EAAiB,EAAE,CACvC,CAEC,MAAO,GAGX,OAAO,EAET,EAAc,EAAW,KAE3B,GAAI,CAAC,EAAW,QACd,MAIE,EAAW,OACb,EAAS,IAMb,OAHI,EAAW,SACb,EAAY,KAAK,EAAY,CAExB,EAGT,SAAS,EAAoB,EAA0C,CACrE,GAAM,CAAE,OAAM,YAAa,EACrB,EAAK,EAAK,GAAG,EAAS,CAC5B,OAAO,OAAO,OAAO,EAAI,CACvB,SAAU,EAAK,QAAU,GACzB,MAAO,EACP,MAAO,EAAE,CACV,CAAC,CAGJ,SAAS,EAAW,EAAoD,CAEtE,OACE,OAAO,GAAc,UACpB,OAAO,GAAc,YACpB,GACA,OAAO,YAAY"}
package/dist/piped.cjs ADDED
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./pipe.cjs`);function t(...t){return n=>e.pipe(n,...t)}exports.piped=t;
2
+ //# sourceMappingURL=piped.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"piped.cjs","names":["pipe"],"sources":["../src/piped.ts"],"sourcesContent":["import { pipe } from \"./pipe\";\n\n/**\n * Data-last version of `pipe`. See `pipe` documentation for full details.\n *\n * Use `piped` when you need to pass a transformation as a callback to\n * functions like `map` and `filter`, where the data type can be inferred\n * from the call site.\n *\n * IMPORTANT: `piped` does not work as a \"function factory\" in order to create\n * standalone utility functions; because TypeScript cannot infer the input data\n * type (without requiring to explicitly define all type params for all\n * functions in the pipe). We recommend defining the function explicitly, and\n * then use `pipe` in its implementation.\n *\n * @signature\n * piped(...functions)(data);\n * @example\n * map(\n * [{ a: 1 }, { a: 2 }, { a: 3 }],\n * piped(prop('a'), add(1)),\n * ); //=> [2, 3, 4]\n * @dataLast\n * @category Function\n */\nexport function piped<A>(): (data: A) => A;\n\nexport function piped<A, B>(funcA: (input: A) => B): (data: A) => B;\n\nexport function piped<A, B, C>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n): (data: A) => C;\n\nexport function piped<A, B, C, D>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n): (data: A) => D;\n\nexport function piped<A, B, C, D, E>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n): (data: A) => E;\n\nexport function piped<A, B, C, D, E, F>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n): (data: A) => F;\n\nexport function piped<A, B, C, D, E, F, G>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n): (data: A) => G;\n\nexport function piped<A, B, C, D, E, F, G, H>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n): (data: A) => H;\n\nexport function piped<A, B, C, D, E, F, G, H, I>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n): (data: A) => I;\n\nexport function piped<A, B, C, D, E, F, G, H, I, J>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n): (data: A) => J;\n\nexport function piped<A, B, C, D, E, F, G, H, I, J, K>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n): (data: A) => K;\n\nexport function piped<A, B, C, D, E, F, G, H, I, J, K, L>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n funcK: (input: K) => L,\n): (data: A) => L;\n\nexport function piped<A, B, C, D, E, F, G, H, I, J, K, L, M>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n funcK: (input: K) => L,\n funcL: (input: L) => M,\n): (data: A) => M;\n\nexport function piped<A, B, C, D, E, F, G, H, I, J, K, L, M, N>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n funcK: (input: K) => L,\n funcL: (input: L) => M,\n funcM: (input: M) => N,\n): (data: A) => N;\n\nexport function piped<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n funcK: (input: K) => L,\n funcL: (input: L) => M,\n funcM: (input: M) => N,\n funcN: (input: N) => O,\n): (data: A) => O;\n\nexport function piped<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n funcK: (input: K) => L,\n funcL: (input: L) => M,\n funcM: (input: M) => N,\n funcN: (input: N) => O,\n funcO: (input: O) => P,\n): (data: A) => P;\n\nexport function piped(...functions: readonly ((input: unknown) => unknown)[]) {\n return (value: unknown): unknown =>\n pipe(\n value,\n // @ts-expect-error [ts2556] - We can't avoid this error because pipe is typed for users and this is an internal function\n ...functions,\n );\n}\n"],"mappings":"iGA8LA,SAAgB,EAAM,GAAG,EAAqD,CAC5E,MAAQ,IACNA,EAAAA,KACE,EAEA,GAAG,EACJ"}
package/dist/piped.js ADDED
@@ -0,0 +1,2 @@
1
+ import{pipe as e}from"./pipe.js";function t(...t){return n=>e(n,...t)}export{t as piped};
2
+ //# sourceMappingURL=piped.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"piped.js","names":[],"sources":["../src/piped.ts"],"sourcesContent":["import { pipe } from \"./pipe\";\n\n/**\n * Data-last version of `pipe`. See `pipe` documentation for full details.\n *\n * Use `piped` when you need to pass a transformation as a callback to\n * functions like `map` and `filter`, where the data type can be inferred\n * from the call site.\n *\n * IMPORTANT: `piped` does not work as a \"function factory\" in order to create\n * standalone utility functions; because TypeScript cannot infer the input data\n * type (without requiring to explicitly define all type params for all\n * functions in the pipe). We recommend defining the function explicitly, and\n * then use `pipe` in its implementation.\n *\n * @signature\n * piped(...functions)(data);\n * @example\n * map(\n * [{ a: 1 }, { a: 2 }, { a: 3 }],\n * piped(prop('a'), add(1)),\n * ); //=> [2, 3, 4]\n * @dataLast\n * @category Function\n */\nexport function piped<A>(): (data: A) => A;\n\nexport function piped<A, B>(funcA: (input: A) => B): (data: A) => B;\n\nexport function piped<A, B, C>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n): (data: A) => C;\n\nexport function piped<A, B, C, D>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n): (data: A) => D;\n\nexport function piped<A, B, C, D, E>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n): (data: A) => E;\n\nexport function piped<A, B, C, D, E, F>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n): (data: A) => F;\n\nexport function piped<A, B, C, D, E, F, G>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n): (data: A) => G;\n\nexport function piped<A, B, C, D, E, F, G, H>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n): (data: A) => H;\n\nexport function piped<A, B, C, D, E, F, G, H, I>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n): (data: A) => I;\n\nexport function piped<A, B, C, D, E, F, G, H, I, J>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n): (data: A) => J;\n\nexport function piped<A, B, C, D, E, F, G, H, I, J, K>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n): (data: A) => K;\n\nexport function piped<A, B, C, D, E, F, G, H, I, J, K, L>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n funcK: (input: K) => L,\n): (data: A) => L;\n\nexport function piped<A, B, C, D, E, F, G, H, I, J, K, L, M>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n funcK: (input: K) => L,\n funcL: (input: L) => M,\n): (data: A) => M;\n\nexport function piped<A, B, C, D, E, F, G, H, I, J, K, L, M, N>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n funcK: (input: K) => L,\n funcL: (input: L) => M,\n funcM: (input: M) => N,\n): (data: A) => N;\n\nexport function piped<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n funcK: (input: K) => L,\n funcL: (input: L) => M,\n funcM: (input: M) => N,\n funcN: (input: N) => O,\n): (data: A) => O;\n\nexport function piped<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(\n funcA: (input: A) => B,\n funcB: (input: B) => C,\n funcC: (input: C) => D,\n funcD: (input: D) => E,\n funcE: (input: E) => F,\n funcF: (input: F) => G,\n funcG: (input: G) => H,\n funcH: (input: H) => I,\n funcI: (input: I) => J,\n funcJ: (input: J) => K,\n funcK: (input: K) => L,\n funcL: (input: L) => M,\n funcM: (input: M) => N,\n funcN: (input: N) => O,\n funcO: (input: O) => P,\n): (data: A) => P;\n\nexport function piped(...functions: readonly ((input: unknown) => unknown)[]) {\n return (value: unknown): unknown =>\n pipe(\n value,\n // @ts-expect-error [ts2556] - We can't avoid this error because pipe is typed for users and this is an internal function\n ...functions,\n );\n}\n"],"mappings":"iCA8LA,SAAgB,EAAM,GAAG,EAAqD,CAC5E,MAAQ,IACN,EACE,EAEA,GAAG,EACJ"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`);function t(...t){return e.purry(n,t)}function n(e){let t=typeof e[0]==`bigint`?1n:1;for(let n of e)t*=n;return t}exports.product=t;
2
+ //# sourceMappingURL=product.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product.cjs","names":["purry"],"sources":["../src/product.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\ntype Product<T extends IterableContainer<bigint> | IterableContainer<number>> =\n // Empty arrays would always result in a product of (a non-bigint) 1\n T extends readonly []\n ? 1\n : // Non-empty bigint arrays will always result in a bigint product.\n T extends readonly [bigint, ...(readonly unknown[])]\n ? bigint\n : // But an empty bigint array would result in a non-bigint 1.\n T[number] extends bigint\n ? bigint | 1\n : // Non-bigint arrays are always handled correctly.\n number;\n\n/**\n * Compute the product of the numbers in the array, or return 1 for an empty\n * array.\n *\n * Works for both `number` and `bigint` arrays, but not arrays that contain both\n * types.\n *\n * IMPORTANT: The result for empty arrays would be 1 (`number`) regardless of\n * the type of the array; to avoid adding this to the return type for cases\n * where the array is known to be non-empty you can use `hasAtLeast` or\n * `isEmpty` to guard against this case.\n *\n * @param data - The array of numbers.\n * @signature\n * product(data);\n * @example\n * product([1, 2, 3]); // => 6\n * product([1n, 2n, 3n]); // => 6n\n * product([]); // => 1\n * @dataFirst\n * @category Number\n */\nexport function product<\n T extends IterableContainer<bigint> | IterableContainer<number>,\n>(data: T): Product<T>;\n\n/**\n * Compute the product of the numbers in the array, or return 1 for an empty\n * array.\n *\n * Works for both `number` and `bigint` arrays, but not arrays that contain both\n * types.\n *\n * IMPORTANT: The result for empty arrays would be 1 (`number`) regardless of\n * the type of the array; to avoid adding this to the return type for cases\n * where the array is known to be non-empty you can use `hasAtLeast` or\n * `isEmpty` to guard against this case.\n *\n * @signature\n * product()(data);\n * @example\n * pipe([1, 2, 3], product()); // => 6\n * pipe([1n, 2n, 3n], product()); // => 6n\n * pipe([], product()); // => 1\n * @dataLast\n * @category Number\n */\nexport function product(): <\n T extends IterableContainer<bigint> | IterableContainer<number>,\n>(\n data: T,\n) => Product<T>;\n\nexport function product(...args: readonly unknown[]): unknown {\n return purry(productImplementation, args);\n}\n\nfunction productImplementation<\n T extends IterableContainer<bigint> | IterableContainer<number>,\n>(data: T): T[number] {\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers -- The rule differentiates 1 and 1n :(\n let out = typeof data[0] === \"bigint\" ? 1n : 1;\n for (const value of data) {\n // @ts-expect-error [ts2365] -- Typescript can't infer that all elements will be a number of the same type.\n out *= value;\n }\n return out;\n}\n"],"mappings":"kGAqEA,SAAgB,EAAQ,GAAG,EAAmC,CAC5D,OAAOA,EAAAA,MAAM,EAAuB,EAAK,CAG3C,SAAS,EAEP,EAAoB,CAEpB,IAAI,EAAM,OAAO,EAAK,IAAO,SAAW,GAAK,EAC7C,IAAK,IAAM,KAAS,EAElB,GAAO,EAET,OAAO"}
@@ -0,0 +1,2 @@
1
+ import{purry as e}from"./purry.js";function t(...t){return e(n,t)}function n(e){let t=typeof e[0]==`bigint`?1n:1;for(let n of e)t*=n;return t}export{t as product};
2
+ //# sourceMappingURL=product.js.map