@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":"sample.js","names":[],"sources":["../src/sample.ts"],"sourcesContent":["import type {\n FixedLengthArray,\n IsEqual,\n IsNever,\n NonNegativeInteger,\n Or,\n Writable,\n} from \"type-fest\";\nimport type { CoercedArray } from \"./internal/types/CoercedArray\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { NTuple } from \"./internal/types/NTuple\";\nimport type { PartialArray } from \"./internal/types/PartialArray\";\nimport type { TupleParts } from \"./internal/types/TupleParts\";\nimport { purry } from \"./purry\";\n\ntype Sampled<T extends IterableContainer, N extends number> =\n Or<IsEqual<N, 0>, IsEqual<T[\"length\"], 0>> extends true\n ? // Short-circuit on trivial inputs.\n []\n : IsNever<NonNegativeInteger<N>> extends true\n ? SampledPrimitive<T>\n : IsLongerThan<T, N> extends true\n ? SampledLiteral<T, N>\n : // If our tuple can never fulfil the sample size the only valid sample\n // is the whole input tuple. Because it's a shallow clone we also\n // strip any readonly-ness.\n Writable<T>;\n\n/**\n * When N is not a non-negative integer **literal** we can't use it in our\n * reconstructing logic so we fallback to a simpler definition of the output of\n * sample, which is any sub-tuple shape of T, of **any length**.\n */\ntype SampledPrimitive<T extends IterableContainer> = [\n ...FixedSubTuples<TupleParts<T>[\"required\"]>,\n // TODO: This might be accurate, but We currently have no tests that check optional elements!\n ...PartialArray<FixedSubTuples<TupleParts<T>[\"optional\"]>>,\n ...CoercedArray<TupleParts<T>[\"item\"]>,\n ...FixedSubTuples<TupleParts<T>[\"suffix\"]>,\n];\n\n/**\n * Knowing N is a non-negative literal integer we can construct all sub-tuples\n * of T that are exactly N elements long.\n */\ntype SampledLiteral<T extends IterableContainer, N extends number> =\n | Extract<\n FixedSubTuples<\n [\n ...TupleParts<T>[\"required\"],\n // TODO: This deliberately ignores optional elements which we don't have tests for either. In order to handle optional elements we can treat the \"optional\" tuple-part as more required elements.\n // We add N elements of the `item` type to the tuple so that we\n // consider any combination possible of elements of the prefix items,\n // any amount of rest items, and suffix items.\n ...(IsNever<TupleParts<T>[\"item\"]> extends true\n ? []\n : NTuple<TupleParts<T>[\"item\"], N>),\n ...TupleParts<T>[\"suffix\"],\n ]\n >,\n // This is just [unknown, unknown, ..., unknown] with N elements.\n FixedLengthArray<unknown, N>\n >\n // In addition to all sub-tuples of length N, we also need to consider all\n // tuples where the input is shorter than N. This will contribute exactly\n // one sub-tuple at each length from the minimum length of T and up to N-1.\n | SubSampled<\n TupleParts<T>[\"required\"],\n // TODO: This deliberately ignores optional elements which we don't have tests for either. In order to handle optional elements we can treat the \"optional\" tuple-part as more required elements.\n TupleParts<T>[\"item\"],\n TupleParts<T>[\"suffix\"],\n N\n >;\n\n// We want to create a union of all sub-tuples where we incrementally add an\n// additional element of the type of the rest element in the middle between the\n// prefix and suffix until we \"fill\" the tuple to size N.\ntype SubSampled<\n Prefix extends readonly unknown[],\n Item,\n Suffix extends readonly unknown[],\n N extends number,\n> =\n IsLongerThan<[...Prefix, ...Suffix], N> extends true\n ? // We need to prevent overflows in case Prefix and Suffix are already long\n // enough\n never\n : [...Prefix, ...Suffix][\"length\"] extends N\n ? never\n : [...Prefix, ...Suffix] | SubSampled<[...Prefix, Item], Item, Suffix, N>;\n\ntype IsLongerThan<T extends readonly unknown[], N extends number> =\n // Checking for `undefined` is a neat trick to avoid needing to compare\n // integer literals because if N overflows the tuple then the type for that\n // element will be `undefined`. This only works for fixed tuples!\n IsEqual<T[N], undefined> extends true ? false : true;\n\n// Assuming T is a fixed tuple we build all it's possible sub-tuples.\ntype FixedSubTuples<T> = T extends readonly [infer Head, ...infer Rest]\n ? // For each element we either take it or skip it, and recurse over the rest.\n FixedSubTuples<Rest> | [Head, ...FixedSubTuples<Rest>]\n : [];\n\n/**\n * Returns a random subset of size `sampleSize` from `array`.\n *\n * Maintains and infers most of the typing information that could be passed\n * along to the output. This means that when using tuples, the output will be\n * a tuple too, and when using literals, those literals would be preserved.\n *\n * The items in the result are kept in the same order as they are in the input.\n * If you need to get a shuffled response you can pipe the shuffle function\n * after this one.\n *\n * @param data - The array.\n * @param sampleSize - The number of elements to take.\n * @signature\n * sample(array, sampleSize)\n * @example\n * sample([\"hello\", \"world\"], 1); // => [\"hello\"] // typed string[]\n * sample([\"hello\", \"world\"] as const, 1); // => [\"world\"] // typed [\"hello\" | \"world\"]\n * @dataFirst\n * @category Array\n */\nexport function sample<const T extends IterableContainer, N extends number>(\n data: T,\n sampleSize: N,\n): Sampled<T, N>;\n\n/**\n * Returns a random subset of size `sampleSize` from `array`.\n *\n * Maintains and infers most of the typing information that could be passed\n * along to the output. This means that when using tuples, the output will be\n * a tuple too, and when using literals, those literals would be preserved.\n *\n * The items in the result are kept in the same order as they are in the input.\n * If you need to get a shuffled response you can pipe the shuffle function\n * after this one.\n *\n * @param sampleSize - The number of elements to take.\n * @signature\n * sample(sampleSize)(array)\n * @example\n * sample(1)([\"hello\", \"world\"]); // => [\"hello\"] // typed string[]\n * sample(1)([\"hello\", \"world\"] as const); // => [\"world\"] // typed [\"hello\" | \"world\"]\n * @dataLast\n * @category Array\n */\nexport function sample<const T extends IterableContainer, N extends number>(\n sampleSize: N,\n): (data: T) => Sampled<T, N>;\n\nexport function sample(...args: readonly unknown[]): unknown {\n return purry(sampleImplementation, args);\n}\n\nfunction sampleImplementation<T>(data: readonly T[], sampleSize: number): T[] {\n if (sampleSize <= 0) {\n // Trivial\n return [];\n }\n\n if (sampleSize >= data.length) {\n // Trivial\n return [...data];\n }\n\n // We have 2 modes of sampling, depending on the size of the sample requested.\n // 1. If sampleSize is _small_, we generate indices that we then use to\n // *EXTRACT* individual elements from the array.\n // 2. If sampleSize is _large_, we instead generate indices to *EXCLUDE* from\n // a full scan of the input array (via filtering).\n //\n // This allows us 2 optimizations that are the core of how this function\n // works:\n // 1. It is hard to generate a large number of unique indices, as the more\n // indices we generate the more likely we are to generate one that is already\n // in the set, which would require more iterations of the generation loop.\n // Capping our effective sampleSize at n/2 would put an upper limit to the\n // average number of iterations required (as a function of n).\n // 2. If sample size is small enough, we never need to actually iterate over\n // the full input array at all; instead we simply project the values we need\n // via random access into the array. This means that for sampleSize (K) less\n // than n/2, we run at O(klogk). For large sampleSize we need to iterate over\n // the full input array, but we don't need to sort the indices because we can\n // use the Set's 'has' method, so we effectively run at O(n).\n const actualSampleSize = Math.min(sampleSize, data.length - sampleSize);\n\n const sampleIndices = new Set<number>();\n while (sampleIndices.size < actualSampleSize) {\n const randomIndex = Math.floor(Math.random() * data.length);\n sampleIndices.add(randomIndex);\n }\n\n if (sampleSize === actualSampleSize) {\n return [...sampleIndices]\n .sort((a, b) => a - b)\n .map((index) => data[index]!);\n }\n\n return data.filter((_, index) => !sampleIndices.has(index));\n}\n"],"mappings":"mCAyJA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAO,EAAM,EAAsB,EAAK,CAG1C,SAAS,EAAwB,EAAoB,EAAyB,CAC5E,GAAI,GAAc,EAEhB,MAAO,EAAE,CAGX,GAAI,GAAc,EAAK,OAErB,MAAO,CAAC,GAAG,EAAK,CAsBlB,IAAM,EAAmB,KAAK,IAAI,EAAY,EAAK,OAAS,EAAW,CAEjE,EAAgB,IAAI,IAC1B,KAAO,EAAc,KAAO,GAAkB,CAC5C,IAAM,EAAc,KAAK,MAAM,KAAK,QAAQ,CAAG,EAAK,OAAO,CAC3D,EAAc,IAAI,EAAY,CAShC,OANI,IAAe,EACV,CAAC,GAAG,EAAc,CACtB,MAAM,EAAG,IAAM,EAAI,EAAE,CACrB,IAAK,GAAU,EAAK,GAAQ,CAG1B,EAAK,QAAQ,EAAG,IAAU,CAAC,EAAc,IAAI,EAAM,CAAC"}
package/dist/set.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,t,n)=>({...e,[t]:n});exports.set=t;
2
+ //# sourceMappingURL=set.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set.cjs","names":["purry"],"sources":["../src/set.ts"],"sourcesContent":["import type { UpsertProp } from \"./internal/types/UpsertProp\";\nimport { purry } from \"./purry\";\n\n/**\n * Sets the `value` at `prop` of `object`.\n *\n * To add a new property to an object, or to override its type, use `addProp`\n * instead, and to set a property within a nested object use `setPath`.\n *\n * @param obj - The target method.\n * @param prop - The property name.\n * @param value - The value to set.\n * @signature\n * set(obj, prop, value)\n * @example\n * set({ a: 1 }, 'a', 2) // => { a: 2 }\n * @dataFirst\n * @category Object\n */\nexport function set<T, K extends keyof T, V extends Required<T>[K]>(\n obj: T,\n prop: K,\n value: V,\n): UpsertProp<T, K, V>;\n\n/**\n * Sets the `value` at `prop` of `object`.\n *\n * To add a new property to an object, or to override it's type use `addProp`\n * instead.\n *\n * @param prop - The property name.\n * @param value - The value to set.\n * @signature\n * set(prop, value)(obj)\n * @example\n * pipe({ a: 1 }, set('a', 2)) // => { a: 2 }\n * @dataLast\n * @category Object\n */\nexport function set<T, K extends keyof T, V extends Required<T>[K]>(\n prop: K,\n value: V,\n): (obj: T) => UpsertProp<T, K, V>;\n\nexport function set(...args: readonly unknown[]): unknown {\n return purry(setImplementation, args);\n}\n\nconst setImplementation = <T, K extends keyof T, V extends Required<T>[K]>(\n obj: T,\n prop: K,\n value: V,\n): UpsertProp<T, K, V> =>\n // @ts-expect-error [ts2322] - Hard to type\n ({ ...obj, [prop]: value });\n"],"mappings":"kGA6CA,SAAgB,EAAI,GAAG,EAAmC,CACxD,OAAOA,EAAAA,MAAM,EAAmB,EAAK,CAGvC,MAAM,GACJ,EACA,EACA,KAGC,CAAE,GAAG,GAAM,GAAO,EAAO"}
package/dist/set.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,n)=>({...e,[t]:n});export{t as set};
2
+ //# sourceMappingURL=set.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set.js","names":[],"sources":["../src/set.ts"],"sourcesContent":["import type { UpsertProp } from \"./internal/types/UpsertProp\";\nimport { purry } from \"./purry\";\n\n/**\n * Sets the `value` at `prop` of `object`.\n *\n * To add a new property to an object, or to override its type, use `addProp`\n * instead, and to set a property within a nested object use `setPath`.\n *\n * @param obj - The target method.\n * @param prop - The property name.\n * @param value - The value to set.\n * @signature\n * set(obj, prop, value)\n * @example\n * set({ a: 1 }, 'a', 2) // => { a: 2 }\n * @dataFirst\n * @category Object\n */\nexport function set<T, K extends keyof T, V extends Required<T>[K]>(\n obj: T,\n prop: K,\n value: V,\n): UpsertProp<T, K, V>;\n\n/**\n * Sets the `value` at `prop` of `object`.\n *\n * To add a new property to an object, or to override it's type use `addProp`\n * instead.\n *\n * @param prop - The property name.\n * @param value - The value to set.\n * @signature\n * set(prop, value)(obj)\n * @example\n * pipe({ a: 1 }, set('a', 2)) // => { a: 2 }\n * @dataLast\n * @category Object\n */\nexport function set<T, K extends keyof T, V extends Required<T>[K]>(\n prop: K,\n value: V,\n): (obj: T) => UpsertProp<T, K, V>;\n\nexport function set(...args: readonly unknown[]): unknown {\n return purry(setImplementation, args);\n}\n\nconst setImplementation = <T, K extends keyof T, V extends Required<T>[K]>(\n obj: T,\n prop: K,\n value: V,\n): UpsertProp<T, K, V> =>\n // @ts-expect-error [ts2322] - Hard to type\n ({ ...obj, [prop]: value });\n"],"mappings":"mCA6CA,SAAgB,EAAI,GAAG,EAAmC,CACxD,OAAO,EAAM,EAAmB,EAAK,CAGvC,MAAM,GACJ,EACA,EACA,KAGC,CAAE,GAAG,GAAM,GAAO,EAAO"}
@@ -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,r){let[i,...a]=t;if(i===void 0)return r;if(Array.isArray(e)){let t=[...e];return t[i]=n(e[i],a,r),t}let{[i]:o,...s}=e;return{...s,[i]:n(o,a,r)}}exports.setPath=t;
2
+ //# sourceMappingURL=setPath.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setPath.cjs","names":["purry"],"sources":["../src/setPath.ts"],"sourcesContent":["import type { ValueOf } from \"type-fest\";\nimport type { RemedaTypeError } from \"./internal/types/RemedaTypeError\";\nimport { purry } from \"./purry\";\n\ntype Paths<T, Prefix extends readonly unknown[] = []> =\n | Prefix\n | (T extends object\n ? ValueOf<{\n [K in ProperKeyOf<T>]-?: Paths<T[K], [...Prefix, K]>;\n }>\n : RemedaTypeError<\n \"setPath\",\n \"Can only compute paths objects\",\n { type: never; metadata: T }\n >) extends infer Path\n ? // The Paths type is used to define the path param in `setPath`. In order\n // for both mutable arrays and readonly arrays to be supported we need to\n // make all results `readonly` (because mutable arrays extend readonly\n // arrays, but not the other way around). Because the result of Paths is\n // a union of arrays we need to distribute Result so that the operator is\n // applied to each member separately.\n Readonly<Path>\n : never;\n\n/**\n * Array objects have all Array.prototype keys in their \"keyof\" type, which\n * is not what we'd expect from the operator. We only want the numeric keys\n * which represent proper elements of the array.\n */\ntype ProperKeyOf<T> = Extract<\n keyof T,\n T extends readonly unknown[] ? number : keyof T\n>;\n\ntype ValueAtPath<T, Path> = Path extends readonly [\n infer Head extends keyof T,\n ...infer Rest,\n]\n ? ValueAtPath<T[Head], Rest>\n : T;\n\n/**\n * Sets the value at `path` of `object`.\n *\n * For simple cases where the path is only one level deep, prefer `set` instead.\n *\n * @param data - The target method.\n * @param path - The array of properties.\n * @param value - The value to set.\n * @signature\n * setPath(obj, path, value)\n * @example\n * setPath({ a: { b: 1 } }, ['a', 'b'], 2) // => { a: { b: 2 } }\n * @dataFirst\n * @category Object\n */\nexport function setPath<T, Path extends Paths<T>>(\n data: T,\n path: Path,\n value: ValueAtPath<T, Path>,\n): T;\n\n/**\n * Sets the value at `path` of `object`.\n *\n * @param path - The array of properties.\n * @param value - The value to set.\n * @signature\n * setPath(path, value)(obj)\n * @example\n * pipe({ a: { b: 1 } }, setPath(['a', 'b'], 2)) // { a: { b: 2 } }\n * @dataLast\n * @category Object\n */\nexport function setPath<\n T,\n Path extends Paths<T>,\n // TODO [>2] -- TODO: The following eslint is solvable by inlining Value and wrapping the T parameter with `NoInfer` (e.g. `ValueAtPath<NoInfer<T>, TPath>); to prevent typescript from inferring it as `unknown`. This is only available in TS 5.4, which is above what we currently support (5.1).\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- See TODO above...\n Value extends ValueAtPath<T, Path>,\n>(path: Path, value: Value): (data: T) => T;\n\nexport function setPath(...args: readonly unknown[]): unknown {\n return purry(setPathImplementation, args);\n}\n\nfunction setPathImplementation(\n data: unknown,\n path: readonly PropertyKey[],\n value: unknown,\n): unknown {\n const [pivot, ...rest] = path;\n if (pivot === undefined) {\n return value;\n }\n\n if (Array.isArray(data)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const copy = [...data];\n copy[pivot as number] = setPathImplementation(\n data[pivot as number],\n rest,\n value,\n );\n return copy;\n }\n\n const { [pivot]: currentValue, ...remaining } = data as Record<\n PropertyKey,\n unknown\n >;\n\n return {\n ...remaining,\n [pivot]: setPathImplementation(currentValue, rest, value),\n };\n}\n"],"mappings":"kGAkFA,SAAgB,EAAQ,GAAG,EAAmC,CAC5D,OAAOA,EAAAA,MAAM,EAAuB,EAAK,CAG3C,SAAS,EACP,EACA,EACA,EACS,CACT,GAAM,CAAC,EAAO,GAAG,GAAQ,EACzB,GAAI,IAAU,IAAA,GACZ,OAAO,EAGT,GAAI,MAAM,QAAQ,EAAK,CAAE,CAEvB,IAAM,EAAO,CAAC,GAAG,EAAK,CAMtB,MALA,GAAK,GAAmB,EACtB,EAAK,GACL,EACA,EACD,CACM,EAGT,GAAM,EAAG,GAAQ,EAAc,GAAG,GAAc,EAKhD,MAAO,CACL,GAAG,GACF,GAAQ,EAAsB,EAAc,EAAM,EAAM,CAC1D"}
@@ -0,0 +1,2 @@
1
+ import{purry as e}from"./purry.js";function t(...t){return e(n,t)}function n(e,t,r){let[i,...a]=t;if(i===void 0)return r;if(Array.isArray(e)){let t=[...e];return t[i]=n(e[i],a,r),t}let{[i]:o,...s}=e;return{...s,[i]:n(o,a,r)}}export{t as setPath};
2
+ //# sourceMappingURL=setPath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setPath.js","names":[],"sources":["../src/setPath.ts"],"sourcesContent":["import type { ValueOf } from \"type-fest\";\nimport type { RemedaTypeError } from \"./internal/types/RemedaTypeError\";\nimport { purry } from \"./purry\";\n\ntype Paths<T, Prefix extends readonly unknown[] = []> =\n | Prefix\n | (T extends object\n ? ValueOf<{\n [K in ProperKeyOf<T>]-?: Paths<T[K], [...Prefix, K]>;\n }>\n : RemedaTypeError<\n \"setPath\",\n \"Can only compute paths objects\",\n { type: never; metadata: T }\n >) extends infer Path\n ? // The Paths type is used to define the path param in `setPath`. In order\n // for both mutable arrays and readonly arrays to be supported we need to\n // make all results `readonly` (because mutable arrays extend readonly\n // arrays, but not the other way around). Because the result of Paths is\n // a union of arrays we need to distribute Result so that the operator is\n // applied to each member separately.\n Readonly<Path>\n : never;\n\n/**\n * Array objects have all Array.prototype keys in their \"keyof\" type, which\n * is not what we'd expect from the operator. We only want the numeric keys\n * which represent proper elements of the array.\n */\ntype ProperKeyOf<T> = Extract<\n keyof T,\n T extends readonly unknown[] ? number : keyof T\n>;\n\ntype ValueAtPath<T, Path> = Path extends readonly [\n infer Head extends keyof T,\n ...infer Rest,\n]\n ? ValueAtPath<T[Head], Rest>\n : T;\n\n/**\n * Sets the value at `path` of `object`.\n *\n * For simple cases where the path is only one level deep, prefer `set` instead.\n *\n * @param data - The target method.\n * @param path - The array of properties.\n * @param value - The value to set.\n * @signature\n * setPath(obj, path, value)\n * @example\n * setPath({ a: { b: 1 } }, ['a', 'b'], 2) // => { a: { b: 2 } }\n * @dataFirst\n * @category Object\n */\nexport function setPath<T, Path extends Paths<T>>(\n data: T,\n path: Path,\n value: ValueAtPath<T, Path>,\n): T;\n\n/**\n * Sets the value at `path` of `object`.\n *\n * @param path - The array of properties.\n * @param value - The value to set.\n * @signature\n * setPath(path, value)(obj)\n * @example\n * pipe({ a: { b: 1 } }, setPath(['a', 'b'], 2)) // { a: { b: 2 } }\n * @dataLast\n * @category Object\n */\nexport function setPath<\n T,\n Path extends Paths<T>,\n // TODO [>2] -- TODO: The following eslint is solvable by inlining Value and wrapping the T parameter with `NoInfer` (e.g. `ValueAtPath<NoInfer<T>, TPath>); to prevent typescript from inferring it as `unknown`. This is only available in TS 5.4, which is above what we currently support (5.1).\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- See TODO above...\n Value extends ValueAtPath<T, Path>,\n>(path: Path, value: Value): (data: T) => T;\n\nexport function setPath(...args: readonly unknown[]): unknown {\n return purry(setPathImplementation, args);\n}\n\nfunction setPathImplementation(\n data: unknown,\n path: readonly PropertyKey[],\n value: unknown,\n): unknown {\n const [pivot, ...rest] = path;\n if (pivot === undefined) {\n return value;\n }\n\n if (Array.isArray(data)) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const copy = [...data];\n copy[pivot as number] = setPathImplementation(\n data[pivot as number],\n rest,\n value,\n );\n return copy;\n }\n\n const { [pivot]: currentValue, ...remaining } = data as Record<\n PropertyKey,\n unknown\n >;\n\n return {\n ...remaining,\n [pivot]: setPathImplementation(currentValue, rest, value),\n };\n}\n"],"mappings":"mCAkFA,SAAgB,EAAQ,GAAG,EAAmC,CAC5D,OAAO,EAAM,EAAuB,EAAK,CAG3C,SAAS,EACP,EACA,EACA,EACS,CACT,GAAM,CAAC,EAAO,GAAG,GAAQ,EACzB,GAAI,IAAU,IAAA,GACZ,OAAO,EAGT,GAAI,MAAM,QAAQ,EAAK,CAAE,CAEvB,IAAM,EAAO,CAAC,GAAG,EAAK,CAMtB,MALA,GAAK,GAAmB,EACtB,EAAK,GACL,EACA,EACD,CACM,EAGT,GAAM,EAAG,GAAQ,EAAc,GAAG,GAAc,EAKhD,MAAO,CACL,GAAG,GACF,GAAQ,EAAsB,EAAc,EAAM,EAAM,CAC1D"}
@@ -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=[...e];for(let n=0;n<e.length;n++){let r=n+Math.floor(Math.random()*(e.length-n)),i=t[r];t[r]=t[n],t[n]=i}return t}exports.shuffle=t;
2
+ //# sourceMappingURL=shuffle.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shuffle.cjs","names":["purry"],"sources":["../src/shuffle.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { ReorderedArray } from \"./internal/types/ReorderedArray\";\nimport { purry } from \"./purry\";\n\n/**\n * Shuffles the input array, returning a new array with the same elements in a random order.\n *\n * @param items - The array to shuffle.\n * @signature\n * shuffle(array)\n * @example\n * shuffle([4, 2, 7, 5]) // => [7, 5, 4, 2]\n * @dataFirst\n * @category Array\n */\nexport function shuffle<T extends IterableContainer>(\n items: T,\n): ReorderedArray<T>;\n\n/**\n * Shuffles the input array, returning a new array with the same elements in a random order.\n *\n * @signature\n * shuffle()(array)\n * @example\n * pipe([4, 2, 7, 5], shuffle()) // => [7, 5, 4, 2]\n * @dataLast\n * @category Array\n */\nexport function shuffle(): <T extends IterableContainer>(\n items: T,\n) => ReorderedArray<T>;\n\nexport function shuffle(...args: readonly unknown[]): unknown {\n return purry(shuffleImplementation, args);\n}\n\nfunction shuffleImplementation<T>(items: readonly T[]): T[] {\n const result = [...items];\n for (let index = 0; index < items.length; index++) {\n const rand = index + Math.floor(Math.random() * (items.length - index));\n const value = result[rand]!;\n result[rand] = result[index]!;\n result[index] = value;\n }\n return result;\n}\n"],"mappings":"kGAiCA,SAAgB,EAAQ,GAAG,EAAmC,CAC5D,OAAOA,EAAAA,MAAM,EAAuB,EAAK,CAG3C,SAAS,EAAyB,EAA0B,CAC1D,IAAM,EAAS,CAAC,GAAG,EAAM,CACzB,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAM,OAAQ,IAAS,CACjD,IAAM,EAAO,EAAQ,KAAK,MAAM,KAAK,QAAQ,EAAI,EAAM,OAAS,GAAO,CACjE,EAAQ,EAAO,GACrB,EAAO,GAAQ,EAAO,GACtB,EAAO,GAAS,EAElB,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=[...e];for(let n=0;n<e.length;n++){let r=n+Math.floor(Math.random()*(e.length-n)),i=t[r];t[r]=t[n],t[n]=i}return t}export{t as shuffle};
2
+ //# sourceMappingURL=shuffle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shuffle.js","names":[],"sources":["../src/shuffle.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { ReorderedArray } from \"./internal/types/ReorderedArray\";\nimport { purry } from \"./purry\";\n\n/**\n * Shuffles the input array, returning a new array with the same elements in a random order.\n *\n * @param items - The array to shuffle.\n * @signature\n * shuffle(array)\n * @example\n * shuffle([4, 2, 7, 5]) // => [7, 5, 4, 2]\n * @dataFirst\n * @category Array\n */\nexport function shuffle<T extends IterableContainer>(\n items: T,\n): ReorderedArray<T>;\n\n/**\n * Shuffles the input array, returning a new array with the same elements in a random order.\n *\n * @signature\n * shuffle()(array)\n * @example\n * pipe([4, 2, 7, 5], shuffle()) // => [7, 5, 4, 2]\n * @dataLast\n * @category Array\n */\nexport function shuffle(): <T extends IterableContainer>(\n items: T,\n) => ReorderedArray<T>;\n\nexport function shuffle(...args: readonly unknown[]): unknown {\n return purry(shuffleImplementation, args);\n}\n\nfunction shuffleImplementation<T>(items: readonly T[]): T[] {\n const result = [...items];\n for (let index = 0; index < items.length; index++) {\n const rand = index + Math.floor(Math.random() * (items.length - index));\n const value = result[rand]!;\n result[rand] = result[index]!;\n result[index] = value;\n }\n return result;\n}\n"],"mappings":"mCAiCA,SAAgB,EAAQ,GAAG,EAAmC,CAC5D,OAAO,EAAM,EAAuB,EAAK,CAG3C,SAAS,EAAyB,EAA0B,CAC1D,IAAM,EAAS,CAAC,GAAG,EAAM,CACzB,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAM,OAAQ,IAAS,CACjD,IAAM,EAAO,EAAQ,KAAK,MAAM,KAAK,QAAQ,EAAI,EAAM,OAAS,GAAO,CACjE,EAAQ,EAAO,GACrB,EAAO,GAAQ,EAAO,GACtB,EAAO,GAAS,EAElB,OAAO"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e,t,n){return typeof e==`string`?e.slice(t,n):n=>n.slice(e,t)}exports.sliceString=e;
2
+ //# sourceMappingURL=sliceString.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sliceString.cjs","names":[],"sources":["../src/sliceString.ts"],"sourcesContent":["/**\n * Extracts a section of a string between two indices.\n *\n * This function is a wrapper around the built-in [`String.prototype.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice)\n * method.\n *\n * @param data - The string to extract from.\n * @param indexStart - The index of the first character to include in the\n * returned substring.\n * @param indexEnd - The index of the first character to exclude from the\n * returned substring.\n * @returns A new string containing the extracted section of the string.\n * @signature\n * sliceString(data, indexStart, indexEnd)\n * @example\n * sliceString(\"abcdefghijkl\", 1) // => `bcdefghijkl`\n * sliceString(\"abcdefghijkl\", 4, 7) // => `efg`\n * @dataFirst\n * @category String\n */\nexport function sliceString(\n data: string,\n indexStart: number,\n indexEnd?: number,\n): string;\n\n/**\n * Extracts a section of a string between two indices.\n *\n * This function is a wrapper around the built-in [`String.prototype.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice)\n * method.\n *\n * @param indexStart - The index of the first character to include in the\n * returned substring.\n * @param indexEnd - The index of the first character to exclude from the\n * returned substring, or `undefined` for the rest of the string.\n * @returns A new string containing the extracted section of the string.\n * @signature\n * sliceString(indexStart, indexEnd)(string)\n * @example\n * sliceString(1)(\"abcdefghijkl\") // => `bcdefghijkl`\n * sliceString(4, 7)(\"abcdefghijkl\") // => `efg`\n * @dataLast\n * @category String\n */\nexport function sliceString(\n indexStart: number,\n indexEnd?: number,\n): (data: string) => string;\n\nexport function sliceString(\n dataOrIndexStart: number | string,\n indexStartOrIndexEnd?: number,\n indexEnd?: number,\n): unknown {\n return typeof dataOrIndexStart === \"string\"\n ? dataOrIndexStart.slice(indexStartOrIndexEnd, indexEnd)\n : (data: string) => data.slice(dataOrIndexStart, indexStartOrIndexEnd);\n}\n"],"mappings":"mEAkDA,SAAgB,EACd,EACA,EACA,EACS,CACT,OAAO,OAAO,GAAqB,SAC/B,EAAiB,MAAM,EAAsB,EAAS,CACrD,GAAiB,EAAK,MAAM,EAAkB,EAAqB"}
@@ -0,0 +1,2 @@
1
+ function e(e,t,n){return typeof e==`string`?e.slice(t,n):n=>n.slice(e,t)}export{e as sliceString};
2
+ //# sourceMappingURL=sliceString.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sliceString.js","names":[],"sources":["../src/sliceString.ts"],"sourcesContent":["/**\n * Extracts a section of a string between two indices.\n *\n * This function is a wrapper around the built-in [`String.prototype.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice)\n * method.\n *\n * @param data - The string to extract from.\n * @param indexStart - The index of the first character to include in the\n * returned substring.\n * @param indexEnd - The index of the first character to exclude from the\n * returned substring.\n * @returns A new string containing the extracted section of the string.\n * @signature\n * sliceString(data, indexStart, indexEnd)\n * @example\n * sliceString(\"abcdefghijkl\", 1) // => `bcdefghijkl`\n * sliceString(\"abcdefghijkl\", 4, 7) // => `efg`\n * @dataFirst\n * @category String\n */\nexport function sliceString(\n data: string,\n indexStart: number,\n indexEnd?: number,\n): string;\n\n/**\n * Extracts a section of a string between two indices.\n *\n * This function is a wrapper around the built-in [`String.prototype.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice)\n * method.\n *\n * @param indexStart - The index of the first character to include in the\n * returned substring.\n * @param indexEnd - The index of the first character to exclude from the\n * returned substring, or `undefined` for the rest of the string.\n * @returns A new string containing the extracted section of the string.\n * @signature\n * sliceString(indexStart, indexEnd)(string)\n * @example\n * sliceString(1)(\"abcdefghijkl\") // => `bcdefghijkl`\n * sliceString(4, 7)(\"abcdefghijkl\") // => `efg`\n * @dataLast\n * @category String\n */\nexport function sliceString(\n indexStart: number,\n indexEnd?: number,\n): (data: string) => string;\n\nexport function sliceString(\n dataOrIndexStart: number | string,\n indexStartOrIndexEnd?: number,\n indexEnd?: number,\n): unknown {\n return typeof dataOrIndexStart === \"string\"\n ? dataOrIndexStart.slice(indexStartOrIndexEnd, indexEnd)\n : (data: string) => data.slice(dataOrIndexStart, indexStartOrIndexEnd);\n}\n"],"mappings":"AAkDA,SAAgB,EACd,EACA,EACA,EACS,CACT,OAAO,OAAO,GAAqB,SAC/B,EAAiB,MAAM,EAAsB,EAAS,CACrD,GAAiB,EAAK,MAAM,EAAkB,EAAqB"}
package/dist/sort.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=[...e];return n.sort(t),n}exports.sort=t;
2
+ //# sourceMappingURL=sort.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort.cjs","names":["purry"],"sources":["../src/sort.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { ReorderedArray } from \"./internal/types/ReorderedArray\";\nimport { purry } from \"./purry\";\n\n/**\n * Sorts an array. The comparator function should accept two values at a time\n * and return a negative number if the first value is smaller, a positive number\n * if it's larger, and zero if they are equal. Sorting is based on a native\n * `sort` function.\n *\n * @param items - The array to sort.\n * @param cmp - The comparator function.\n * @signature\n * sort(items, cmp)\n * @example\n * sort([4, 2, 7, 5], (a, b) => a - b); // => [2, 4, 5, 7]\n * @dataFirst\n * @category Array\n */\nexport function sort<T extends IterableContainer>(\n items: T,\n cmp: (a: T[number], b: T[number]) => number,\n): ReorderedArray<T>;\n\n/**\n * Sorts an array. The comparator function should accept two values at a time\n * and return a negative number if the first value is smaller, a positive number\n * if it's larger, and zero if they are equal. Sorting is based on a native\n * `sort` function.\n *\n * @param cmp - The comparator function.\n * @signature\n * sort(cmp)(items)\n * @example\n * pipe([4, 2, 7, 5], sort((a, b) => a - b)) // => [2, 4, 5, 7]\n * @dataLast\n * @category Array\n */\nexport function sort<T extends IterableContainer>(\n cmp: (a: T[number], b: T[number]) => number,\n): (items: T) => ReorderedArray<T>;\n\nexport function sort(...args: readonly unknown[]): unknown {\n return purry(sortImplementation, args);\n}\n\nfunction sortImplementation<T extends IterableContainer>(\n items: T,\n cmp: (a: T[number], b: T[number]) => number,\n): ReorderedArray<T> {\n const ret = [...items];\n ret.sort(cmp);\n return ret as ReorderedArray<T>;\n}\n"],"mappings":"kGA0CA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAOA,EAAAA,MAAM,EAAoB,EAAK,CAGxC,SAAS,EACP,EACA,EACmB,CACnB,IAAM,EAAM,CAAC,GAAG,EAAM,CAEtB,OADA,EAAI,KAAK,EAAI,CACN"}
package/dist/sort.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];return n.sort(t),n}export{t as sort};
2
+ //# sourceMappingURL=sort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort.js","names":[],"sources":["../src/sort.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { ReorderedArray } from \"./internal/types/ReorderedArray\";\nimport { purry } from \"./purry\";\n\n/**\n * Sorts an array. The comparator function should accept two values at a time\n * and return a negative number if the first value is smaller, a positive number\n * if it's larger, and zero if they are equal. Sorting is based on a native\n * `sort` function.\n *\n * @param items - The array to sort.\n * @param cmp - The comparator function.\n * @signature\n * sort(items, cmp)\n * @example\n * sort([4, 2, 7, 5], (a, b) => a - b); // => [2, 4, 5, 7]\n * @dataFirst\n * @category Array\n */\nexport function sort<T extends IterableContainer>(\n items: T,\n cmp: (a: T[number], b: T[number]) => number,\n): ReorderedArray<T>;\n\n/**\n * Sorts an array. The comparator function should accept two values at a time\n * and return a negative number if the first value is smaller, a positive number\n * if it's larger, and zero if they are equal. Sorting is based on a native\n * `sort` function.\n *\n * @param cmp - The comparator function.\n * @signature\n * sort(cmp)(items)\n * @example\n * pipe([4, 2, 7, 5], sort((a, b) => a - b)) // => [2, 4, 5, 7]\n * @dataLast\n * @category Array\n */\nexport function sort<T extends IterableContainer>(\n cmp: (a: T[number], b: T[number]) => number,\n): (items: T) => ReorderedArray<T>;\n\nexport function sort(...args: readonly unknown[]): unknown {\n return purry(sortImplementation, args);\n}\n\nfunction sortImplementation<T extends IterableContainer>(\n items: T,\n cmp: (a: T[number], b: T[number]) => number,\n): ReorderedArray<T> {\n const ret = [...items];\n ret.sort(cmp);\n return ret as ReorderedArray<T>;\n}\n"],"mappings":"mCA0CA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAO,EAAM,EAAoB,EAAK,CAGxC,SAAS,EACP,EACA,EACmB,CACnB,IAAM,EAAM,CAAC,GAAG,EAAM,CAEtB,OADA,EAAI,KAAK,EAAI,CACN"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purryOrderRules-B8pzD03D.cjs`);function t(...t){return e.t(n,t)}const n=(e,t)=>[...e].sort(t);exports.sortBy=t;
2
+ //# sourceMappingURL=sortBy.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sortBy.cjs","names":["purryOrderRules"],"sources":["../src/sortBy.ts"],"sourcesContent":["import { purryOrderRules, type OrderRule } from \"./internal/purryOrderRules\";\nimport type { CompareFunction } from \"./internal/types/CompareFunction\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { NonEmptyArray } from \"./internal/types/NonEmptyArray\";\nimport type { ReorderedArray } from \"./internal/types/ReorderedArray\";\n\n/**\n * Sorts `data` using the provided ordering rules. The `sort` is done via the\n * native `Array.prototype.sort` but is performed on a shallow copy of the array\n * to avoid mutating the original data.\n *\n * There are several other functions that take order rules and **bypass** the\n * need to sort the array first (in *O(nlogn)* time):\n * * `firstBy` === `first(sortBy(data, ...rules))`, O(n).\n * * `takeFirstBy` === `take(sortBy(data, ...rules), k)`, O(nlogk).\n * * `dropFirstBy` === `drop(sortBy(data, ...rules), k)`, O(nlogk).\n * * `nthBy` === `sortBy(data, ...rules).at(k)`, O(n).\n * * `rankBy` === `sortedIndex(sortBy(data, ...rules), item)`, O(n).\n * Refer to the docs for more details.\n *\n * @param sortRules - A variadic array of order rules defining the sorting\n * criteria. Each order rule is a projection function that extracts a comparable\n * value from the data. Sorting is based on these extracted values using the\n * native `<` and `>` operators. Earlier rules take precedence over later ones.\n * Use the syntax `[projection, \"desc\"]` for descending order.\n * @returns A shallow copy of the input array sorted by the provided rules.\n * @signature\n * sortBy(...rules)(data)\n * @example\n * pipe(\n * [{ a: 1 }, { a: 3 }, { a: 7 }, { a: 2 }],\n * sortBy(prop('a')),\n * ); // => [{ a: 1 }, { a: 2 }, { a: 3 }, { a: 7 }]\n * @dataLast\n * @category Array\n */\nexport function sortBy<T extends IterableContainer>(\n ...sortRules: Readonly<NonEmptyArray<OrderRule<T[number]>>>\n): (array: T) => ReorderedArray<T>;\n\n/**\n * Sorts `data` using the provided ordering rules. The `sort` is done via the\n * native `Array.prototype.sort` but is performed on a shallow copy of the array\n * to avoid mutating the original data.\n *\n * There are several other functions that take order rules and **bypass** the\n * need to sort the array first (in *O(nlogn)* time):\n * * `firstBy` === `first(sortBy(data, ...rules))`, O(n).\n * * `takeFirstBy` === `take(sortBy(data, ...rules), k)`, O(nlogk).\n * * `dropFirstBy` === `drop(sortBy(data, ...rules), k)`, O(nlogk).\n * * `nthBy` === `sortBy(data, ...rules).at(k)`, O(n).\n * * `rankBy` === `sortedIndex(sortBy(data, ...rules), item)`, O(n).\n * Refer to the docs for more details.\n *\n * @param array - The input array.\n * @param sortRules - A variadic array of order rules defining the sorting\n * criteria. Each order rule is a projection function that extracts a comparable\n * value from the data. Sorting is based on these extracted values using the\n * native `<` and `>` operators. Earlier rules take precedence over later ones.\n * Use the syntax `[projection, \"desc\"]` for descending order.\n * @returns A shallow copy of the input array sorted by the provided rules.\n * @signature\n * sortBy(data, ...rules)\n * @example\n * sortBy(\n * [{ a: 1 }, { a: 3 }, { a: 7 }, { a: 2 }],\n * prop('a'),\n * ); // => [{ a: 1 }, { a: 2 }, { a: 3 }, { a: 7 }]\n * sortBy(\n * [\n * {color: 'red', weight: 2},\n * {color: 'blue', weight: 3},\n * {color: 'green', weight: 1},\n * {color: 'purple', weight: 1},\n * ],\n * [prop('weight'), 'asc'],\n * prop('color'),\n * ); // => [\n * // {color: 'green', weight: 1},\n * // {color: 'purple', weight: 1},\n * // {color: 'red', weight: 2},\n * // {color: 'blue', weight: 3},\n * // ]\n * @dataFirst\n * @category Array\n */\nexport function sortBy<T extends IterableContainer>(\n array: T,\n ...sortRules: Readonly<NonEmptyArray<OrderRule<T[number]>>>\n): ReorderedArray<T>;\n\nexport function sortBy(...args: readonly unknown[]): unknown {\n return purryOrderRules(sortByImplementation, args);\n}\n\nconst sortByImplementation = <T>(\n data: readonly T[],\n compareFn: CompareFunction<T>,\n): T[] =>\n // TODO [>2]: When node 18 reaches end-of-life bump target lib to ES2023+ and use `Array.prototype.toSorted` here.\n [...data].sort(compareFn);\n"],"mappings":"qHA2FA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAOA,EAAAA,EAAgB,EAAsB,EAAK,CAGpD,MAAM,GACJ,EACA,IAGA,CAAC,GAAG,EAAK,CAAC,KAAK,EAAU"}
package/dist/sortBy.js ADDED
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./purryOrderRules-4JgY6z4X.js";function t(...t){return e(n,t)}const n=(e,t)=>[...e].sort(t);export{t as sortBy};
2
+ //# sourceMappingURL=sortBy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sortBy.js","names":[],"sources":["../src/sortBy.ts"],"sourcesContent":["import { purryOrderRules, type OrderRule } from \"./internal/purryOrderRules\";\nimport type { CompareFunction } from \"./internal/types/CompareFunction\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { NonEmptyArray } from \"./internal/types/NonEmptyArray\";\nimport type { ReorderedArray } from \"./internal/types/ReorderedArray\";\n\n/**\n * Sorts `data` using the provided ordering rules. The `sort` is done via the\n * native `Array.prototype.sort` but is performed on a shallow copy of the array\n * to avoid mutating the original data.\n *\n * There are several other functions that take order rules and **bypass** the\n * need to sort the array first (in *O(nlogn)* time):\n * * `firstBy` === `first(sortBy(data, ...rules))`, O(n).\n * * `takeFirstBy` === `take(sortBy(data, ...rules), k)`, O(nlogk).\n * * `dropFirstBy` === `drop(sortBy(data, ...rules), k)`, O(nlogk).\n * * `nthBy` === `sortBy(data, ...rules).at(k)`, O(n).\n * * `rankBy` === `sortedIndex(sortBy(data, ...rules), item)`, O(n).\n * Refer to the docs for more details.\n *\n * @param sortRules - A variadic array of order rules defining the sorting\n * criteria. Each order rule is a projection function that extracts a comparable\n * value from the data. Sorting is based on these extracted values using the\n * native `<` and `>` operators. Earlier rules take precedence over later ones.\n * Use the syntax `[projection, \"desc\"]` for descending order.\n * @returns A shallow copy of the input array sorted by the provided rules.\n * @signature\n * sortBy(...rules)(data)\n * @example\n * pipe(\n * [{ a: 1 }, { a: 3 }, { a: 7 }, { a: 2 }],\n * sortBy(prop('a')),\n * ); // => [{ a: 1 }, { a: 2 }, { a: 3 }, { a: 7 }]\n * @dataLast\n * @category Array\n */\nexport function sortBy<T extends IterableContainer>(\n ...sortRules: Readonly<NonEmptyArray<OrderRule<T[number]>>>\n): (array: T) => ReorderedArray<T>;\n\n/**\n * Sorts `data` using the provided ordering rules. The `sort` is done via the\n * native `Array.prototype.sort` but is performed on a shallow copy of the array\n * to avoid mutating the original data.\n *\n * There are several other functions that take order rules and **bypass** the\n * need to sort the array first (in *O(nlogn)* time):\n * * `firstBy` === `first(sortBy(data, ...rules))`, O(n).\n * * `takeFirstBy` === `take(sortBy(data, ...rules), k)`, O(nlogk).\n * * `dropFirstBy` === `drop(sortBy(data, ...rules), k)`, O(nlogk).\n * * `nthBy` === `sortBy(data, ...rules).at(k)`, O(n).\n * * `rankBy` === `sortedIndex(sortBy(data, ...rules), item)`, O(n).\n * Refer to the docs for more details.\n *\n * @param array - The input array.\n * @param sortRules - A variadic array of order rules defining the sorting\n * criteria. Each order rule is a projection function that extracts a comparable\n * value from the data. Sorting is based on these extracted values using the\n * native `<` and `>` operators. Earlier rules take precedence over later ones.\n * Use the syntax `[projection, \"desc\"]` for descending order.\n * @returns A shallow copy of the input array sorted by the provided rules.\n * @signature\n * sortBy(data, ...rules)\n * @example\n * sortBy(\n * [{ a: 1 }, { a: 3 }, { a: 7 }, { a: 2 }],\n * prop('a'),\n * ); // => [{ a: 1 }, { a: 2 }, { a: 3 }, { a: 7 }]\n * sortBy(\n * [\n * {color: 'red', weight: 2},\n * {color: 'blue', weight: 3},\n * {color: 'green', weight: 1},\n * {color: 'purple', weight: 1},\n * ],\n * [prop('weight'), 'asc'],\n * prop('color'),\n * ); // => [\n * // {color: 'green', weight: 1},\n * // {color: 'purple', weight: 1},\n * // {color: 'red', weight: 2},\n * // {color: 'blue', weight: 3},\n * // ]\n * @dataFirst\n * @category Array\n */\nexport function sortBy<T extends IterableContainer>(\n array: T,\n ...sortRules: Readonly<NonEmptyArray<OrderRule<T[number]>>>\n): ReorderedArray<T>;\n\nexport function sortBy(...args: readonly unknown[]): unknown {\n return purryOrderRules(sortByImplementation, args);\n}\n\nconst sortByImplementation = <T>(\n data: readonly T[],\n compareFn: CompareFunction<T>,\n): T[] =>\n // TODO [>2]: When node 18 reaches end-of-life bump target lib to ES2023+ and use `Array.prototype.toSorted` here.\n [...data].sort(compareFn);\n"],"mappings":"kDA2FA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAO,EAAgB,EAAsB,EAAK,CAGpD,MAAM,GACJ,EACA,IAGA,CAAC,GAAG,EAAK,CAAC,KAAK,EAAU"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`),t=require(`./binarySearchCutoffIndex-DdLPjZiy.cjs`);function n(...t){return e.purry(r,t)}const r=(e,n)=>t.t(e,e=>e<n);exports.sortedIndex=n;
2
+ //# sourceMappingURL=sortedIndex.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sortedIndex.cjs","names":["purry","binarySearchCutoffIndex"],"sources":["../src/sortedIndex.ts"],"sourcesContent":["import { purry } from \"./purry\";\nimport { binarySearchCutoffIndex } from \"./internal/binarySearchCutoffIndex\";\n\n/**\n * Find the insertion position (index) of an item in an array with items sorted\n * in ascending order; so that `splice(sortedIndex, 0, item)` would result in\n * maintaining the array's sort-ness. The array can contain duplicates.\n * If the item already exists in the array the index would be of the *first*\n * occurrence of the item.\n *\n * Runs in O(logN) time.\n *\n * @param data - The (ascending) sorted array.\n * @param item - The item to insert.\n * @returns Insertion index (In the range 0..array.length).\n * @signature\n * sortedIndex(data, item)\n * @example\n * sortedIndex(['a','a','b','c','c'], 'c') // => 3\n * @dataFirst\n * @category Array\n * @see sortedIndexBy, sortedIndexWith, sortedLastIndex, sortedLastIndexBy\n */\nexport function sortedIndex<T>(data: readonly T[], item: T): number;\n\n/**\n * Find the insertion position (index) of an item in an array with items sorted\n * in ascending order; so that `splice(sortedIndex, 0, item)` would result in\n * maintaining the array's sort-ness. The array can contain duplicates.\n * If the item already exists in the array the index would be of the *first*\n * occurrence of the item.\n *\n * Runs in O(logN) time.\n *\n * @param item - The item to insert.\n * @returns Insertion index (In the range 0..array.length).\n * @signature\n * sortedIndex(item)(data)\n * @example\n * pipe(['a','a','b','c','c'], sortedIndex('c')) // => 3\n * @dataLast\n * @category Array\n * @see sortedIndexBy, sortedIndexWith, sortedLastIndex, sortedLastIndexBy\n */\nexport function sortedIndex<T>(item: T): (data: readonly T[]) => number;\n\nexport function sortedIndex(...args: readonly unknown[]): unknown {\n return purry(sortedIndexImplementation, args);\n}\n\nconst sortedIndexImplementation = <T>(array: readonly T[], item: T): number =>\n binarySearchCutoffIndex(array, (pivot) => pivot < item);\n"],"mappings":"sJA8CA,SAAgB,EAAY,GAAG,EAAmC,CAChE,OAAOA,EAAAA,MAAM,EAA2B,EAAK,CAG/C,MAAM,GAAgC,EAAqB,IACzDC,EAAAA,EAAwB,EAAQ,GAAU,EAAQ,EAAK"}
@@ -0,0 +1,2 @@
1
+ import{purry as e}from"./purry.js";import{t}from"./binarySearchCutoffIndex-CLQRwIY1.js";function n(...t){return e(r,t)}const r=(e,n)=>t(e,e=>e<n);export{n as sortedIndex};
2
+ //# sourceMappingURL=sortedIndex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sortedIndex.js","names":[],"sources":["../src/sortedIndex.ts"],"sourcesContent":["import { purry } from \"./purry\";\nimport { binarySearchCutoffIndex } from \"./internal/binarySearchCutoffIndex\";\n\n/**\n * Find the insertion position (index) of an item in an array with items sorted\n * in ascending order; so that `splice(sortedIndex, 0, item)` would result in\n * maintaining the array's sort-ness. The array can contain duplicates.\n * If the item already exists in the array the index would be of the *first*\n * occurrence of the item.\n *\n * Runs in O(logN) time.\n *\n * @param data - The (ascending) sorted array.\n * @param item - The item to insert.\n * @returns Insertion index (In the range 0..array.length).\n * @signature\n * sortedIndex(data, item)\n * @example\n * sortedIndex(['a','a','b','c','c'], 'c') // => 3\n * @dataFirst\n * @category Array\n * @see sortedIndexBy, sortedIndexWith, sortedLastIndex, sortedLastIndexBy\n */\nexport function sortedIndex<T>(data: readonly T[], item: T): number;\n\n/**\n * Find the insertion position (index) of an item in an array with items sorted\n * in ascending order; so that `splice(sortedIndex, 0, item)` would result in\n * maintaining the array's sort-ness. The array can contain duplicates.\n * If the item already exists in the array the index would be of the *first*\n * occurrence of the item.\n *\n * Runs in O(logN) time.\n *\n * @param item - The item to insert.\n * @returns Insertion index (In the range 0..array.length).\n * @signature\n * sortedIndex(item)(data)\n * @example\n * pipe(['a','a','b','c','c'], sortedIndex('c')) // => 3\n * @dataLast\n * @category Array\n * @see sortedIndexBy, sortedIndexWith, sortedLastIndex, sortedLastIndexBy\n */\nexport function sortedIndex<T>(item: T): (data: readonly T[]) => number;\n\nexport function sortedIndex(...args: readonly unknown[]): unknown {\n return purry(sortedIndexImplementation, args);\n}\n\nconst sortedIndexImplementation = <T>(array: readonly T[], item: T): number =>\n binarySearchCutoffIndex(array, (pivot) => pivot < item);\n"],"mappings":"wFA8CA,SAAgB,EAAY,GAAG,EAAmC,CAChE,OAAO,EAAM,EAA2B,EAAK,CAG/C,MAAM,GAAgC,EAAqB,IACzD,EAAwB,EAAQ,GAAU,EAAQ,EAAK"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`),t=require(`./binarySearchCutoffIndex-DdLPjZiy.cjs`);function n(...t){return e.purry(r,t)}function r(e,n,r){let i=r(n,void 0,e);return t.t(e,(t,n)=>r(t,n,e)<i)}exports.sortedIndexBy=n;
2
+ //# sourceMappingURL=sortedIndexBy.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sortedIndexBy.cjs","names":["purry","binarySearchCutoffIndex"],"sources":["../src/sortedIndexBy.ts"],"sourcesContent":["import { purry } from \"./purry\";\nimport { binarySearchCutoffIndex } from \"./internal/binarySearchCutoffIndex\";\n\n/**\n * Find the insertion position (index) of an item in an array with items sorted\n * in ascending order using a value function; so that\n * `splice(sortedIndex, 0, item)` would result in maintaining the arrays sort-\n * ness. The array can contain duplicates.\n * If the item already exists in the array the index would be of the *first*\n * occurrence of the item.\n *\n * Runs in O(logN) time.\n *\n * See also:\n * * `findIndex` - scans a possibly unsorted array in-order (linear search).\n * * `sortedIndex` - like this function, but doesn't take a callbackfn.\n * * `sortedLastIndexBy` - like this function, but finds the last suitable index.\n * * `sortedLastIndex` - like `sortedIndex`, but finds the last suitable index.\n * * `rankBy` - scans a possibly unsorted array in-order, returning the index based on a sorting criteria.\n *\n * @param data - The (ascending) sorted array.\n * @param item - The item to insert.\n * @param valueFunction - All comparisons would be performed on the result of\n * calling this function on each compared item. Preferably this function should\n * return a `number` or `string`. This function should be the same as the one\n * provided to sortBy to sort the array. The function is called exactly once on\n * each items that is compared against in the array, and once at the beginning\n * on `item`. When called on `item` the `index` argument is `undefined`.\n * @returns Insertion index (In the range 0..data.length).\n * @signature\n * sortedIndexBy(data, item, valueFunction)\n * @example\n * sortedIndexBy([{age:20},{age:22}],{age:21},prop('age')) // => 1\n * @dataFirst\n * @category Array\n */\nexport function sortedIndexBy<T>(\n data: readonly T[],\n item: T,\n valueFunction: (\n item: T,\n index: number | undefined,\n data: readonly T[],\n ) => NonNullable<unknown>,\n): number;\n\n/**\n * Find the insertion position (index) of an item in an array with items sorted\n * in ascending order using a value function; so that\n * `splice(sortedIndex, 0, item)` would result in maintaining the arrays sort-\n * ness. The array can contain duplicates.\n * If the item already exists in the array the index would be of the *first*\n * occurrence of the item.\n *\n * Runs in O(logN) time.\n *\n * See also:\n * * `findIndex` - scans a possibly unsorted array in-order (linear search).\n * * `sortedIndex` - like this function, but doesn't take a callbackfn.\n * * `sortedLastIndexBy` - like this function, but finds the last suitable index.\n * * `sortedLastIndex` - like `sortedIndex`, but finds the last suitable index.\n * * `rankBy` - scans a possibly unsorted array in-order, returning the index based on a sorting criteria.\n *\n * @param item - The item to insert.\n * @param valueFunction - All comparisons would be performed on the result of\n * calling this function on each compared item. Preferably this function should\n * return a `number` or `string`. This function should be the same as the one\n * provided to sortBy to sort the array. The function is called exactly once on\n * each items that is compared against in the array, and once at the beginning\n * on `item`. When called on `item` the `index` argument is `undefined`.\n * @signature\n * sortedIndexBy(data, item, valueFunction)\n * @example\n * sortedIndexBy([{age:20},{age:22}],{age:21},prop('age')) // => 1\n * @dataLast\n * @category Array\n */\nexport function sortedIndexBy<T>(\n item: T,\n valueFunction: (\n item: T,\n index: number | undefined,\n data: readonly T[],\n ) => NonNullable<unknown>,\n): (data: readonly T[]) => number;\n\nexport function sortedIndexBy(...args: readonly unknown[]): unknown {\n return purry(sortedIndexByImplementation, args);\n}\n\nfunction sortedIndexByImplementation<T>(\n data: readonly T[],\n item: T,\n valueFunction: (\n item: T,\n index: number | undefined,\n data: readonly T[],\n ) => NonNullable<unknown>,\n): number {\n const value = valueFunction(item, undefined /* index */, data);\n return binarySearchCutoffIndex(\n data,\n (pivot, index) => valueFunction(pivot, index, data) < value,\n );\n}\n"],"mappings":"sJAsFA,SAAgB,EAAc,GAAG,EAAmC,CAClE,OAAOA,EAAAA,MAAM,EAA6B,EAAK,CAGjD,SAAS,EACP,EACA,EACA,EAKQ,CACR,IAAM,EAAQ,EAAc,EAAM,IAAA,GAAuB,EAAK,CAC9D,OAAOC,EAAAA,EACL,GACC,EAAO,IAAU,EAAc,EAAO,EAAO,EAAK,CAAG,EACvD"}
@@ -0,0 +1,2 @@
1
+ import{purry as e}from"./purry.js";import{t}from"./binarySearchCutoffIndex-CLQRwIY1.js";function n(...t){return e(r,t)}function r(e,n,r){let i=r(n,void 0,e);return t(e,(t,n)=>r(t,n,e)<i)}export{n as sortedIndexBy};
2
+ //# sourceMappingURL=sortedIndexBy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sortedIndexBy.js","names":[],"sources":["../src/sortedIndexBy.ts"],"sourcesContent":["import { purry } from \"./purry\";\nimport { binarySearchCutoffIndex } from \"./internal/binarySearchCutoffIndex\";\n\n/**\n * Find the insertion position (index) of an item in an array with items sorted\n * in ascending order using a value function; so that\n * `splice(sortedIndex, 0, item)` would result in maintaining the arrays sort-\n * ness. The array can contain duplicates.\n * If the item already exists in the array the index would be of the *first*\n * occurrence of the item.\n *\n * Runs in O(logN) time.\n *\n * See also:\n * * `findIndex` - scans a possibly unsorted array in-order (linear search).\n * * `sortedIndex` - like this function, but doesn't take a callbackfn.\n * * `sortedLastIndexBy` - like this function, but finds the last suitable index.\n * * `sortedLastIndex` - like `sortedIndex`, but finds the last suitable index.\n * * `rankBy` - scans a possibly unsorted array in-order, returning the index based on a sorting criteria.\n *\n * @param data - The (ascending) sorted array.\n * @param item - The item to insert.\n * @param valueFunction - All comparisons would be performed on the result of\n * calling this function on each compared item. Preferably this function should\n * return a `number` or `string`. This function should be the same as the one\n * provided to sortBy to sort the array. The function is called exactly once on\n * each items that is compared against in the array, and once at the beginning\n * on `item`. When called on `item` the `index` argument is `undefined`.\n * @returns Insertion index (In the range 0..data.length).\n * @signature\n * sortedIndexBy(data, item, valueFunction)\n * @example\n * sortedIndexBy([{age:20},{age:22}],{age:21},prop('age')) // => 1\n * @dataFirst\n * @category Array\n */\nexport function sortedIndexBy<T>(\n data: readonly T[],\n item: T,\n valueFunction: (\n item: T,\n index: number | undefined,\n data: readonly T[],\n ) => NonNullable<unknown>,\n): number;\n\n/**\n * Find the insertion position (index) of an item in an array with items sorted\n * in ascending order using a value function; so that\n * `splice(sortedIndex, 0, item)` would result in maintaining the arrays sort-\n * ness. The array can contain duplicates.\n * If the item already exists in the array the index would be of the *first*\n * occurrence of the item.\n *\n * Runs in O(logN) time.\n *\n * See also:\n * * `findIndex` - scans a possibly unsorted array in-order (linear search).\n * * `sortedIndex` - like this function, but doesn't take a callbackfn.\n * * `sortedLastIndexBy` - like this function, but finds the last suitable index.\n * * `sortedLastIndex` - like `sortedIndex`, but finds the last suitable index.\n * * `rankBy` - scans a possibly unsorted array in-order, returning the index based on a sorting criteria.\n *\n * @param item - The item to insert.\n * @param valueFunction - All comparisons would be performed on the result of\n * calling this function on each compared item. Preferably this function should\n * return a `number` or `string`. This function should be the same as the one\n * provided to sortBy to sort the array. The function is called exactly once on\n * each items that is compared against in the array, and once at the beginning\n * on `item`. When called on `item` the `index` argument is `undefined`.\n * @signature\n * sortedIndexBy(data, item, valueFunction)\n * @example\n * sortedIndexBy([{age:20},{age:22}],{age:21},prop('age')) // => 1\n * @dataLast\n * @category Array\n */\nexport function sortedIndexBy<T>(\n item: T,\n valueFunction: (\n item: T,\n index: number | undefined,\n data: readonly T[],\n ) => NonNullable<unknown>,\n): (data: readonly T[]) => number;\n\nexport function sortedIndexBy(...args: readonly unknown[]): unknown {\n return purry(sortedIndexByImplementation, args);\n}\n\nfunction sortedIndexByImplementation<T>(\n data: readonly T[],\n item: T,\n valueFunction: (\n item: T,\n index: number | undefined,\n data: readonly T[],\n ) => NonNullable<unknown>,\n): number {\n const value = valueFunction(item, undefined /* index */, data);\n return binarySearchCutoffIndex(\n data,\n (pivot, index) => valueFunction(pivot, index, data) < value,\n );\n}\n"],"mappings":"wFAsFA,SAAgB,EAAc,GAAG,EAAmC,CAClE,OAAO,EAAM,EAA6B,EAAK,CAGjD,SAAS,EACP,EACA,EACA,EAKQ,CACR,IAAM,EAAQ,EAAc,EAAM,IAAA,GAAuB,EAAK,CAC9D,OAAO,EACL,GACC,EAAO,IAAU,EAAc,EAAO,EAAO,EAAK,CAAG,EACvD"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`),t=require(`./binarySearchCutoffIndex-DdLPjZiy.cjs`);function n(...n){return e.purry(t.t,n)}exports.sortedIndexWith=n;
2
+ //# sourceMappingURL=sortedIndexWith.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sortedIndexWith.cjs","names":["purry","binarySearchCutoffIndex"],"sources":["../src/sortedIndexWith.ts"],"sourcesContent":["import { purry } from \"./purry\";\nimport { binarySearchCutoffIndex } from \"./internal/binarySearchCutoffIndex\";\n\n/**\n * Performs a **binary search** for the index of the item at which the predicate\n * stops returning `true`. This function assumes that the array is \"sorted\" in\n * regards to the predicate, meaning that running the predicate as a mapper on\n * it would result in an array `[...true[], ...false[]]`.\n * This stricter requirement from the predicate provides us 2 benefits over\n * `findIndex` which does a similar thing:\n * 1. It would run at O(logN) time instead of O(N) time.\n * 2. It always returns a value (it would return `data.length` if the\n * predicate returns `true` for all items).\n *\n * This function is the basis for all other sortedIndex functions which search\n * for a specific item in a sorted array, and it could be used to perform\n * similar efficient searches.\n * * `sortedIndex` - scans a sorted array with a binary search, find the first suitable index.\n * * `sortedIndexBy` - like `sortedIndex`, but assumes sorting is based on a callbackfn.\n * * `sortedLastIndex` - scans a sorted array with a binary search, finding the last suitable index.\n * * `sortedLastIndexBy` - like `sortedLastIndex`, but assumes sorting is based on a callbackfn.\n *\n * See also:\n * * `findIndex` - scans a possibly unsorted array in-order (linear search).\n * * `rankBy` - scans a possibly unsorted array in-order, returning the index based on a sorting criteria.\n *\n * @param data - Array, \"sorted\" by `predicate`.\n * @param predicate - A predicate which also defines the array's order.\n * @returns Index (In the range 0..data.length).\n * @signature\n * sortedIndexWith(data, predicate)\n * @example\n * sortedIndexWith(['a','ab','abc'], (item) => item.length < 2) // => 1\n * @dataFirst\n * @category Array\n * @see findIndex, sortedIndex, sortedIndexBy, sortedLastIndex, sortedLastIndexBy\n */\nexport function sortedIndexWith<T>(\n data: readonly T[],\n predicate: (value: T, index: number, data: readonly T[]) => boolean,\n): number;\n\n/**\n * Performs a **binary search** for the index of the item at which the predicate\n * stops returning `true`. This function assumes that the array is \"sorted\" in\n * regards to the predicate, meaning that running the predicate as a mapper on\n * it would result in an array `[...true[], ...false[]]`.\n * This stricter requirement from the predicate provides us 2 benefits over\n * `findIndex` which does a similar thing:\n * 1. It would run at O(logN) time instead of O(N) time.\n * 2. It always returns a value (it would return `data.length` if the\n * predicate returns `true` for all items).\n *\n * This function is the basis for all other sortedIndex functions which search\n * for a specific item in a sorted array, and it could be used to perform\n * similar efficient searches.\n * * `sortedIndex` - scans a sorted array with a binary search, find the first suitable index.\n * * `sortedIndexBy` - like `sortedIndex`, but assumes sorting is based on a callbackfn.\n * * `sortedLastIndex` - scans a sorted array with a binary search, finding the last suitable index.\n * * `sortedLastIndexBy` - like `sortedLastIndex`, but assumes sorting is based on a callbackfn.\n *\n * See also:\n * * `findIndex` - scans a possibly unsorted array in-order (linear search).\n * * `rankBy` - scans a possibly unsorted array in-order, returning the index based on a sorting criteria.\n *\n * @param predicate - A predicate which also defines the array's order.\n * @returns Index (In the range 0..data.length).\n * @signature\n * sortedIndexWith(predicate)(data)\n * @example\n * pipe(['a','ab','abc'], sortedIndexWith((item) => item.length < 2)) // => 1\n * @dataLast\n * @category Array\n */\nexport function sortedIndexWith<T>(\n predicate: (value: T, index: number, data: readonly T[]) => boolean,\n): (data: readonly T[]) => number;\n\nexport function sortedIndexWith(...args: readonly unknown[]): unknown {\n return purry(binarySearchCutoffIndex, args);\n}\n"],"mappings":"sJA8EA,SAAgB,EAAgB,GAAG,EAAmC,CACpE,OAAOA,EAAAA,MAAMC,EAAAA,EAAyB,EAAK"}
@@ -0,0 +1,2 @@
1
+ import{purry as e}from"./purry.js";import{t}from"./binarySearchCutoffIndex-CLQRwIY1.js";function n(...n){return e(t,n)}export{n as sortedIndexWith};
2
+ //# sourceMappingURL=sortedIndexWith.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sortedIndexWith.js","names":[],"sources":["../src/sortedIndexWith.ts"],"sourcesContent":["import { purry } from \"./purry\";\nimport { binarySearchCutoffIndex } from \"./internal/binarySearchCutoffIndex\";\n\n/**\n * Performs a **binary search** for the index of the item at which the predicate\n * stops returning `true`. This function assumes that the array is \"sorted\" in\n * regards to the predicate, meaning that running the predicate as a mapper on\n * it would result in an array `[...true[], ...false[]]`.\n * This stricter requirement from the predicate provides us 2 benefits over\n * `findIndex` which does a similar thing:\n * 1. It would run at O(logN) time instead of O(N) time.\n * 2. It always returns a value (it would return `data.length` if the\n * predicate returns `true` for all items).\n *\n * This function is the basis for all other sortedIndex functions which search\n * for a specific item in a sorted array, and it could be used to perform\n * similar efficient searches.\n * * `sortedIndex` - scans a sorted array with a binary search, find the first suitable index.\n * * `sortedIndexBy` - like `sortedIndex`, but assumes sorting is based on a callbackfn.\n * * `sortedLastIndex` - scans a sorted array with a binary search, finding the last suitable index.\n * * `sortedLastIndexBy` - like `sortedLastIndex`, but assumes sorting is based on a callbackfn.\n *\n * See also:\n * * `findIndex` - scans a possibly unsorted array in-order (linear search).\n * * `rankBy` - scans a possibly unsorted array in-order, returning the index based on a sorting criteria.\n *\n * @param data - Array, \"sorted\" by `predicate`.\n * @param predicate - A predicate which also defines the array's order.\n * @returns Index (In the range 0..data.length).\n * @signature\n * sortedIndexWith(data, predicate)\n * @example\n * sortedIndexWith(['a','ab','abc'], (item) => item.length < 2) // => 1\n * @dataFirst\n * @category Array\n * @see findIndex, sortedIndex, sortedIndexBy, sortedLastIndex, sortedLastIndexBy\n */\nexport function sortedIndexWith<T>(\n data: readonly T[],\n predicate: (value: T, index: number, data: readonly T[]) => boolean,\n): number;\n\n/**\n * Performs a **binary search** for the index of the item at which the predicate\n * stops returning `true`. This function assumes that the array is \"sorted\" in\n * regards to the predicate, meaning that running the predicate as a mapper on\n * it would result in an array `[...true[], ...false[]]`.\n * This stricter requirement from the predicate provides us 2 benefits over\n * `findIndex` which does a similar thing:\n * 1. It would run at O(logN) time instead of O(N) time.\n * 2. It always returns a value (it would return `data.length` if the\n * predicate returns `true` for all items).\n *\n * This function is the basis for all other sortedIndex functions which search\n * for a specific item in a sorted array, and it could be used to perform\n * similar efficient searches.\n * * `sortedIndex` - scans a sorted array with a binary search, find the first suitable index.\n * * `sortedIndexBy` - like `sortedIndex`, but assumes sorting is based on a callbackfn.\n * * `sortedLastIndex` - scans a sorted array with a binary search, finding the last suitable index.\n * * `sortedLastIndexBy` - like `sortedLastIndex`, but assumes sorting is based on a callbackfn.\n *\n * See also:\n * * `findIndex` - scans a possibly unsorted array in-order (linear search).\n * * `rankBy` - scans a possibly unsorted array in-order, returning the index based on a sorting criteria.\n *\n * @param predicate - A predicate which also defines the array's order.\n * @returns Index (In the range 0..data.length).\n * @signature\n * sortedIndexWith(predicate)(data)\n * @example\n * pipe(['a','ab','abc'], sortedIndexWith((item) => item.length < 2)) // => 1\n * @dataLast\n * @category Array\n */\nexport function sortedIndexWith<T>(\n predicate: (value: T, index: number, data: readonly T[]) => boolean,\n): (data: readonly T[]) => number;\n\nexport function sortedIndexWith(...args: readonly unknown[]): unknown {\n return purry(binarySearchCutoffIndex, args);\n}\n"],"mappings":"wFA8EA,SAAgB,EAAgB,GAAG,EAAmC,CACpE,OAAO,EAAM,EAAyB,EAAK"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`),t=require(`./binarySearchCutoffIndex-DdLPjZiy.cjs`);function n(...t){return e.purry(r,t)}const r=(e,n)=>t.t(e,e=>e<=n);exports.sortedLastIndex=n;
2
+ //# sourceMappingURL=sortedLastIndex.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sortedLastIndex.cjs","names":["purry","binarySearchCutoffIndex"],"sources":["../src/sortedLastIndex.ts"],"sourcesContent":["import { purry } from \"./purry\";\nimport { binarySearchCutoffIndex } from \"./internal/binarySearchCutoffIndex\";\n\n/**\n * Find the insertion position (index) of an item in an array with items sorted\n * in ascending order; so that `splice(sortedIndex, 0, item)` would result in\n * maintaining the array's sort-ness. The array can contain duplicates.\n * If the item already exists in the array the index would be of the *last*\n * occurrence of the item.\n *\n * Runs in O(logN) time.\n *\n * @param data - The (ascending) sorted array.\n * @param item - The item to insert.\n * @returns Insertion index (In the range 0..data.length).\n * @signature\n * sortedLastIndex(data, item)\n * @example\n * sortedLastIndex(['a','a','b','c','c'], 'c') // => 5\n * @dataFirst\n * @category Array\n * @see sortedIndex, sortedIndexBy, sortedIndexWith, sortedLastIndexBy\n */\nexport function sortedLastIndex<T>(data: readonly T[], item: T): number;\n\n/**\n * Find the insertion position (index) of an item in an array with items sorted\n * in ascending order; so that `splice(sortedIndex, 0, item)` would result in\n * maintaining the array's sort-ness. The array can contain duplicates.\n * If the item already exists in the array the index would be of the *last*\n * occurrence of the item.\n *\n * Runs in O(logN) time.\n *\n * @param item - The item to insert.\n * @returns Insertion index (In the range 0..data.length).\n * @signature\n * sortedLastIndex(item)(data)\n * @example\n * pipe(['a','a','b','c','c'], sortedLastIndex('c')) // => 5\n * @dataLast\n * @category Array\n * @see sortedIndex, sortedIndexBy, sortedIndexWith, sortedLastIndexBy\n */\nexport function sortedLastIndex<T>(item: T): (data: readonly T[]) => number;\n\nexport function sortedLastIndex(...args: readonly unknown[]): unknown {\n return purry(sortedLastIndexImplementation, args);\n}\n\nconst sortedLastIndexImplementation = <T>(\n array: readonly T[],\n item: T,\n): number =>\n binarySearchCutoffIndex(\n array,\n // The only difference between the regular implementation and the \"last\"\n // variation is that we consider the pivot with equality too, so that we\n // skip all equal values in addition to the lower ones.\n (pivot) => pivot <= item,\n );\n"],"mappings":"sJA8CA,SAAgB,EAAgB,GAAG,EAAmC,CACpE,OAAOA,EAAAA,MAAM,EAA+B,EAAK,CAGnD,MAAM,GACJ,EACA,IAEAC,EAAAA,EACE,EAIC,GAAU,GAAS,EACrB"}
@@ -0,0 +1,2 @@
1
+ import{purry as e}from"./purry.js";import{t}from"./binarySearchCutoffIndex-CLQRwIY1.js";function n(...t){return e(r,t)}const r=(e,n)=>t(e,e=>e<=n);export{n as sortedLastIndex};
2
+ //# sourceMappingURL=sortedLastIndex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sortedLastIndex.js","names":[],"sources":["../src/sortedLastIndex.ts"],"sourcesContent":["import { purry } from \"./purry\";\nimport { binarySearchCutoffIndex } from \"./internal/binarySearchCutoffIndex\";\n\n/**\n * Find the insertion position (index) of an item in an array with items sorted\n * in ascending order; so that `splice(sortedIndex, 0, item)` would result in\n * maintaining the array's sort-ness. The array can contain duplicates.\n * If the item already exists in the array the index would be of the *last*\n * occurrence of the item.\n *\n * Runs in O(logN) time.\n *\n * @param data - The (ascending) sorted array.\n * @param item - The item to insert.\n * @returns Insertion index (In the range 0..data.length).\n * @signature\n * sortedLastIndex(data, item)\n * @example\n * sortedLastIndex(['a','a','b','c','c'], 'c') // => 5\n * @dataFirst\n * @category Array\n * @see sortedIndex, sortedIndexBy, sortedIndexWith, sortedLastIndexBy\n */\nexport function sortedLastIndex<T>(data: readonly T[], item: T): number;\n\n/**\n * Find the insertion position (index) of an item in an array with items sorted\n * in ascending order; so that `splice(sortedIndex, 0, item)` would result in\n * maintaining the array's sort-ness. The array can contain duplicates.\n * If the item already exists in the array the index would be of the *last*\n * occurrence of the item.\n *\n * Runs in O(logN) time.\n *\n * @param item - The item to insert.\n * @returns Insertion index (In the range 0..data.length).\n * @signature\n * sortedLastIndex(item)(data)\n * @example\n * pipe(['a','a','b','c','c'], sortedLastIndex('c')) // => 5\n * @dataLast\n * @category Array\n * @see sortedIndex, sortedIndexBy, sortedIndexWith, sortedLastIndexBy\n */\nexport function sortedLastIndex<T>(item: T): (data: readonly T[]) => number;\n\nexport function sortedLastIndex(...args: readonly unknown[]): unknown {\n return purry(sortedLastIndexImplementation, args);\n}\n\nconst sortedLastIndexImplementation = <T>(\n array: readonly T[],\n item: T,\n): number =>\n binarySearchCutoffIndex(\n array,\n // The only difference between the regular implementation and the \"last\"\n // variation is that we consider the pivot with equality too, so that we\n // skip all equal values in addition to the lower ones.\n (pivot) => pivot <= item,\n );\n"],"mappings":"wFA8CA,SAAgB,EAAgB,GAAG,EAAmC,CACpE,OAAO,EAAM,EAA+B,EAAK,CAGnD,MAAM,GACJ,EACA,IAEA,EACE,EAIC,GAAU,GAAS,EACrB"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`),t=require(`./binarySearchCutoffIndex-DdLPjZiy.cjs`);function n(...t){return e.purry(r,t)}function r(e,n,r){let i=r(n,void 0,e);return t.t(e,(t,n)=>r(t,n,e)<=i)}exports.sortedLastIndexBy=n;
2
+ //# sourceMappingURL=sortedLastIndexBy.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sortedLastIndexBy.cjs","names":["purry","binarySearchCutoffIndex"],"sources":["../src/sortedLastIndexBy.ts"],"sourcesContent":["import { purry } from \"./purry\";\nimport { binarySearchCutoffIndex } from \"./internal/binarySearchCutoffIndex\";\n\n/**\n * Find the insertion position (index) of an item in an array with items sorted\n * in ascending order using a value function; so that\n * `splice(sortedIndex, 0, item)` would result in maintaining the arrays sort-\n * ness. The array can contain duplicates.\n * If the item already exists in the array the index would be of the *last*\n * occurrence of the item.\n *\n * Runs in O(logN) time.\n *\n * See also:\n * * `findIndex` - scans a possibly unsorted array in-order (linear search).\n * * `sortedLastIndex` - a simplified version of this function, without a callbackfn.\n * * `sortedIndexBy` - like this function, but returns the first suitable index.\n * * `sortedIndex` - like `sortedLastIndex` but without a callbackfn.\n * * `rankBy` - scans a possibly unsorted array in-order, returning the index based on a sorting criteria.\n *\n * @param data - The (ascending) sorted array.\n * @param item - The item to insert.\n * @param valueFunction - All comparisons would be performed on the result of\n * calling this function on each compared item. Preferably this function should\n * return a `number` or `string`. This function should be the same as the one\n * provided to sortBy to sort the array. The function is called exactly once on\n * each items that is compared against in the array, and once at the beginning\n * on `item`. When called on `item` the `index` argument is `undefined`.\n * @returns Insertion index (In the range 0..data.length).\n * @signature\n * sortedLastIndexBy(data, item, valueFunction)\n * @example\n * sortedLastIndexBy([{age:20},{age:22}],{age:21},prop('age')) // => 1\n * @dataFirst\n * @category Array\n */\nexport function sortedLastIndexBy<T>(\n data: readonly T[],\n item: T,\n valueFunction: (\n item: T,\n index: number | undefined,\n data: readonly T[],\n ) => NonNullable<unknown>,\n): number;\n\n/**\n * Find the insertion position (index) of an item in an array with items sorted\n * in ascending order using a value function; so that\n * `splice(sortedIndex, 0, item)` would result in maintaining the arrays sort-\n * ness. The array can contain duplicates.\n * If the item already exists in the array the index would be of the *last*\n * occurrence of the item.\n *\n * Runs in O(logN) time.\n *\n * See also:\n * * `findIndex` - scans a possibly unsorted array in-order (linear search).\n * * `sortedLastIndex` - a simplified version of this function, without a callbackfn.\n * * `sortedIndexBy` - like this function, but returns the first suitable index.\n * * `sortedIndex` - like `sortedLastIndex` but without a callbackfn.\n * * `rankBy` - scans a possibly unsorted array in-order, returning the index based on a sorting criteria.\n *\n * @param item - The item to insert.\n * @param valueFunction - All comparisons would be performed on the result of\n * calling this function on each compared item. Preferably this function should\n * return a `number` or `string`. This function should be the same as the one\n * provided to sortBy to sort the array. The function is called exactly once on\n * each items that is compared against in the array, and once at the beginning\n * on `item`. When called on `item` the `index` argument is `undefined`.\n * @returns Insertion index (In the range 0..data.length).\n * @signature\n * sortedLastIndexBy(item, valueFunction)(data)\n * @example\n * pipe([{age:20},{age:22}],sortedLastIndexBy({age:21},prop('age'))) // => 1\n * @dataLast\n * @category Array\n * @see sortedIndex, sortedIndexBy, sortedIndexWith, sortedLastIndex\n */\nexport function sortedLastIndexBy<T>(\n item: T,\n valueFunction: (\n item: T,\n index: number | undefined,\n data: readonly T[],\n ) => NonNullable<unknown>,\n): (data: readonly T[]) => number;\n\nexport function sortedLastIndexBy(...args: readonly unknown[]): unknown {\n return purry(sortedLastIndexByImplementation, args);\n}\n\nfunction sortedLastIndexByImplementation<T>(\n array: readonly T[],\n item: T,\n valueFunction: (\n item: T,\n index: number | undefined,\n data: readonly T[],\n ) => NonNullable<unknown>,\n): number {\n const value = valueFunction(item, undefined /* index */, array);\n return binarySearchCutoffIndex(\n array,\n // The only difference between the regular implementation and the \"last\"\n // variation is that we consider the pivot with equality too, so that we\n // skip all equal values in addition to the lower ones.\n (pivot, index) => valueFunction(pivot, index, array) <= value,\n );\n}\n"],"mappings":"sJAwFA,SAAgB,EAAkB,GAAG,EAAmC,CACtE,OAAOA,EAAAA,MAAM,EAAiC,EAAK,CAGrD,SAAS,EACP,EACA,EACA,EAKQ,CACR,IAAM,EAAQ,EAAc,EAAM,IAAA,GAAuB,EAAM,CAC/D,OAAOC,EAAAA,EACL,GAIC,EAAO,IAAU,EAAc,EAAO,EAAO,EAAM,EAAI,EACzD"}
@@ -0,0 +1,2 @@
1
+ import{purry as e}from"./purry.js";import{t}from"./binarySearchCutoffIndex-CLQRwIY1.js";function n(...t){return e(r,t)}function r(e,n,r){let i=r(n,void 0,e);return t(e,(t,n)=>r(t,n,e)<=i)}export{n as sortedLastIndexBy};
2
+ //# sourceMappingURL=sortedLastIndexBy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sortedLastIndexBy.js","names":[],"sources":["../src/sortedLastIndexBy.ts"],"sourcesContent":["import { purry } from \"./purry\";\nimport { binarySearchCutoffIndex } from \"./internal/binarySearchCutoffIndex\";\n\n/**\n * Find the insertion position (index) of an item in an array with items sorted\n * in ascending order using a value function; so that\n * `splice(sortedIndex, 0, item)` would result in maintaining the arrays sort-\n * ness. The array can contain duplicates.\n * If the item already exists in the array the index would be of the *last*\n * occurrence of the item.\n *\n * Runs in O(logN) time.\n *\n * See also:\n * * `findIndex` - scans a possibly unsorted array in-order (linear search).\n * * `sortedLastIndex` - a simplified version of this function, without a callbackfn.\n * * `sortedIndexBy` - like this function, but returns the first suitable index.\n * * `sortedIndex` - like `sortedLastIndex` but without a callbackfn.\n * * `rankBy` - scans a possibly unsorted array in-order, returning the index based on a sorting criteria.\n *\n * @param data - The (ascending) sorted array.\n * @param item - The item to insert.\n * @param valueFunction - All comparisons would be performed on the result of\n * calling this function on each compared item. Preferably this function should\n * return a `number` or `string`. This function should be the same as the one\n * provided to sortBy to sort the array. The function is called exactly once on\n * each items that is compared against in the array, and once at the beginning\n * on `item`. When called on `item` the `index` argument is `undefined`.\n * @returns Insertion index (In the range 0..data.length).\n * @signature\n * sortedLastIndexBy(data, item, valueFunction)\n * @example\n * sortedLastIndexBy([{age:20},{age:22}],{age:21},prop('age')) // => 1\n * @dataFirst\n * @category Array\n */\nexport function sortedLastIndexBy<T>(\n data: readonly T[],\n item: T,\n valueFunction: (\n item: T,\n index: number | undefined,\n data: readonly T[],\n ) => NonNullable<unknown>,\n): number;\n\n/**\n * Find the insertion position (index) of an item in an array with items sorted\n * in ascending order using a value function; so that\n * `splice(sortedIndex, 0, item)` would result in maintaining the arrays sort-\n * ness. The array can contain duplicates.\n * If the item already exists in the array the index would be of the *last*\n * occurrence of the item.\n *\n * Runs in O(logN) time.\n *\n * See also:\n * * `findIndex` - scans a possibly unsorted array in-order (linear search).\n * * `sortedLastIndex` - a simplified version of this function, without a callbackfn.\n * * `sortedIndexBy` - like this function, but returns the first suitable index.\n * * `sortedIndex` - like `sortedLastIndex` but without a callbackfn.\n * * `rankBy` - scans a possibly unsorted array in-order, returning the index based on a sorting criteria.\n *\n * @param item - The item to insert.\n * @param valueFunction - All comparisons would be performed on the result of\n * calling this function on each compared item. Preferably this function should\n * return a `number` or `string`. This function should be the same as the one\n * provided to sortBy to sort the array. The function is called exactly once on\n * each items that is compared against in the array, and once at the beginning\n * on `item`. When called on `item` the `index` argument is `undefined`.\n * @returns Insertion index (In the range 0..data.length).\n * @signature\n * sortedLastIndexBy(item, valueFunction)(data)\n * @example\n * pipe([{age:20},{age:22}],sortedLastIndexBy({age:21},prop('age'))) // => 1\n * @dataLast\n * @category Array\n * @see sortedIndex, sortedIndexBy, sortedIndexWith, sortedLastIndex\n */\nexport function sortedLastIndexBy<T>(\n item: T,\n valueFunction: (\n item: T,\n index: number | undefined,\n data: readonly T[],\n ) => NonNullable<unknown>,\n): (data: readonly T[]) => number;\n\nexport function sortedLastIndexBy(...args: readonly unknown[]): unknown {\n return purry(sortedLastIndexByImplementation, args);\n}\n\nfunction sortedLastIndexByImplementation<T>(\n array: readonly T[],\n item: T,\n valueFunction: (\n item: T,\n index: number | undefined,\n data: readonly T[],\n ) => NonNullable<unknown>,\n): number {\n const value = valueFunction(item, undefined /* index */, array);\n return binarySearchCutoffIndex(\n array,\n // The only difference between the regular implementation and the \"last\"\n // variation is that we consider the pivot with equality too, so that we\n // skip all equal values in addition to the lower ones.\n (pivot, index) => valueFunction(pivot, index, array) <= value,\n );\n}\n"],"mappings":"wFAwFA,SAAgB,EAAkB,GAAG,EAAmC,CACtE,OAAO,EAAM,EAAiC,EAAK,CAGrD,SAAS,EACP,EACA,EACA,EAKQ,CACR,IAAM,EAAQ,EAAc,EAAM,IAAA,GAAuB,EAAM,CAC/D,OAAO,EACL,GAIC,EAAO,IAAU,EAAc,EAAO,EAAO,EAAM,EAAI,EACzD"}
@@ -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,r){let i=[...e];return i.splice(t,n,...r),i}exports.splice=t;
2
+ //# sourceMappingURL=splice.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splice.cjs","names":["purry"],"sources":["../src/splice.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Removes elements from an array and, inserts new elements in their place.\n *\n * @param items - The array to splice.\n * @param start - The index from which to start removing elements.\n * @param deleteCount - The number of elements to remove.\n * @param replacement - The elements to insert into the array in place of the deleted elements.\n * @signature\n * splice(items, start, deleteCount, replacement)\n * @example\n * splice([1,2,3,4,5,6,7,8], 2, 3, []); //=> [1,2,6,7,8]\n * splice([1,2,3,4,5,6,7,8], 2, 3, [9, 10]); //=> [1,2,9,10,6,7,8]\n * @dataFirst\n * @category Array\n */\nexport function splice<T>(\n items: readonly T[],\n start: number,\n deleteCount: number,\n replacement: readonly T[],\n): T[];\n\n/**\n * Removes elements from an array and, inserts new elements in their place.\n *\n * @param start - The index from which to start removing elements.\n * @param deleteCount - The number of elements to remove.\n * @param replacement - The elements to insert into the array in place of the deleted elements.\n * @signature\n * splice(start, deleteCount, replacement)(items)\n * @example\n * pipe([1,2,3,4,5,6,7,8], splice(2, 3, [])) // => [1,2,6,7,8]\n * pipe([1,2,3,4,5,6,7,8], splice(2, 3, [9, 10])) // => [1,2,9,10,6,7,8]\n * @dataLast\n * @category Array\n */\nexport function splice<T>(\n start: number,\n deleteCount: number,\n replacement: readonly T[],\n): (items: readonly T[]) => T[];\n\nexport function splice(...args: readonly unknown[]): unknown {\n return purry(spliceImplementation, args);\n}\n\nfunction spliceImplementation<T>(\n items: readonly T[],\n start: number,\n deleteCount: number,\n replacement: readonly T[],\n): T[] {\n // TODO [>2]: When node 18 reaches end-of-life bump target lib to ES2023+ and use `Array.prototype.toSpliced` here.\n const result = [...items];\n result.splice(start, deleteCount, ...replacement);\n return result;\n}\n"],"mappings":"kGA4CA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAOA,EAAAA,MAAM,EAAsB,EAAK,CAG1C,SAAS,EACP,EACA,EACA,EACA,EACK,CAEL,IAAM,EAAS,CAAC,GAAG,EAAM,CAEzB,OADA,EAAO,OAAO,EAAO,EAAa,GAAG,EAAY,CAC1C"}
package/dist/splice.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,r){let i=[...e];return i.splice(t,n,...r),i}export{t as splice};
2
+ //# sourceMappingURL=splice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splice.js","names":[],"sources":["../src/splice.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Removes elements from an array and, inserts new elements in their place.\n *\n * @param items - The array to splice.\n * @param start - The index from which to start removing elements.\n * @param deleteCount - The number of elements to remove.\n * @param replacement - The elements to insert into the array in place of the deleted elements.\n * @signature\n * splice(items, start, deleteCount, replacement)\n * @example\n * splice([1,2,3,4,5,6,7,8], 2, 3, []); //=> [1,2,6,7,8]\n * splice([1,2,3,4,5,6,7,8], 2, 3, [9, 10]); //=> [1,2,9,10,6,7,8]\n * @dataFirst\n * @category Array\n */\nexport function splice<T>(\n items: readonly T[],\n start: number,\n deleteCount: number,\n replacement: readonly T[],\n): T[];\n\n/**\n * Removes elements from an array and, inserts new elements in their place.\n *\n * @param start - The index from which to start removing elements.\n * @param deleteCount - The number of elements to remove.\n * @param replacement - The elements to insert into the array in place of the deleted elements.\n * @signature\n * splice(start, deleteCount, replacement)(items)\n * @example\n * pipe([1,2,3,4,5,6,7,8], splice(2, 3, [])) // => [1,2,6,7,8]\n * pipe([1,2,3,4,5,6,7,8], splice(2, 3, [9, 10])) // => [1,2,9,10,6,7,8]\n * @dataLast\n * @category Array\n */\nexport function splice<T>(\n start: number,\n deleteCount: number,\n replacement: readonly T[],\n): (items: readonly T[]) => T[];\n\nexport function splice(...args: readonly unknown[]): unknown {\n return purry(spliceImplementation, args);\n}\n\nfunction spliceImplementation<T>(\n items: readonly T[],\n start: number,\n deleteCount: number,\n replacement: readonly T[],\n): T[] {\n // TODO [>2]: When node 18 reaches end-of-life bump target lib to ES2023+ and use `Array.prototype.toSpliced` here.\n const result = [...items];\n result.splice(start, deleteCount, ...replacement);\n return result;\n}\n"],"mappings":"mCA4CA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAO,EAAM,EAAsB,EAAK,CAG1C,SAAS,EACP,EACA,EACA,EACA,EACK,CAEL,IAAM,EAAS,CAAC,GAAG,EAAM,CAEzB,OADA,EAAO,OAAO,EAAO,EAAa,GAAG,EAAY,CAC1C"}
package/dist/split.cjs ADDED
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e,t,n){return typeof t==`number`||t===void 0?n=>n.split(e,t):e.split(t,n)}exports.split=e;
2
+ //# sourceMappingURL=split.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"split.cjs","names":[],"sources":["../src/split.ts"],"sourcesContent":["import type {\n ArraySlice,\n IsFloat,\n NonNegative,\n Split as SplitBase,\n} from \"type-fest\";\n\n// We can use the type-fest's split **only** if all the params are literals.\n// For all other cases it would return the wrong type so we use\n// `Array.prototype.split`s return type instead.\ntype BuiltInReturnType = ReturnType<typeof String.prototype.split>;\n\ntype Split<\n S extends string,\n Separator extends string,\n N extends number | undefined = undefined,\n> = string extends S\n ? BuiltInReturnType\n : string extends Separator\n ? BuiltInReturnType\n : number extends N\n ? BuiltInReturnType\n : // TODO: We need a way to \"floor\" non-integer numbers, until then we return a lower fidelity type instead.\n IsFloat<N> extends true\n ? BuiltInReturnType\n : N extends number\n ? ArraySlice<SplitBase<S, Separator>, 0, NonNegative<N>>\n : SplitBase<S, Separator>;\n\n/**\n * Splits a string into an array of substrings using a separator pattern.\n *\n * This function is a wrapper around the built-in [`String.prototype.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)\n * method.\n *\n * @param data - The string to split.\n * @param separator - The pattern describing where each split should occur. Can\n * be a string, or a regular expression.\n * @param limit - A non-negative integer specifying a limit on the number of\n * substrings to be included in the array. If provided, splits the string at\n * each occurrence of the specified separator, but stops when limit entries have\n * been placed in the array. Any leftover text is not included in the array at\n * all. The array may contain fewer entries than limit if the end of the string\n * is reached before the limit is reached. If limit is 0, [] is returned.\n * @returns An array of strings, split at each point where the separator occurs\n * in the given string.\n * @signature\n * split(data, separator, limit);\n * @example\n * split(\"a,b,c\", \",\"); //=> [\"a\", \"b\", \"c\"]\n * split(\"a,b,c\", \",\", 2); //=> [\"a\", \"b\"]\n * split(\"a1b2c3d\", /\\d/u); //=> [\"a\", \"b\", \"c\", \"d\"]\n * @dataFirst\n * @category String\n */\nexport function split(\n data: string,\n separator: RegExp,\n limit?: number,\n): string[];\nexport function split<\n S extends string,\n Separator extends string,\n N extends number | undefined = undefined,\n>(data: S, separator: Separator, limit?: N): Split<S, Separator, N>;\n\n/**\n * Splits a string into an array of substrings using a separator pattern.\n *\n * This function is a wrapper around the built-in [`String.prototype.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)\n * method.\n *\n * @param separator - The pattern describing where each split should occur. Can\n * be a string, or a regular expression.\n * @param limit - A non-negative integer specifying a limit on the number of\n * substrings to be included in the array. If provided, splits the string at\n * each occurrence of the specified separator, but stops when limit entries have\n * been placed in the array. Any leftover text is not included in the array at\n * all. The array may contain fewer entries than limit if the end of the string\n * is reached before the limit is reached. If limit is 0, [] is returned.\n * @returns An array of strings, split at each point where the separator occurs\n * in the given string.\n * @signature\n * split(separator, limit)(data);\n * @example\n * pipe(\"a,b,c\", split(\",\")); //=> [\"a\", \"b\", \"c\"]\n * pipe(\"a,b,c\", split(\",\", 2)); //=> [\"a\", \"b\"]\n * pipe(\"a1b2c3d\", split(/\\d/u)); //=> [\"a\", \"b\", \"c\", \"d\"]\n * @dataLast\n * @category String\n */\nexport function split(\n separator: RegExp,\n limit?: number,\n): (data: string) => string[];\nexport function split<\n S extends string,\n Separator extends string,\n N extends number | undefined = undefined,\n>(separator: Separator, limit?: N): (data: S) => Split<S, Separator, N>;\n\nexport function split(\n dataOrSeparator: RegExp | string,\n separatorOrLimit?: RegExp | number | string,\n limit?: number,\n): unknown {\n return typeof separatorOrLimit === \"number\" || separatorOrLimit === undefined\n ? // dataLast\n (data: string) => data.split(dataOrSeparator, separatorOrLimit)\n : // dataFirst\n (dataOrSeparator as string).split(separatorOrLimit, limit);\n}\n"],"mappings":"mEAqGA,SAAgB,EACd,EACA,EACA,EACS,CACT,OAAO,OAAO,GAAqB,UAAY,IAAqB,IAAA,GAE/D,GAAiB,EAAK,MAAM,EAAiB,EAAiB,CAE9D,EAA2B,MAAM,EAAkB,EAAM"}
package/dist/split.js ADDED
@@ -0,0 +1,2 @@
1
+ function e(e,t,n){return typeof t==`number`||t===void 0?n=>n.split(e,t):e.split(t,n)}export{e as split};
2
+ //# sourceMappingURL=split.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"split.js","names":[],"sources":["../src/split.ts"],"sourcesContent":["import type {\n ArraySlice,\n IsFloat,\n NonNegative,\n Split as SplitBase,\n} from \"type-fest\";\n\n// We can use the type-fest's split **only** if all the params are literals.\n// For all other cases it would return the wrong type so we use\n// `Array.prototype.split`s return type instead.\ntype BuiltInReturnType = ReturnType<typeof String.prototype.split>;\n\ntype Split<\n S extends string,\n Separator extends string,\n N extends number | undefined = undefined,\n> = string extends S\n ? BuiltInReturnType\n : string extends Separator\n ? BuiltInReturnType\n : number extends N\n ? BuiltInReturnType\n : // TODO: We need a way to \"floor\" non-integer numbers, until then we return a lower fidelity type instead.\n IsFloat<N> extends true\n ? BuiltInReturnType\n : N extends number\n ? ArraySlice<SplitBase<S, Separator>, 0, NonNegative<N>>\n : SplitBase<S, Separator>;\n\n/**\n * Splits a string into an array of substrings using a separator pattern.\n *\n * This function is a wrapper around the built-in [`String.prototype.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)\n * method.\n *\n * @param data - The string to split.\n * @param separator - The pattern describing where each split should occur. Can\n * be a string, or a regular expression.\n * @param limit - A non-negative integer specifying a limit on the number of\n * substrings to be included in the array. If provided, splits the string at\n * each occurrence of the specified separator, but stops when limit entries have\n * been placed in the array. Any leftover text is not included in the array at\n * all. The array may contain fewer entries than limit if the end of the string\n * is reached before the limit is reached. If limit is 0, [] is returned.\n * @returns An array of strings, split at each point where the separator occurs\n * in the given string.\n * @signature\n * split(data, separator, limit);\n * @example\n * split(\"a,b,c\", \",\"); //=> [\"a\", \"b\", \"c\"]\n * split(\"a,b,c\", \",\", 2); //=> [\"a\", \"b\"]\n * split(\"a1b2c3d\", /\\d/u); //=> [\"a\", \"b\", \"c\", \"d\"]\n * @dataFirst\n * @category String\n */\nexport function split(\n data: string,\n separator: RegExp,\n limit?: number,\n): string[];\nexport function split<\n S extends string,\n Separator extends string,\n N extends number | undefined = undefined,\n>(data: S, separator: Separator, limit?: N): Split<S, Separator, N>;\n\n/**\n * Splits a string into an array of substrings using a separator pattern.\n *\n * This function is a wrapper around the built-in [`String.prototype.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)\n * method.\n *\n * @param separator - The pattern describing where each split should occur. Can\n * be a string, or a regular expression.\n * @param limit - A non-negative integer specifying a limit on the number of\n * substrings to be included in the array. If provided, splits the string at\n * each occurrence of the specified separator, but stops when limit entries have\n * been placed in the array. Any leftover text is not included in the array at\n * all. The array may contain fewer entries than limit if the end of the string\n * is reached before the limit is reached. If limit is 0, [] is returned.\n * @returns An array of strings, split at each point where the separator occurs\n * in the given string.\n * @signature\n * split(separator, limit)(data);\n * @example\n * pipe(\"a,b,c\", split(\",\")); //=> [\"a\", \"b\", \"c\"]\n * pipe(\"a,b,c\", split(\",\", 2)); //=> [\"a\", \"b\"]\n * pipe(\"a1b2c3d\", split(/\\d/u)); //=> [\"a\", \"b\", \"c\", \"d\"]\n * @dataLast\n * @category String\n */\nexport function split(\n separator: RegExp,\n limit?: number,\n): (data: string) => string[];\nexport function split<\n S extends string,\n Separator extends string,\n N extends number | undefined = undefined,\n>(separator: Separator, limit?: N): (data: S) => Split<S, Separator, N>;\n\nexport function split(\n dataOrSeparator: RegExp | string,\n separatorOrLimit?: RegExp | number | string,\n limit?: number,\n): unknown {\n return typeof separatorOrLimit === \"number\" || separatorOrLimit === undefined\n ? // dataLast\n (data: string) => data.split(dataOrSeparator, separatorOrLimit)\n : // dataFirst\n (dataOrSeparator as string).split(separatorOrLimit, limit);\n}\n"],"mappings":"AAqGA,SAAgB,EACd,EACA,EACA,EACS,CACT,OAAO,OAAO,GAAqB,UAAY,IAAqB,IAAA,GAE/D,GAAiB,EAAK,MAAM,EAAiB,EAAiB,CAE9D,EAA2B,MAAM,EAAkB,EAAM"}
@@ -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=Math.max(Math.min(t<0?e.length+t:t,e.length),0);return[e.slice(0,n),e.slice(n)]}exports.splitAt=t;
2
+ //# sourceMappingURL=splitAt.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splitAt.cjs","names":["purry"],"sources":["../src/splitAt.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Splits a given array at a given index.\n *\n * @param array - The array to split.\n * @param index - The index to split at.\n * @signature\n * splitAt(array, index)\n * @example\n * splitAt([1, 2, 3], 1) // => [[1], [2, 3]]\n * splitAt([1, 2, 3, 4, 5], -1) // => [[1, 2, 3, 4], [5]]\n * @dataFirst\n * @category Array\n */\nexport function splitAt<T>(array: readonly T[], index: number): [T[], T[]];\n\n/**\n * Splits a given array at a given index.\n *\n * @param index - The index to split at.\n * @signature\n * splitAt(index)(array)\n * @example\n * splitAt(1)([1, 2, 3]) // => [[1], [2, 3]]\n * splitAt(-1)([1, 2, 3, 4, 5]) // => [[1, 2, 3, 4], [5]]\n * @dataLast\n * @category Array\n */\nexport function splitAt<T>(index: number): (array: readonly T[]) => [T[], T[]];\n\nexport function splitAt(...args: readonly unknown[]): unknown {\n return purry(splitAtImplementation, args);\n}\n\nfunction splitAtImplementation<T>(\n array: readonly T[],\n index: number,\n): [T[], T[]] {\n const effectiveIndex = Math.max(\n Math.min(index < 0 ? array.length + index : index, array.length),\n 0,\n );\n return [array.slice(0, effectiveIndex), array.slice(effectiveIndex)];\n}\n"],"mappings":"kGA+BA,SAAgB,EAAQ,GAAG,EAAmC,CAC5D,OAAOA,EAAAA,MAAM,EAAuB,EAAK,CAG3C,SAAS,EACP,EACA,EACY,CACZ,IAAM,EAAiB,KAAK,IAC1B,KAAK,IAAI,EAAQ,EAAI,EAAM,OAAS,EAAQ,EAAO,EAAM,OAAO,CAChE,EACD,CACD,MAAO,CAAC,EAAM,MAAM,EAAG,EAAe,CAAE,EAAM,MAAM,EAAe,CAAC"}
@@ -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=Math.max(Math.min(t<0?e.length+t:t,e.length),0);return[e.slice(0,n),e.slice(n)]}export{t as splitAt};
2
+ //# sourceMappingURL=splitAt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splitAt.js","names":[],"sources":["../src/splitAt.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Splits a given array at a given index.\n *\n * @param array - The array to split.\n * @param index - The index to split at.\n * @signature\n * splitAt(array, index)\n * @example\n * splitAt([1, 2, 3], 1) // => [[1], [2, 3]]\n * splitAt([1, 2, 3, 4, 5], -1) // => [[1, 2, 3, 4], [5]]\n * @dataFirst\n * @category Array\n */\nexport function splitAt<T>(array: readonly T[], index: number): [T[], T[]];\n\n/**\n * Splits a given array at a given index.\n *\n * @param index - The index to split at.\n * @signature\n * splitAt(index)(array)\n * @example\n * splitAt(1)([1, 2, 3]) // => [[1], [2, 3]]\n * splitAt(-1)([1, 2, 3, 4, 5]) // => [[1, 2, 3, 4], [5]]\n * @dataLast\n * @category Array\n */\nexport function splitAt<T>(index: number): (array: readonly T[]) => [T[], T[]];\n\nexport function splitAt(...args: readonly unknown[]): unknown {\n return purry(splitAtImplementation, args);\n}\n\nfunction splitAtImplementation<T>(\n array: readonly T[],\n index: number,\n): [T[], T[]] {\n const effectiveIndex = Math.max(\n Math.min(index < 0 ? array.length + index : index, array.length),\n 0,\n );\n return [array.slice(0, effectiveIndex), array.slice(effectiveIndex)];\n}\n"],"mappings":"mCA+BA,SAAgB,EAAQ,GAAG,EAAmC,CAC5D,OAAO,EAAM,EAAuB,EAAK,CAG3C,SAAS,EACP,EACA,EACY,CACZ,IAAM,EAAiB,KAAK,IAC1B,KAAK,IAAI,EAAQ,EAAI,EAAM,OAAS,EAAQ,EAAO,EAAM,OAAO,CAChE,EACD,CACD,MAAO,CAAC,EAAM,MAAM,EAAG,EAAe,CAAE,EAAM,MAAM,EAAe,CAAC"}
@@ -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.findIndex(t);return n===-1?[[...e],[]]:[e.slice(0,n),e.slice(n)]}exports.splitWhen=t;
2
+ //# sourceMappingURL=splitWhen.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splitWhen.cjs","names":["purry"],"sources":["../src/splitWhen.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Splits a given array at the first index where the given predicate returns true.\n *\n * @param data - The array to split.\n * @param predicate - The predicate.\n * @signature\n * splitWhen(array, fn)\n * @example\n * splitWhen([1, 2, 3], x => x === 2) // => [[1], [2, 3]]\n * @dataFirst\n * @category Array\n */\nexport function splitWhen<T>(\n data: readonly T[],\n predicate: (item: T, index: number, data: readonly T[]) => boolean,\n): [T[], T[]];\n\n/**\n * Splits a given array at an index where the given predicate returns true.\n *\n * @param predicate - The predicate.\n * @signature\n * splitWhen(fn)(array)\n * @example\n * splitWhen(x => x === 2)([1, 2, 3]) // => [[1], [2, 3]]\n * @dataLast\n * @category Array\n */\nexport function splitWhen<T>(\n predicate: (item: T, index: number, data: readonly T[]) => boolean,\n): (array: readonly T[]) => [T[], T[]];\n\nexport function splitWhen(...args: readonly unknown[]): unknown {\n return purry(splitWhenImplementation, args);\n}\n\nfunction splitWhenImplementation<T>(\n data: readonly T[],\n predicate: (item: T, index: number, data: readonly T[]) => boolean,\n): [T[], T[]] {\n const index = data.findIndex(predicate);\n return index === -1\n ? [[...data], []]\n : [data.slice(0, index), data.slice(index)];\n}\n"],"mappings":"kGAkCA,SAAgB,EAAU,GAAG,EAAmC,CAC9D,OAAOA,EAAAA,MAAM,EAAyB,EAAK,CAG7C,SAAS,EACP,EACA,EACY,CACZ,IAAM,EAAQ,EAAK,UAAU,EAAU,CACvC,OAAO,IAAU,GACb,CAAC,CAAC,GAAG,EAAK,CAAE,EAAE,CAAC,CACf,CAAC,EAAK,MAAM,EAAG,EAAM,CAAE,EAAK,MAAM,EAAM,CAAC"}
@@ -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.findIndex(t);return n===-1?[[...e],[]]:[e.slice(0,n),e.slice(n)]}export{t as splitWhen};
2
+ //# sourceMappingURL=splitWhen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splitWhen.js","names":[],"sources":["../src/splitWhen.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Splits a given array at the first index where the given predicate returns true.\n *\n * @param data - The array to split.\n * @param predicate - The predicate.\n * @signature\n * splitWhen(array, fn)\n * @example\n * splitWhen([1, 2, 3], x => x === 2) // => [[1], [2, 3]]\n * @dataFirst\n * @category Array\n */\nexport function splitWhen<T>(\n data: readonly T[],\n predicate: (item: T, index: number, data: readonly T[]) => boolean,\n): [T[], T[]];\n\n/**\n * Splits a given array at an index where the given predicate returns true.\n *\n * @param predicate - The predicate.\n * @signature\n * splitWhen(fn)(array)\n * @example\n * splitWhen(x => x === 2)([1, 2, 3]) // => [[1], [2, 3]]\n * @dataLast\n * @category Array\n */\nexport function splitWhen<T>(\n predicate: (item: T, index: number, data: readonly T[]) => boolean,\n): (array: readonly T[]) => [T[], T[]];\n\nexport function splitWhen(...args: readonly unknown[]): unknown {\n return purry(splitWhenImplementation, args);\n}\n\nfunction splitWhenImplementation<T>(\n data: readonly T[],\n predicate: (item: T, index: number, data: readonly T[]) => boolean,\n): [T[], T[]] {\n const index = data.findIndex(predicate);\n return index === -1\n ? [[...data], []]\n : [data.slice(0, index), data.slice(index)];\n}\n"],"mappings":"mCAkCA,SAAgB,EAAU,GAAG,EAAmC,CAC9D,OAAO,EAAM,EAAyB,EAAK,CAG7C,SAAS,EACP,EACA,EACY,CACZ,IAAM,EAAQ,EAAK,UAAU,EAAU,CACvC,OAAO,IAAU,GACb,CAAC,CAAC,GAAG,EAAK,CAAE,EAAE,CAAC,CACf,CAAC,EAAK,MAAM,EAAG,EAAM,CAAE,EAAK,MAAM,EAAM,CAAC"}
@@ -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)=>e.startsWith(t);exports.startsWith=t;
2
+ //# sourceMappingURL=startsWith.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startsWith.cjs","names":["purry"],"sources":["../src/startsWith.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Determines whether a string begins with the provided prefix, and refines the\n * output type if possible.\n *\n * This function is a wrapper around the built-in [`String.prototype.startsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith)\n * method, but doesn't expose the `startPosition` parameter. To check from a\n * specific position, use\n * `startsWith(sliceString(data, startPosition), prefix)`.\n *\n * @param data - The input string.\n * @param prefix - The string to check for at the beginning.\n * @signature\n * startsWith(data, prefix);\n * @example\n * startsWith(\"hello world\", \"hello\"); // true\n * startsWith(\"hello world\", \"world\"); // false\n * @dataFirst\n * @category String\n */\nexport function startsWith<T extends string, Prefix extends string>(\n data: T,\n prefix: string extends Prefix ? never : Prefix,\n): data is T & `${Prefix}${string}`;\nexport function startsWith(data: string, prefix: string): boolean;\n\n/**\n * Determines whether a string begins with the provided prefix, and refines the\n * output type if possible.\n *\n * This function is a wrapper around the built-in [`String.prototype.startsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith)\n * method, but doesn't expose the `startPosition` parameter. To check from a\n * specific position, use\n * `startsWith(sliceString(data, startPosition), prefix)`.\n *\n * @param prefix - The string to check for at the beginning.\n * @signature\n * startsWith(prefix)(data);\n * @example\n * pipe(\"hello world\", startsWith(\"hello\")); // true\n * pipe(\"hello world\", startsWith(\"world\")); // false\n * @dataLast\n * @category String\n */\nexport function startsWith<Prefix extends string>(\n prefix: string extends Prefix ? never : Prefix,\n): <T extends string>(data: T) => data is T & `${Prefix}${string}`;\nexport function startsWith(prefix: string): (data: string) => boolean;\n\nexport function startsWith(...args: readonly unknown[]): unknown {\n return purry(startsWithImplementation, args);\n}\n\nconst startsWithImplementation = (data: string, prefix: string): boolean =>\n data.startsWith(prefix);\n"],"mappings":"kGAkDA,SAAgB,EAAW,GAAG,EAAmC,CAC/D,OAAOA,EAAAA,MAAM,EAA0B,EAAK,CAG9C,MAAM,GAA4B,EAAc,IAC9C,EAAK,WAAW,EAAO"}
@@ -0,0 +1,2 @@
1
+ import{purry as e}from"./purry.js";function t(...t){return e(n,t)}const n=(e,t)=>e.startsWith(t);export{t as startsWith};
2
+ //# sourceMappingURL=startsWith.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startsWith.js","names":[],"sources":["../src/startsWith.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Determines whether a string begins with the provided prefix, and refines the\n * output type if possible.\n *\n * This function is a wrapper around the built-in [`String.prototype.startsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith)\n * method, but doesn't expose the `startPosition` parameter. To check from a\n * specific position, use\n * `startsWith(sliceString(data, startPosition), prefix)`.\n *\n * @param data - The input string.\n * @param prefix - The string to check for at the beginning.\n * @signature\n * startsWith(data, prefix);\n * @example\n * startsWith(\"hello world\", \"hello\"); // true\n * startsWith(\"hello world\", \"world\"); // false\n * @dataFirst\n * @category String\n */\nexport function startsWith<T extends string, Prefix extends string>(\n data: T,\n prefix: string extends Prefix ? never : Prefix,\n): data is T & `${Prefix}${string}`;\nexport function startsWith(data: string, prefix: string): boolean;\n\n/**\n * Determines whether a string begins with the provided prefix, and refines the\n * output type if possible.\n *\n * This function is a wrapper around the built-in [`String.prototype.startsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith)\n * method, but doesn't expose the `startPosition` parameter. To check from a\n * specific position, use\n * `startsWith(sliceString(data, startPosition), prefix)`.\n *\n * @param prefix - The string to check for at the beginning.\n * @signature\n * startsWith(prefix)(data);\n * @example\n * pipe(\"hello world\", startsWith(\"hello\")); // true\n * pipe(\"hello world\", startsWith(\"world\")); // false\n * @dataLast\n * @category String\n */\nexport function startsWith<Prefix extends string>(\n prefix: string extends Prefix ? never : Prefix,\n): <T extends string>(data: T) => data is T & `${Prefix}${string}`;\nexport function startsWith(prefix: string): (data: string) => boolean;\n\nexport function startsWith(...args: readonly unknown[]): unknown {\n return purry(startsWithImplementation, args);\n}\n\nconst startsWithImplementation = (data: string, prefix: string): boolean =>\n data.startsWith(prefix);\n"],"mappings":"mCAkDA,SAAgB,EAAW,GAAG,EAAmC,CAC/D,OAAO,EAAM,EAA0B,EAAK,CAG9C,MAAM,GAA4B,EAAc,IAC9C,EAAK,WAAW,EAAO"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=/^(?:0|[1-9][0-9]*)$/u;function t(n){let r=[],i=/\.{0,4096}(?<propName>[^.[\]]+)|\['(?<quoted>.{0,4096}?)'\]|\["(?<doubleQuoted>.{0,4096}?)"\]|\[(?<unquoted>.{0,4096}?)\]/uy,a;for(;(a=i.exec(n))!==null;){let{propName:n,quoted:i,doubleQuoted:o,unquoted:s}=a.groups;if(s!==void 0){r.push(...t(s));continue}r.push(n===void 0?i??o:e.test(n)?Number(n):n)}return r}exports.stringToPath=t;
2
+ //# sourceMappingURL=stringToPath.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringToPath.cjs","names":[],"sources":["../src/stringToPath.ts"],"sourcesContent":["import type { IsNumericLiteral, IsStringLiteral } from \"type-fest\";\n\n// This is the most efficient way to check an arbitrary string if it is a simple\n// non-negative integer. We use character ranges instead of the `\\d` character\n// class to avoid matching non-ascii digits (e.g. Arabic-Indic digits), while\n// maintaining that the regular expression supports unicode.\nconst NON_NEGATIVE_INTEGER_RE = /^(?:0|[1-9][0-9]*)$/u;\n\ntype StringToPath<S> =\n // We can only compute the path type for literals that TypeScript can\n // break down further into parts.\n IsStringLiteral<S> extends true ? StringToPathImpl<S> : (string | number)[];\n\ntype StringToPathImpl<S> =\n // We start by checking the 2 quoted variants of the square bracket access\n // syntax. We do this in a single check and not in a subsequent check that\n // would only extract the quoted part so that we can catch cases where the\n // quoted part itself contains square brackets. This allows TypeScript to be\n // \"greedy\" about what it infers into Quoted and DoubleQuoted.\n S extends `${infer Head}['${infer Quoted}']${infer Tail}`\n ? [...StringToPath<Head>, Quoted, ...StringToPath<Tail>]\n : S extends `${infer Head}[\"${infer DoubleQuoted}\"]${infer Tail}`\n ? [...StringToPath<Head>, DoubleQuoted, ...StringToPath<Tail>]\n : // If we have an unquoted property access we also need to run the\n // contents recursively too (unlike the quoted variants above).\n S extends `${infer Head}[${infer Unquoted}]${infer Tail}`\n ? [\n ...StringToPath<Head>,\n ...StringToPath<Unquoted>,\n ...StringToPath<Tail>,\n ]\n : // Finally, we process any dots one after the other from left to\n // right. TypeScript will be non-greedy here, putting *everything*\n // after the first dot into the Tail.\n S extends `${infer Head}.${infer Tail}`\n ? [...StringToPath<Head>, ...StringToPath<Tail>]\n : // Finally we need to handle the few cases of simple literals.\n \"\" extends S\n ? // There are some edge-cases where Lodash will try to access an\n // empty property, but those seem nonsensical in practice so we\n // prefer just skipping these cases.\n []\n : // We differ from Lodash in the way we handle numbers. Lodash\n // returns everything in the path as a string, and relies on JS to\n // coerce array accessors to numbers (or the other way around in\n // practice, e.g., `myArray[123] === myArray['123']`), but from a\n // typing perspective the two are not the same and we need the\n // path to be accurate about it.\n S extends `${infer N extends number}`\n ? [\n // TypeScript considers \" 123 \" to still extend `${number}`,\n // but would type is as `string` instead of a literal. We\n // can use that fact to make sure we only consider simple\n // number literals as numbers, and take the rest as strings.\n IsNumericLiteral<N> extends true ? N : S,\n ]\n : // This simplest form of a path is just a single string literal.\n [S];\n\n/**\n * A utility to allow JSONPath-like strings to be used in other utilities which\n * take an array of path segments as input (e.g. `prop`, `setPath`, etc...).\n * The main purpose of this utility is to act as a bridge between the runtime\n * implementation that converts the path to an array, and the type-system that\n * parses the path string **type** into an array **type**. This type allows us\n * to return fine-grained types and to enforce correctness at the type-level.\n *\n * We **discourage** using this utility for new code. This utility is for legacy\n * code that already contains path strings (which are accepted by Lodash). We\n * strongly recommend using *path arrays* instead as they provide better\n * developer experience via significantly faster type-checking, fine-grained\n * error messages, and automatic typeahead suggestions for each segment of the\n * path.\n *\n * *There are a bunch of limitations to this utility derived from the\n * limitations of the type itself, these are usually edge-cases around deeply\n * nested paths, escaping, whitespaces, and empty segments. This is true even\n * in cases where the runtime implementation can better handle them, this is\n * intentional. See the tests for this utility for more details and the\n * expected outputs*.\n *\n * @param path - A string path.\n * @signature\n * stringToPath(path)\n * @example\n * stringToPath('a.b[0].c') // => ['a', 'b', 0, 'c']\n * @dataFirst\n * @category Utility\n */\nexport function stringToPath<const Path extends string>(\n path: Path,\n): StringToPath<Path> {\n const result: (string | number)[] = [];\n\n // There are four possible ways to define a path segment::\n // - `propName`: is used to parse dot-notation paths, e.g. 'foo.bar.baz', we\n // allow multiple sequential dots because our type allows them, but they are\n // semantically meaningless. Note that this would also allow strings starting\n // with a dot, e.g. `.foo`, this is fine because the dot itself is just used\n // as a separator and is ignored in the final path.\n // - `quoted`, `doubleQuoted`: used within square bracket notation to prevent\n // any recursive parsing of their contents. As for the type itself, we only\n // allow quote symbols to appear immediately after the opening square bracket\n // and immediately before the closing square bracket, this allows us to handle\n // more gracefully cases where a quote symbol might appear within the quoted\n // part.\n // - `unquoted`: If the contents of the square brackets are not quoted they\n // will match this group (this is why the order is important here!). Contents\n // of this group get parsed *recursively*.\n //\n // NOTE: We limit all repeats to 4096 characters to avoid a possible attack\n // vector when the input to this function is controlled by the user. This is\n // due to a DoS timing attack because regex backtracking is non-linear.\n // @see: https://codeql.github.com/codeql-query-help/javascript/js-polynomial-redos/\n const pathSegmentRe =\n /\\.{0,4096}(?<propName>[^.[\\]]+)|\\['(?<quoted>.{0,4096}?)'\\]|\\[\"(?<doubleQuoted>.{0,4096}?)\"\\]|\\[(?<unquoted>.{0,4096}?)\\]/uy;\n\n let match: RegExpExecArray | null;\n while ((match = pathSegmentRe.exec(path)) !== null) {\n const { propName, quoted, doubleQuoted, unquoted } = match.groups!;\n\n if (unquoted !== undefined) {\n result.push(...stringToPath(unquoted));\n continue;\n }\n\n result.push(\n propName === undefined\n ? (quoted ?? doubleQuoted!)\n : // The only way to differentiate between array indices and properties\n // is to check if the property is a non-negative integer. In those\n // cases we perform the conversion (unlike Lodash).\n NON_NEGATIVE_INTEGER_RE.test(propName)\n ? Number(propName)\n : propName,\n );\n }\n\n return result;\n}\n"],"mappings":"mEAMA,MAAM,EAA0B,uBAmFhC,SAAgB,EACd,EACoB,CACpB,IAAM,EAA8B,EAAE,CAsBhC,EACJ,8HAEE,EACJ,MAAQ,EAAQ,EAAc,KAAK,EAAK,IAAM,MAAM,CAClD,GAAM,CAAE,WAAU,SAAQ,eAAc,YAAa,EAAM,OAE3D,GAAI,IAAa,IAAA,GAAW,CAC1B,EAAO,KAAK,GAAG,EAAa,EAAS,CAAC,CACtC,SAGF,EAAO,KACL,IAAa,IAAA,GACR,GAAU,EAIX,EAAwB,KAAK,EAAS,CACpC,OAAO,EAAS,CAChB,EACP,CAGH,OAAO"}
@@ -0,0 +1,2 @@
1
+ const e=/^(?:0|[1-9][0-9]*)$/u;function t(n){let r=[],i=/\.{0,4096}(?<propName>[^.[\]]+)|\['(?<quoted>.{0,4096}?)'\]|\["(?<doubleQuoted>.{0,4096}?)"\]|\[(?<unquoted>.{0,4096}?)\]/uy,a;for(;(a=i.exec(n))!==null;){let{propName:n,quoted:i,doubleQuoted:o,unquoted:s}=a.groups;if(s!==void 0){r.push(...t(s));continue}r.push(n===void 0?i??o:e.test(n)?Number(n):n)}return r}export{t as stringToPath};
2
+ //# sourceMappingURL=stringToPath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringToPath.js","names":[],"sources":["../src/stringToPath.ts"],"sourcesContent":["import type { IsNumericLiteral, IsStringLiteral } from \"type-fest\";\n\n// This is the most efficient way to check an arbitrary string if it is a simple\n// non-negative integer. We use character ranges instead of the `\\d` character\n// class to avoid matching non-ascii digits (e.g. Arabic-Indic digits), while\n// maintaining that the regular expression supports unicode.\nconst NON_NEGATIVE_INTEGER_RE = /^(?:0|[1-9][0-9]*)$/u;\n\ntype StringToPath<S> =\n // We can only compute the path type for literals that TypeScript can\n // break down further into parts.\n IsStringLiteral<S> extends true ? StringToPathImpl<S> : (string | number)[];\n\ntype StringToPathImpl<S> =\n // We start by checking the 2 quoted variants of the square bracket access\n // syntax. We do this in a single check and not in a subsequent check that\n // would only extract the quoted part so that we can catch cases where the\n // quoted part itself contains square brackets. This allows TypeScript to be\n // \"greedy\" about what it infers into Quoted and DoubleQuoted.\n S extends `${infer Head}['${infer Quoted}']${infer Tail}`\n ? [...StringToPath<Head>, Quoted, ...StringToPath<Tail>]\n : S extends `${infer Head}[\"${infer DoubleQuoted}\"]${infer Tail}`\n ? [...StringToPath<Head>, DoubleQuoted, ...StringToPath<Tail>]\n : // If we have an unquoted property access we also need to run the\n // contents recursively too (unlike the quoted variants above).\n S extends `${infer Head}[${infer Unquoted}]${infer Tail}`\n ? [\n ...StringToPath<Head>,\n ...StringToPath<Unquoted>,\n ...StringToPath<Tail>,\n ]\n : // Finally, we process any dots one after the other from left to\n // right. TypeScript will be non-greedy here, putting *everything*\n // after the first dot into the Tail.\n S extends `${infer Head}.${infer Tail}`\n ? [...StringToPath<Head>, ...StringToPath<Tail>]\n : // Finally we need to handle the few cases of simple literals.\n \"\" extends S\n ? // There are some edge-cases where Lodash will try to access an\n // empty property, but those seem nonsensical in practice so we\n // prefer just skipping these cases.\n []\n : // We differ from Lodash in the way we handle numbers. Lodash\n // returns everything in the path as a string, and relies on JS to\n // coerce array accessors to numbers (or the other way around in\n // practice, e.g., `myArray[123] === myArray['123']`), but from a\n // typing perspective the two are not the same and we need the\n // path to be accurate about it.\n S extends `${infer N extends number}`\n ? [\n // TypeScript considers \" 123 \" to still extend `${number}`,\n // but would type is as `string` instead of a literal. We\n // can use that fact to make sure we only consider simple\n // number literals as numbers, and take the rest as strings.\n IsNumericLiteral<N> extends true ? N : S,\n ]\n : // This simplest form of a path is just a single string literal.\n [S];\n\n/**\n * A utility to allow JSONPath-like strings to be used in other utilities which\n * take an array of path segments as input (e.g. `prop`, `setPath`, etc...).\n * The main purpose of this utility is to act as a bridge between the runtime\n * implementation that converts the path to an array, and the type-system that\n * parses the path string **type** into an array **type**. This type allows us\n * to return fine-grained types and to enforce correctness at the type-level.\n *\n * We **discourage** using this utility for new code. This utility is for legacy\n * code that already contains path strings (which are accepted by Lodash). We\n * strongly recommend using *path arrays* instead as they provide better\n * developer experience via significantly faster type-checking, fine-grained\n * error messages, and automatic typeahead suggestions for each segment of the\n * path.\n *\n * *There are a bunch of limitations to this utility derived from the\n * limitations of the type itself, these are usually edge-cases around deeply\n * nested paths, escaping, whitespaces, and empty segments. This is true even\n * in cases where the runtime implementation can better handle them, this is\n * intentional. See the tests for this utility for more details and the\n * expected outputs*.\n *\n * @param path - A string path.\n * @signature\n * stringToPath(path)\n * @example\n * stringToPath('a.b[0].c') // => ['a', 'b', 0, 'c']\n * @dataFirst\n * @category Utility\n */\nexport function stringToPath<const Path extends string>(\n path: Path,\n): StringToPath<Path> {\n const result: (string | number)[] = [];\n\n // There are four possible ways to define a path segment::\n // - `propName`: is used to parse dot-notation paths, e.g. 'foo.bar.baz', we\n // allow multiple sequential dots because our type allows them, but they are\n // semantically meaningless. Note that this would also allow strings starting\n // with a dot, e.g. `.foo`, this is fine because the dot itself is just used\n // as a separator and is ignored in the final path.\n // - `quoted`, `doubleQuoted`: used within square bracket notation to prevent\n // any recursive parsing of their contents. As for the type itself, we only\n // allow quote symbols to appear immediately after the opening square bracket\n // and immediately before the closing square bracket, this allows us to handle\n // more gracefully cases where a quote symbol might appear within the quoted\n // part.\n // - `unquoted`: If the contents of the square brackets are not quoted they\n // will match this group (this is why the order is important here!). Contents\n // of this group get parsed *recursively*.\n //\n // NOTE: We limit all repeats to 4096 characters to avoid a possible attack\n // vector when the input to this function is controlled by the user. This is\n // due to a DoS timing attack because regex backtracking is non-linear.\n // @see: https://codeql.github.com/codeql-query-help/javascript/js-polynomial-redos/\n const pathSegmentRe =\n /\\.{0,4096}(?<propName>[^.[\\]]+)|\\['(?<quoted>.{0,4096}?)'\\]|\\[\"(?<doubleQuoted>.{0,4096}?)\"\\]|\\[(?<unquoted>.{0,4096}?)\\]/uy;\n\n let match: RegExpExecArray | null;\n while ((match = pathSegmentRe.exec(path)) !== null) {\n const { propName, quoted, doubleQuoted, unquoted } = match.groups!;\n\n if (unquoted !== undefined) {\n result.push(...stringToPath(unquoted));\n continue;\n }\n\n result.push(\n propName === undefined\n ? (quoted ?? doubleQuoted!)\n : // The only way to differentiate between array indices and properties\n // is to check if the property is a non-negative integer. In those\n // cases we perform the conversion (unlike Lodash).\n NON_NEGATIVE_INTEGER_RE.test(propName)\n ? Number(propName)\n : propName,\n );\n }\n\n return result;\n}\n"],"mappings":"AAMA,MAAM,EAA0B,uBAmFhC,SAAgB,EACd,EACoB,CACpB,IAAM,EAA8B,EAAE,CAsBhC,EACJ,8HAEE,EACJ,MAAQ,EAAQ,EAAc,KAAK,EAAK,IAAM,MAAM,CAClD,GAAM,CAAE,WAAU,SAAQ,eAAc,YAAa,EAAM,OAE3D,GAAI,IAAa,IAAA,GAAW,CAC1B,EAAO,KAAK,GAAG,EAAa,EAAS,CAAC,CACtC,SAGF,EAAO,KACL,IAAa,IAAA,GACR,GAAU,EAIX,EAAwB,KAAK,EAAS,CACpC,OAAO,EAAS,CAChB,EACP,CAGH,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)}const n=(e,t)=>e-t;exports.subtract=t;
2
+ //# sourceMappingURL=subtract.cjs.map