@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.
- package/README.md +25 -0
- package/changes.json +5 -0
- package/dist/add.cjs +2 -0
- package/dist/add.cjs.map +1 -0
- package/dist/add.js +2 -0
- package/dist/add.js.map +1 -0
- package/dist/addProp.cjs +2 -0
- package/dist/addProp.cjs.map +1 -0
- package/dist/addProp.js +2 -0
- package/dist/addProp.js.map +1 -0
- package/dist/allPass.cjs +2 -0
- package/dist/allPass.cjs.map +1 -0
- package/dist/allPass.js +2 -0
- package/dist/allPass.js.map +1 -0
- package/dist/anyPass.cjs +2 -0
- package/dist/anyPass.cjs.map +1 -0
- package/dist/anyPass.js +2 -0
- package/dist/anyPass.js.map +1 -0
- package/dist/binarySearchCutoffIndex-CLQRwIY1.js +2 -0
- package/dist/binarySearchCutoffIndex-CLQRwIY1.js.map +1 -0
- package/dist/binarySearchCutoffIndex-DdLPjZiy.cjs +2 -0
- package/dist/binarySearchCutoffIndex-DdLPjZiy.cjs.map +1 -0
- package/dist/capitalize.cjs +2 -0
- package/dist/capitalize.cjs.map +1 -0
- package/dist/capitalize.js +2 -0
- package/dist/capitalize.js.map +1 -0
- package/dist/ceil.cjs +2 -0
- package/dist/ceil.cjs.map +1 -0
- package/dist/ceil.js +2 -0
- package/dist/ceil.js.map +1 -0
- package/dist/chunk.cjs +2 -0
- package/dist/chunk.cjs.map +1 -0
- package/dist/chunk.js +2 -0
- package/dist/chunk.js.map +1 -0
- package/dist/clamp.cjs +2 -0
- package/dist/clamp.cjs.map +1 -0
- package/dist/clamp.js +2 -0
- package/dist/clamp.js.map +1 -0
- package/dist/clone.cjs +2 -0
- package/dist/clone.cjs.map +1 -0
- package/dist/clone.js +2 -0
- package/dist/clone.js.map +1 -0
- package/dist/concat.cjs +2 -0
- package/dist/concat.cjs.map +1 -0
- package/dist/concat.js +2 -0
- package/dist/concat.js.map +1 -0
- package/dist/conditional.cjs +2 -0
- package/dist/conditional.cjs.map +1 -0
- package/dist/conditional.js +2 -0
- package/dist/conditional.js.map +1 -0
- package/dist/constant.cjs +2 -0
- package/dist/constant.cjs.map +1 -0
- package/dist/constant.js +2 -0
- package/dist/constant.js.map +1 -0
- package/dist/countBy.cjs +2 -0
- package/dist/countBy.cjs.map +1 -0
- package/dist/countBy.js +2 -0
- package/dist/countBy.js.map +1 -0
- package/dist/debounce.cjs +2 -0
- package/dist/debounce.cjs.map +1 -0
- package/dist/debounce.js +2 -0
- package/dist/debounce.js.map +1 -0
- package/dist/defaultTo.cjs +2 -0
- package/dist/defaultTo.cjs.map +1 -0
- package/dist/defaultTo.js +2 -0
- package/dist/defaultTo.js.map +1 -0
- package/dist/difference.cjs +2 -0
- package/dist/difference.cjs.map +1 -0
- package/dist/difference.js +2 -0
- package/dist/difference.js.map +1 -0
- package/dist/differenceWith.cjs +2 -0
- package/dist/differenceWith.cjs.map +1 -0
- package/dist/differenceWith.js +2 -0
- package/dist/differenceWith.js.map +1 -0
- package/dist/divide.cjs +2 -0
- package/dist/divide.cjs.map +1 -0
- package/dist/divide.js +2 -0
- package/dist/divide.js.map +1 -0
- package/dist/doNothing.cjs +2 -0
- package/dist/doNothing.cjs.map +1 -0
- package/dist/doNothing.js +2 -0
- package/dist/doNothing.js.map +1 -0
- package/dist/drop.cjs +2 -0
- package/dist/drop.cjs.map +1 -0
- package/dist/drop.js +2 -0
- package/dist/drop.js.map +1 -0
- package/dist/dropFirstBy.cjs +2 -0
- package/dist/dropFirstBy.cjs.map +1 -0
- package/dist/dropFirstBy.js +2 -0
- package/dist/dropFirstBy.js.map +1 -0
- package/dist/dropLast.cjs +2 -0
- package/dist/dropLast.cjs.map +1 -0
- package/dist/dropLast.js +2 -0
- package/dist/dropLast.js.map +1 -0
- package/dist/dropLastWhile.cjs +2 -0
- package/dist/dropLastWhile.cjs.map +1 -0
- package/dist/dropLastWhile.js +2 -0
- package/dist/dropLastWhile.js.map +1 -0
- package/dist/dropWhile.cjs +2 -0
- package/dist/dropWhile.cjs.map +1 -0
- package/dist/dropWhile.js +2 -0
- package/dist/dropWhile.js.map +1 -0
- package/dist/endsWith.cjs +2 -0
- package/dist/endsWith.cjs.map +1 -0
- package/dist/endsWith.js +2 -0
- package/dist/endsWith.js.map +1 -0
- package/dist/entries.cjs +2 -0
- package/dist/entries.cjs.map +1 -0
- package/dist/entries.js +2 -0
- package/dist/entries.js.map +1 -0
- package/dist/evolve.cjs +2 -0
- package/dist/evolve.cjs.map +1 -0
- package/dist/evolve.js +2 -0
- package/dist/evolve.js.map +1 -0
- package/dist/filter.cjs +2 -0
- package/dist/filter.cjs.map +1 -0
- package/dist/filter.js +2 -0
- package/dist/filter.js.map +1 -0
- package/dist/find.cjs +2 -0
- package/dist/find.cjs.map +1 -0
- package/dist/find.js +2 -0
- package/dist/find.js.map +1 -0
- package/dist/findIndex.cjs +2 -0
- package/dist/findIndex.cjs.map +1 -0
- package/dist/findIndex.js +2 -0
- package/dist/findIndex.js.map +1 -0
- package/dist/findLast.cjs +2 -0
- package/dist/findLast.cjs.map +1 -0
- package/dist/findLast.js +2 -0
- package/dist/findLast.js.map +1 -0
- package/dist/findLastIndex.cjs +2 -0
- package/dist/findLastIndex.cjs.map +1 -0
- package/dist/findLastIndex.js +2 -0
- package/dist/findLastIndex.js.map +1 -0
- package/dist/first.cjs +2 -0
- package/dist/first.cjs.map +1 -0
- package/dist/first.js +2 -0
- package/dist/first.js.map +1 -0
- package/dist/firstBy.cjs +2 -0
- package/dist/firstBy.cjs.map +1 -0
- package/dist/firstBy.js +2 -0
- package/dist/firstBy.js.map +1 -0
- package/dist/flat.cjs +2 -0
- package/dist/flat.cjs.map +1 -0
- package/dist/flat.js +2 -0
- package/dist/flat.js.map +1 -0
- package/dist/flatMap.cjs +2 -0
- package/dist/flatMap.cjs.map +1 -0
- package/dist/flatMap.js +2 -0
- package/dist/flatMap.js.map +1 -0
- package/dist/floor.cjs +2 -0
- package/dist/floor.cjs.map +1 -0
- package/dist/floor.js +2 -0
- package/dist/floor.js.map +1 -0
- package/dist/forEach.cjs +2 -0
- package/dist/forEach.cjs.map +1 -0
- package/dist/forEach.js +2 -0
- package/dist/forEach.js.map +1 -0
- package/dist/forEachObj.cjs +2 -0
- package/dist/forEachObj.cjs.map +1 -0
- package/dist/forEachObj.js +2 -0
- package/dist/forEachObj.js.map +1 -0
- package/dist/fromEntries.cjs +2 -0
- package/dist/fromEntries.cjs.map +1 -0
- package/dist/fromEntries.js +2 -0
- package/dist/fromEntries.js.map +1 -0
- package/dist/fromKeys.cjs +2 -0
- package/dist/fromKeys.cjs.map +1 -0
- package/dist/fromKeys.js +2 -0
- package/dist/fromKeys.js.map +1 -0
- package/dist/funnel.cjs +2 -0
- package/dist/funnel.cjs.map +1 -0
- package/dist/funnel.js +2 -0
- package/dist/funnel.js.map +1 -0
- package/dist/groupBy.cjs +2 -0
- package/dist/groupBy.cjs.map +1 -0
- package/dist/groupBy.js +2 -0
- package/dist/groupBy.js.map +1 -0
- package/dist/groupByProp.cjs +2 -0
- package/dist/groupByProp.cjs.map +1 -0
- package/dist/groupByProp.js +2 -0
- package/dist/groupByProp.js.map +1 -0
- package/dist/hasAtLeast.cjs +2 -0
- package/dist/hasAtLeast.cjs.map +1 -0
- package/dist/hasAtLeast.js +2 -0
- package/dist/hasAtLeast.js.map +1 -0
- package/dist/hasSubObject.cjs +2 -0
- package/dist/hasSubObject.cjs.map +1 -0
- package/dist/hasSubObject.js +2 -0
- package/dist/hasSubObject.js.map +1 -0
- package/dist/heap-14xVkDB1.cjs +2 -0
- package/dist/heap-14xVkDB1.cjs.map +1 -0
- package/dist/heap-OOe_F8_z.js +2 -0
- package/dist/heap-OOe_F8_z.js.map +1 -0
- package/dist/identity.cjs +2 -0
- package/dist/identity.cjs.map +1 -0
- package/dist/identity.js +2 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +11948 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +11948 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/indexBy.cjs +2 -0
- package/dist/indexBy.cjs.map +1 -0
- package/dist/indexBy.js +2 -0
- package/dist/indexBy.js.map +1 -0
- package/dist/intersection.cjs +2 -0
- package/dist/intersection.cjs.map +1 -0
- package/dist/intersection.js +2 -0
- package/dist/intersection.js.map +1 -0
- package/dist/intersectionWith.cjs +2 -0
- package/dist/intersectionWith.cjs.map +1 -0
- package/dist/intersectionWith.js +2 -0
- package/dist/intersectionWith.js.map +1 -0
- package/dist/invert.cjs +2 -0
- package/dist/invert.cjs.map +1 -0
- package/dist/invert.js +2 -0
- package/dist/invert.js.map +1 -0
- package/dist/isArray.cjs +2 -0
- package/dist/isArray.cjs.map +1 -0
- package/dist/isArray.js +2 -0
- package/dist/isArray.js.map +1 -0
- package/dist/isBigInt.cjs +2 -0
- package/dist/isBigInt.cjs.map +1 -0
- package/dist/isBigInt.js +2 -0
- package/dist/isBigInt.js.map +1 -0
- package/dist/isBoolean.cjs +2 -0
- package/dist/isBoolean.cjs.map +1 -0
- package/dist/isBoolean.js +2 -0
- package/dist/isBoolean.js.map +1 -0
- package/dist/isDate.cjs +2 -0
- package/dist/isDate.cjs.map +1 -0
- package/dist/isDate.js +2 -0
- package/dist/isDate.js.map +1 -0
- package/dist/isDeepEqual.cjs +2 -0
- package/dist/isDeepEqual.cjs.map +1 -0
- package/dist/isDeepEqual.js +2 -0
- package/dist/isDeepEqual.js.map +1 -0
- package/dist/isDefined.cjs +2 -0
- package/dist/isDefined.cjs.map +1 -0
- package/dist/isDefined.js +2 -0
- package/dist/isDefined.js.map +1 -0
- package/dist/isEmpty.cjs +2 -0
- package/dist/isEmpty.cjs.map +1 -0
- package/dist/isEmpty.js +2 -0
- package/dist/isEmpty.js.map +1 -0
- package/dist/isEmptyish.cjs +2 -0
- package/dist/isEmptyish.cjs.map +1 -0
- package/dist/isEmptyish.js +2 -0
- package/dist/isEmptyish.js.map +1 -0
- package/dist/isError.cjs +2 -0
- package/dist/isError.cjs.map +1 -0
- package/dist/isError.js +2 -0
- package/dist/isError.js.map +1 -0
- package/dist/isFunction.cjs +2 -0
- package/dist/isFunction.cjs.map +1 -0
- package/dist/isFunction.js +2 -0
- package/dist/isFunction.js.map +1 -0
- package/dist/isIncludedIn.cjs +2 -0
- package/dist/isIncludedIn.cjs.map +1 -0
- package/dist/isIncludedIn.js +2 -0
- package/dist/isIncludedIn.js.map +1 -0
- package/dist/isNonNull.cjs +2 -0
- package/dist/isNonNull.cjs.map +1 -0
- package/dist/isNonNull.js +2 -0
- package/dist/isNonNull.js.map +1 -0
- package/dist/isNonNullish.cjs +2 -0
- package/dist/isNonNullish.cjs.map +1 -0
- package/dist/isNonNullish.js +2 -0
- package/dist/isNonNullish.js.map +1 -0
- package/dist/isNot.cjs +2 -0
- package/dist/isNot.cjs.map +1 -0
- package/dist/isNot.js +2 -0
- package/dist/isNot.js.map +1 -0
- package/dist/isNullish.cjs +2 -0
- package/dist/isNullish.cjs.map +1 -0
- package/dist/isNullish.js +2 -0
- package/dist/isNullish.js.map +1 -0
- package/dist/isNumber.cjs +2 -0
- package/dist/isNumber.cjs.map +1 -0
- package/dist/isNumber.js +2 -0
- package/dist/isNumber.js.map +1 -0
- package/dist/isObjectType.cjs +2 -0
- package/dist/isObjectType.cjs.map +1 -0
- package/dist/isObjectType.js +2 -0
- package/dist/isObjectType.js.map +1 -0
- package/dist/isPlainObject.cjs +2 -0
- package/dist/isPlainObject.cjs.map +1 -0
- package/dist/isPlainObject.js +2 -0
- package/dist/isPlainObject.js.map +1 -0
- package/dist/isPromise.cjs +2 -0
- package/dist/isPromise.cjs.map +1 -0
- package/dist/isPromise.js +2 -0
- package/dist/isPromise.js.map +1 -0
- package/dist/isShallowEqual.cjs +2 -0
- package/dist/isShallowEqual.cjs.map +1 -0
- package/dist/isShallowEqual.js +2 -0
- package/dist/isShallowEqual.js.map +1 -0
- package/dist/isStrictEqual.cjs +2 -0
- package/dist/isStrictEqual.cjs.map +1 -0
- package/dist/isStrictEqual.js +2 -0
- package/dist/isStrictEqual.js.map +1 -0
- package/dist/isString.cjs +2 -0
- package/dist/isString.cjs.map +1 -0
- package/dist/isString.js +2 -0
- package/dist/isString.js.map +1 -0
- package/dist/isSymbol.cjs +2 -0
- package/dist/isSymbol.cjs.map +1 -0
- package/dist/isSymbol.js +2 -0
- package/dist/isSymbol.js.map +1 -0
- package/dist/isTruthy.cjs +2 -0
- package/dist/isTruthy.cjs.map +1 -0
- package/dist/isTruthy.js +2 -0
- package/dist/isTruthy.js.map +1 -0
- package/dist/join.cjs +2 -0
- package/dist/join.cjs.map +1 -0
- package/dist/join.js +2 -0
- package/dist/join.js.map +1 -0
- package/dist/keys.cjs +2 -0
- package/dist/keys.cjs.map +1 -0
- package/dist/keys.js +2 -0
- package/dist/keys.js.map +1 -0
- package/dist/last.cjs +2 -0
- package/dist/last.cjs.map +1 -0
- package/dist/last.js +2 -0
- package/dist/last.js.map +1 -0
- package/dist/lazyDataLastImpl-DdpJofHC.cjs +2 -0
- package/dist/lazyDataLastImpl-DdpJofHC.cjs.map +1 -0
- package/dist/lazyDataLastImpl-DtF3cihj.js +2 -0
- package/dist/lazyDataLastImpl-DtF3cihj.js.map +1 -0
- package/dist/length.cjs +2 -0
- package/dist/length.cjs.map +1 -0
- package/dist/length.js +2 -0
- package/dist/length.js.map +1 -0
- package/dist/map.cjs +2 -0
- package/dist/map.cjs.map +1 -0
- package/dist/map.js +2 -0
- package/dist/map.js.map +1 -0
- package/dist/mapKeys.cjs +2 -0
- package/dist/mapKeys.cjs.map +1 -0
- package/dist/mapKeys.js +2 -0
- package/dist/mapKeys.js.map +1 -0
- package/dist/mapToObj.cjs +2 -0
- package/dist/mapToObj.cjs.map +1 -0
- package/dist/mapToObj.js +2 -0
- package/dist/mapToObj.js.map +1 -0
- package/dist/mapValues.cjs +2 -0
- package/dist/mapValues.cjs.map +1 -0
- package/dist/mapValues.js +2 -0
- package/dist/mapValues.js.map +1 -0
- package/dist/mapWithFeedback.cjs +2 -0
- package/dist/mapWithFeedback.cjs.map +1 -0
- package/dist/mapWithFeedback.js +2 -0
- package/dist/mapWithFeedback.js.map +1 -0
- package/dist/mean.cjs +2 -0
- package/dist/mean.cjs.map +1 -0
- package/dist/mean.js +2 -0
- package/dist/mean.js.map +1 -0
- package/dist/meanBy.cjs +2 -0
- package/dist/meanBy.cjs.map +1 -0
- package/dist/meanBy.js +2 -0
- package/dist/meanBy.js.map +1 -0
- package/dist/median.cjs +2 -0
- package/dist/median.cjs.map +1 -0
- package/dist/median.js +2 -0
- package/dist/median.js.map +1 -0
- package/dist/merge.cjs +2 -0
- package/dist/merge.cjs.map +1 -0
- package/dist/merge.js +2 -0
- package/dist/merge.js.map +1 -0
- package/dist/mergeAll.cjs +2 -0
- package/dist/mergeAll.cjs.map +1 -0
- package/dist/mergeAll.js +2 -0
- package/dist/mergeAll.js.map +1 -0
- package/dist/mergeDeep.cjs +2 -0
- package/dist/mergeDeep.cjs.map +1 -0
- package/dist/mergeDeep.js +2 -0
- package/dist/mergeDeep.js.map +1 -0
- package/dist/multiply.cjs +2 -0
- package/dist/multiply.cjs.map +1 -0
- package/dist/multiply.js +2 -0
- package/dist/multiply.js.map +1 -0
- package/dist/nthBy.cjs +2 -0
- package/dist/nthBy.cjs.map +1 -0
- package/dist/nthBy.js +2 -0
- package/dist/nthBy.js.map +1 -0
- package/dist/objOf.cjs +2 -0
- package/dist/objOf.cjs.map +1 -0
- package/dist/objOf.js +2 -0
- package/dist/objOf.js.map +1 -0
- package/dist/omit.cjs +2 -0
- package/dist/omit.cjs.map +1 -0
- package/dist/omit.js +2 -0
- package/dist/omit.js.map +1 -0
- package/dist/omitBy.cjs +2 -0
- package/dist/omitBy.cjs.map +1 -0
- package/dist/omitBy.js +2 -0
- package/dist/omitBy.js.map +1 -0
- package/dist/once.cjs +2 -0
- package/dist/once.cjs.map +1 -0
- package/dist/once.js +2 -0
- package/dist/once.js.map +1 -0
- package/dist/only.cjs +2 -0
- package/dist/only.cjs.map +1 -0
- package/dist/only.js +2 -0
- package/dist/only.js.map +1 -0
- package/dist/partialBind.cjs +2 -0
- package/dist/partialBind.cjs.map +1 -0
- package/dist/partialBind.js +2 -0
- package/dist/partialBind.js.map +1 -0
- package/dist/partialLastBind.cjs +2 -0
- package/dist/partialLastBind.cjs.map +1 -0
- package/dist/partialLastBind.js +2 -0
- package/dist/partialLastBind.js.map +1 -0
- package/dist/partition.cjs +2 -0
- package/dist/partition.cjs.map +1 -0
- package/dist/partition.js +2 -0
- package/dist/partition.js.map +1 -0
- package/dist/pathOr.cjs +2 -0
- package/dist/pathOr.cjs.map +1 -0
- package/dist/pathOr.js +2 -0
- package/dist/pathOr.js.map +1 -0
- package/dist/pick.cjs +2 -0
- package/dist/pick.cjs.map +1 -0
- package/dist/pick.js +2 -0
- package/dist/pick.js.map +1 -0
- package/dist/pickBy.cjs +2 -0
- package/dist/pickBy.cjs.map +1 -0
- package/dist/pickBy.js +2 -0
- package/dist/pickBy.js.map +1 -0
- package/dist/pipe.cjs +2 -0
- package/dist/pipe.cjs.map +1 -0
- package/dist/pipe.js +2 -0
- package/dist/pipe.js.map +1 -0
- package/dist/piped.cjs +2 -0
- package/dist/piped.cjs.map +1 -0
- package/dist/piped.js +2 -0
- package/dist/piped.js.map +1 -0
- package/dist/product.cjs +2 -0
- package/dist/product.cjs.map +1 -0
- package/dist/product.js +2 -0
- package/dist/product.js.map +1 -0
- package/dist/prop.cjs +2 -0
- package/dist/prop.cjs.map +1 -0
- package/dist/prop.js +2 -0
- package/dist/prop.js.map +1 -0
- package/dist/pullObject.cjs +2 -0
- package/dist/pullObject.cjs.map +1 -0
- package/dist/pullObject.js +2 -0
- package/dist/pullObject.js.map +1 -0
- package/dist/purry.cjs +2 -0
- package/dist/purry.cjs.map +1 -0
- package/dist/purry.js +2 -0
- package/dist/purry.js.map +1 -0
- package/dist/purryFromLazy-B-_oTxzb.js +2 -0
- package/dist/purryFromLazy-B-_oTxzb.js.map +1 -0
- package/dist/purryFromLazy-CwB5T8yd.cjs +2 -0
- package/dist/purryFromLazy-CwB5T8yd.cjs.map +1 -0
- package/dist/purryOn-D4wFIFMT.js +2 -0
- package/dist/purryOn-D4wFIFMT.js.map +1 -0
- package/dist/purryOn-DdnETb-0.cjs +2 -0
- package/dist/purryOn-DdnETb-0.cjs.map +1 -0
- package/dist/purryOrderRules-4JgY6z4X.js +2 -0
- package/dist/purryOrderRules-4JgY6z4X.js.map +1 -0
- package/dist/purryOrderRules-B8pzD03D.cjs +2 -0
- package/dist/purryOrderRules-B8pzD03D.cjs.map +1 -0
- package/dist/quickSelect-B4eZ0JeB.js +2 -0
- package/dist/quickSelect-B4eZ0JeB.js.map +1 -0
- package/dist/quickSelect-BwH5h4uh.cjs +2 -0
- package/dist/quickSelect-BwH5h4uh.cjs.map +1 -0
- package/dist/randomBigInt.cjs +2 -0
- package/dist/randomBigInt.cjs.map +1 -0
- package/dist/randomBigInt.js +2 -0
- package/dist/randomBigInt.js.map +1 -0
- package/dist/randomInteger.cjs +2 -0
- package/dist/randomInteger.cjs.map +1 -0
- package/dist/randomInteger.js +2 -0
- package/dist/randomInteger.js.map +1 -0
- package/dist/randomString.cjs +2 -0
- package/dist/randomString.cjs.map +1 -0
- package/dist/randomString.js +2 -0
- package/dist/randomString.js.map +1 -0
- package/dist/range.cjs +2 -0
- package/dist/range.cjs.map +1 -0
- package/dist/range.js +2 -0
- package/dist/range.js.map +1 -0
- package/dist/rankBy.cjs +2 -0
- package/dist/rankBy.cjs.map +1 -0
- package/dist/rankBy.js +2 -0
- package/dist/rankBy.js.map +1 -0
- package/dist/reduce.cjs +2 -0
- package/dist/reduce.cjs.map +1 -0
- package/dist/reduce.js +2 -0
- package/dist/reduce.js.map +1 -0
- package/dist/reverse.cjs +2 -0
- package/dist/reverse.cjs.map +1 -0
- package/dist/reverse.js +2 -0
- package/dist/reverse.js.map +1 -0
- package/dist/round.cjs +2 -0
- package/dist/round.cjs.map +1 -0
- package/dist/round.js +2 -0
- package/dist/round.js.map +1 -0
- package/dist/sample.cjs +2 -0
- package/dist/sample.cjs.map +1 -0
- package/dist/sample.js +2 -0
- package/dist/sample.js.map +1 -0
- package/dist/set.cjs +2 -0
- package/dist/set.cjs.map +1 -0
- package/dist/set.js +2 -0
- package/dist/set.js.map +1 -0
- package/dist/setPath.cjs +2 -0
- package/dist/setPath.cjs.map +1 -0
- package/dist/setPath.js +2 -0
- package/dist/setPath.js.map +1 -0
- package/dist/shuffle.cjs +2 -0
- package/dist/shuffle.cjs.map +1 -0
- package/dist/shuffle.js +2 -0
- package/dist/shuffle.js.map +1 -0
- package/dist/sliceString.cjs +2 -0
- package/dist/sliceString.cjs.map +1 -0
- package/dist/sliceString.js +2 -0
- package/dist/sliceString.js.map +1 -0
- package/dist/sort.cjs +2 -0
- package/dist/sort.cjs.map +1 -0
- package/dist/sort.js +2 -0
- package/dist/sort.js.map +1 -0
- package/dist/sortBy.cjs +2 -0
- package/dist/sortBy.cjs.map +1 -0
- package/dist/sortBy.js +2 -0
- package/dist/sortBy.js.map +1 -0
- package/dist/sortedIndex.cjs +2 -0
- package/dist/sortedIndex.cjs.map +1 -0
- package/dist/sortedIndex.js +2 -0
- package/dist/sortedIndex.js.map +1 -0
- package/dist/sortedIndexBy.cjs +2 -0
- package/dist/sortedIndexBy.cjs.map +1 -0
- package/dist/sortedIndexBy.js +2 -0
- package/dist/sortedIndexBy.js.map +1 -0
- package/dist/sortedIndexWith.cjs +2 -0
- package/dist/sortedIndexWith.cjs.map +1 -0
- package/dist/sortedIndexWith.js +2 -0
- package/dist/sortedIndexWith.js.map +1 -0
- package/dist/sortedLastIndex.cjs +2 -0
- package/dist/sortedLastIndex.cjs.map +1 -0
- package/dist/sortedLastIndex.js +2 -0
- package/dist/sortedLastIndex.js.map +1 -0
- package/dist/sortedLastIndexBy.cjs +2 -0
- package/dist/sortedLastIndexBy.cjs.map +1 -0
- package/dist/sortedLastIndexBy.js +2 -0
- package/dist/sortedLastIndexBy.js.map +1 -0
- package/dist/splice.cjs +2 -0
- package/dist/splice.cjs.map +1 -0
- package/dist/splice.js +2 -0
- package/dist/splice.js.map +1 -0
- package/dist/split.cjs +2 -0
- package/dist/split.cjs.map +1 -0
- package/dist/split.js +2 -0
- package/dist/split.js.map +1 -0
- package/dist/splitAt.cjs +2 -0
- package/dist/splitAt.cjs.map +1 -0
- package/dist/splitAt.js +2 -0
- package/dist/splitAt.js.map +1 -0
- package/dist/splitWhen.cjs +2 -0
- package/dist/splitWhen.cjs.map +1 -0
- package/dist/splitWhen.js +2 -0
- package/dist/splitWhen.js.map +1 -0
- package/dist/startsWith.cjs +2 -0
- package/dist/startsWith.cjs.map +1 -0
- package/dist/startsWith.js +2 -0
- package/dist/startsWith.js.map +1 -0
- package/dist/stringToPath.cjs +2 -0
- package/dist/stringToPath.cjs.map +1 -0
- package/dist/stringToPath.js +2 -0
- package/dist/stringToPath.js.map +1 -0
- package/dist/subtract.cjs +2 -0
- package/dist/subtract.cjs.map +1 -0
- package/dist/subtract.js +2 -0
- package/dist/subtract.js.map +1 -0
- package/dist/sum.cjs +2 -0
- package/dist/sum.cjs.map +1 -0
- package/dist/sum.js +2 -0
- package/dist/sum.js.map +1 -0
- package/dist/sumBy.cjs +2 -0
- package/dist/sumBy.cjs.map +1 -0
- package/dist/sumBy.js +2 -0
- package/dist/sumBy.js.map +1 -0
- package/dist/swapInPlace-BrVgf3c3.js +2 -0
- package/dist/swapInPlace-BrVgf3c3.js.map +1 -0
- package/dist/swapInPlace-IOnMIay9.cjs +2 -0
- package/dist/swapInPlace-IOnMIay9.cjs.map +1 -0
- package/dist/swapIndices.cjs +2 -0
- package/dist/swapIndices.cjs.map +1 -0
- package/dist/swapIndices.js +2 -0
- package/dist/swapIndices.js.map +1 -0
- package/dist/swapProps.cjs +2 -0
- package/dist/swapProps.cjs.map +1 -0
- package/dist/swapProps.js +2 -0
- package/dist/swapProps.js.map +1 -0
- package/dist/take.cjs +2 -0
- package/dist/take.cjs.map +1 -0
- package/dist/take.js +2 -0
- package/dist/take.js.map +1 -0
- package/dist/takeFirstBy.cjs +2 -0
- package/dist/takeFirstBy.cjs.map +1 -0
- package/dist/takeFirstBy.js +2 -0
- package/dist/takeFirstBy.js.map +1 -0
- package/dist/takeLast.cjs +2 -0
- package/dist/takeLast.cjs.map +1 -0
- package/dist/takeLast.js +2 -0
- package/dist/takeLast.js.map +1 -0
- package/dist/takeLastWhile.cjs +2 -0
- package/dist/takeLastWhile.cjs.map +1 -0
- package/dist/takeLastWhile.js +2 -0
- package/dist/takeLastWhile.js.map +1 -0
- package/dist/takeWhile.cjs +2 -0
- package/dist/takeWhile.cjs.map +1 -0
- package/dist/takeWhile.js +2 -0
- package/dist/takeWhile.js.map +1 -0
- package/dist/tap.cjs +2 -0
- package/dist/tap.cjs.map +1 -0
- package/dist/tap.js +2 -0
- package/dist/tap.js.map +1 -0
- package/dist/times.cjs +2 -0
- package/dist/times.cjs.map +1 -0
- package/dist/times.js +2 -0
- package/dist/times.js.map +1 -0
- package/dist/toCamelCase.cjs +2 -0
- package/dist/toCamelCase.cjs.map +1 -0
- package/dist/toCamelCase.js +2 -0
- package/dist/toCamelCase.js.map +1 -0
- package/dist/toKebabCase.cjs +2 -0
- package/dist/toKebabCase.cjs.map +1 -0
- package/dist/toKebabCase.js +2 -0
- package/dist/toKebabCase.js.map +1 -0
- package/dist/toLowerCase.cjs +2 -0
- package/dist/toLowerCase.cjs.map +1 -0
- package/dist/toLowerCase.js +2 -0
- package/dist/toLowerCase.js.map +1 -0
- package/dist/toSingle-qs9PC5sP.js +2 -0
- package/dist/toSingle-qs9PC5sP.js.map +1 -0
- package/dist/toSingle-z9yHVHGr.cjs +2 -0
- package/dist/toSingle-z9yHVHGr.cjs.map +1 -0
- package/dist/toSnakeCase.cjs +2 -0
- package/dist/toSnakeCase.cjs.map +1 -0
- package/dist/toSnakeCase.js +2 -0
- package/dist/toSnakeCase.js.map +1 -0
- package/dist/toTitleCase.cjs +2 -0
- package/dist/toTitleCase.cjs.map +1 -0
- package/dist/toTitleCase.js +2 -0
- package/dist/toTitleCase.js.map +1 -0
- package/dist/toUpperCase.cjs +2 -0
- package/dist/toUpperCase.cjs.map +1 -0
- package/dist/toUpperCase.js +2 -0
- package/dist/toUpperCase.js.map +1 -0
- package/dist/truncate.cjs +2 -0
- package/dist/truncate.cjs.map +1 -0
- package/dist/truncate.js +2 -0
- package/dist/truncate.js.map +1 -0
- package/dist/uncapitalize.cjs +2 -0
- package/dist/uncapitalize.cjs.map +1 -0
- package/dist/uncapitalize.js +2 -0
- package/dist/uncapitalize.js.map +1 -0
- package/dist/unique.cjs +2 -0
- package/dist/unique.cjs.map +1 -0
- package/dist/unique.js +2 -0
- package/dist/unique.js.map +1 -0
- package/dist/uniqueBy.cjs +2 -0
- package/dist/uniqueBy.cjs.map +1 -0
- package/dist/uniqueBy.js +2 -0
- package/dist/uniqueBy.js.map +1 -0
- package/dist/uniqueWith.cjs +2 -0
- package/dist/uniqueWith.cjs.map +1 -0
- package/dist/uniqueWith.js +2 -0
- package/dist/uniqueWith.js.map +1 -0
- package/dist/utilityEvaluators-BQqW5Ir5.js +2 -0
- package/dist/utilityEvaluators-BQqW5Ir5.js.map +1 -0
- package/dist/utilityEvaluators-CW0M8vMV.cjs +2 -0
- package/dist/utilityEvaluators-CW0M8vMV.cjs.map +1 -0
- package/dist/values.cjs +2 -0
- package/dist/values.cjs.map +1 -0
- package/dist/values.js +2 -0
- package/dist/values.js.map +1 -0
- package/dist/when.cjs +2 -0
- package/dist/when.cjs.map +1 -0
- package/dist/when.js +2 -0
- package/dist/when.js.map +1 -0
- package/dist/withPrecision-CDZ-Oor7.js +2 -0
- package/dist/withPrecision-CDZ-Oor7.js.map +1 -0
- package/dist/withPrecision-DED4FjDo.cjs +2 -0
- package/dist/withPrecision-DED4FjDo.cjs.map +1 -0
- package/dist/words-CDCUnuNz.cjs +3 -0
- package/dist/words-CDCUnuNz.cjs.map +1 -0
- package/dist/words-Dv8LmnKC.js +3 -0
- package/dist/words-Dv8LmnKC.js.map +1 -0
- package/dist/zip.cjs +2 -0
- package/dist/zip.cjs.map +1 -0
- package/dist/zip.js +2 -0
- package/dist/zip.js.map +1 -0
- package/dist/zipWith.cjs +2 -0
- package/dist/zipWith.cjs.map +1 -0
- package/dist/zipWith.js +2 -0
- package/dist/zipWith.js.map +1 -0
- package/package.json +104 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.cjs","names":[],"sources":["../src/debounce.ts"],"sourcesContent":["import type { StrictFunction } from \"./internal/types/StrictFunction\";\n\ntype Debouncer<F extends StrictFunction, IsNullable extends boolean = true> = {\n /**\n * Invoke the debounced function.\n *\n * @param args - Same as the args for the debounced function.\n * @returns The last computed value of the debounced function with the\n * latest args provided to it. If `timing` does not include `leading` then the\n * the function would return `undefined` until the first cool-down period is\n * over, otherwise the function would always return the return type of the\n * debounced function.\n */\n readonly call: (\n ...args: Parameters<F>\n ) => ReturnType<F> | (true extends IsNullable ? undefined : never);\n\n /**\n * Cancels any debounced functions without calling them, effectively resetting\n * the debouncer to the same state it is when initially created.\n */\n readonly cancel: () => void;\n\n /**\n * Similar to `cancel`, but would also trigger the `trailing` invocation if\n * the debouncer would run one at the end of the cool-down period.\n */\n readonly flush: () => ReturnType<F> | undefined;\n\n /**\n * Is `true` when there is an active cool-down period currently debouncing\n * invocations.\n */\n readonly isPending: boolean;\n\n /**\n * The last computed value of the debounced function.\n */\n readonly cachedValue: ReturnType<F> | undefined;\n};\n\ntype DebounceOptions = {\n readonly waitMs?: number;\n readonly maxWaitMs?: number;\n};\n\n/**\n * Wraps `func` with a debouncer object that \"debounces\" (delays) invocations of the function during a defined cool-down period (`waitMs`). It can be configured to invoke the function either at the start of the cool-down period, the end of it, or at both ends (`timing`).\n * It can also be configured to allow invocations during the cool-down period (`maxWaitMs`).\n * It stores the latest call's arguments so they could be used at the end of the cool-down period when invoking `func` (if configured to invoke the function at the end of the cool-down period).\n * It stores the value returned by `func` whenever its invoked. This value is returned on every call, and is accessible via the `cachedValue` property of the debouncer. Its important to note that the value might be different from the value that would be returned from running `func` with the current arguments as it is a cached value from a previous invocation.\n * **Important**: The cool-down period defines the minimum between two invocations, and not the maximum. The period will be **extended** each time a call is made until a full cool-down period has elapsed without any additional calls.\n *\n *! **DEPRECATED**: This implementation of debounce is known to have issues and might not behave as expected. It should be replaced with the `funnel` utility instead. The test file [funnel.remeda-debounce.test.ts](https://github.com/remeda/remeda/blob/main/packages/remeda/src/funnel.remeda-debounce.test.ts) offers a reference implementation that replicates `debounce` via `funnel`!\n *\n * @param func - The function to debounce, the returned `call` function will have\n * the exact same signature.\n * @param options - An object allowing further customization of the debouncer:\n * - `timing?: 'leading' | 'trailing' |'both'`. The default is `'trailing'`.\n * `leading` would result in the function being invoked at the start of the\n * cool-down period; `trailing` would result in the function being invoked at\n * the end of the cool-down period (using the args from the last call to the\n * debouncer). When `both` is selected the `trailing` invocation would only\n * take place if there were more than one call to the debouncer during the\n * cool-down period. **DEFAULT: 'trailing'**\n * - `waitMs?: number`. The length of the cool-down period in milliseconds. The\n * debouncer would wait until this amount of time has passed without **any**\n * additional calls to the debouncer before triggering the end-of-cool-down-\n * period event. When this happens, the function would be invoked (if `timing`\n * isn't `'leading'`) and the debouncer state would be reset. **DEFAULT: 0**\n * - `maxWaitMs?: number`. The length of time since a debounced call (a call\n * that the debouncer prevented from being invoked) was made until it would be\n * invoked. Because the debouncer can be continually triggered and thus never\n * reach the end of the cool-down period, this allows the function to still\n * be invoked occasionally. IMPORTANT: This param is ignored when `timing` is\n * `'leading'`.\n * @returns A debouncer object. The main function is `call`. In addition to it\n * the debouncer comes with the following additional functions and properties:\n * - `cancel` method to cancel delayed `func` invocations\n * - `flush` method to end the cool-down period immediately.\n * - `cachedValue` the latest return value of an invocation (if one occurred).\n * - `isPending` flag to check if there is an inflight cool-down window.\n * @signature\n * debounce(func, options);\n * @example\n * const debouncer = debounce(identity(), { timing: 'trailing', waitMs: 1000 });\n * const result1 = debouncer.call(1); // => undefined\n * const result2 = debouncer.call(2); // => undefined\n * // after 1 second\n * const result3 = debouncer.call(3); // => 2\n * // after 1 second\n * debouncer.cachedValue; // => 3\n * @dataFirst\n * @category Function\n * @deprecated This implementation of debounce is known to have issues and might\n * not behave as expected. It should be replaced with the `funnel` utility\n * instead. The test file `funnel.remeda-debounce.test.ts` offers a reference\n * implementation that replicates `debounce` via `funnel`.\n * @see https://css-tricks.com/debouncing-throttling-explained-examples/\n */\nexport function debounce<F extends StrictFunction>(\n func: F,\n options: DebounceOptions & { readonly timing?: \"trailing\" },\n): Debouncer<F>;\nexport function debounce<F extends StrictFunction>(\n func: F,\n options:\n | (DebounceOptions & { readonly timing: \"both\" })\n | (Omit<DebounceOptions, \"maxWaitMs\"> & { readonly timing: \"leading\" }),\n): Debouncer<F, false /* call CAN'T return null */>;\n\nexport function debounce<F extends StrictFunction>(\n func: F,\n {\n waitMs,\n timing = \"trailing\",\n maxWaitMs,\n }: DebounceOptions & {\n readonly timing?: \"both\" | \"leading\" | \"trailing\";\n },\n): Debouncer<F> {\n if (maxWaitMs !== undefined && waitMs !== undefined && maxWaitMs < waitMs) {\n throw new Error(\n `debounce: maxWaitMs (${maxWaitMs.toString()}) cannot be less than waitMs (${waitMs.toString()})`,\n );\n }\n\n // All these are part of the debouncer runtime state:\n\n // The timeout is the main object we use to tell if there's an active cool-\n // down period or not.\n let coolDownTimeoutId: ReturnType<typeof setTimeout> | undefined;\n\n // We use an additional timeout to track how long the last debounced call is\n // waiting.\n let maxWaitTimeoutId: ReturnType<typeof setTimeout> | undefined;\n\n // For 'trailing' invocations we need to keep the args around until we\n // actually invoke the function.\n let latestCallArgs: Parameters<F> | undefined;\n\n // To make any value of the debounced function we need to be able to return a\n // value. For any invocation except the first one when 'leading' is enabled we\n // will return this cached value.\n let result: ReturnType<F> | undefined;\n\n const handleInvoke = (): void => {\n if (maxWaitTimeoutId !== undefined) {\n // We are invoking the function so the wait is over...\n const timeoutId = maxWaitTimeoutId;\n maxWaitTimeoutId = undefined;\n clearTimeout(timeoutId);\n }\n\n /* v8 ignore if -- This protects us against changes to the logic, there is no known flow we can simulate to reach this condition. It can only happen if a previous timeout isn't cleared (or faces a race condition clearing). @preserve */\n if (latestCallArgs === undefined) {\n // If you see this error pop up when using this function please report\n // it on the Remeda github page!\n throw new Error(\n \"REMEDA[debounce]: latestCallArgs was unexpectedly undefined.\",\n );\n }\n\n const args = latestCallArgs;\n // Make sure the args aren't accidentally used again, this is mainly\n // relevant for the check above where we'll fail a subsequent call to\n // 'trailingEdge'.\n latestCallArgs = undefined;\n\n // Invoke the function and store the results locally.\n // @ts-expect-error [ts2345, ts2322] -- TypeScript infers the generic sub-\n // types too eagerly, making itself blind to the fact that the types match\n // here.\n result = func(...args);\n };\n\n const handleCoolDownEnd = (): void => {\n if (coolDownTimeoutId === undefined) {\n // It's rare to get here, it should only happen when `flush` is called\n // when the cool-down window isn't active.\n return;\n }\n\n // Make sure there are no more timers running.\n const timeoutId = coolDownTimeoutId;\n coolDownTimeoutId = undefined;\n clearTimeout(timeoutId);\n // Then reset state so a new cool-down window can begin on the next call.\n\n if (latestCallArgs !== undefined) {\n // If we have a debounced call waiting to be invoked at the end of the\n // cool-down period we need to invoke it now.\n handleInvoke();\n }\n };\n\n const handleDebouncedCall = (args: Parameters<F>): void => {\n // We save the latest call args so that (if and) when we invoke the function\n // in the future, we have args to invoke it with.\n latestCallArgs = args;\n\n if (maxWaitMs !== undefined && maxWaitTimeoutId === undefined) {\n // We only need to start the maxWait timeout once, on the first debounced\n // call that is now being delayed.\n maxWaitTimeoutId = setTimeout(handleInvoke, maxWaitMs);\n }\n };\n\n return {\n call: (...args) => {\n if (coolDownTimeoutId === undefined) {\n // This call is starting a new cool-down window!\n\n if (timing === \"trailing\") {\n // Only when the timing is \"trailing\" is the first call \"debounced\".\n handleDebouncedCall(args);\n } else {\n // Otherwise for \"leading\" and \"both\" the first call is actually\n // called directly and not via a timeout.\n // @ts-expect-error [ts2345, ts2322] -- TypeScript infers the generic\n // sub-types too eagerly, making itself blind to the fact that the\n // types match here.\n result = func(...args);\n }\n } else {\n // There's an inflight cool-down window.\n\n if (timing !== \"leading\") {\n // When the timing is 'leading' all following calls are just ignored\n // until the cool-down period ends. But for the other timings the call\n // is \"debounced\".\n handleDebouncedCall(args);\n }\n\n // The current timeout is no longer relevant because we need to wait the\n // full `waitMs` time from this call.\n const timeoutId = coolDownTimeoutId;\n coolDownTimeoutId = undefined;\n clearTimeout(timeoutId);\n }\n\n coolDownTimeoutId = setTimeout(\n handleCoolDownEnd,\n // If waitMs is not defined but maxWaitMs *is* it means the user is only\n // interested in the leaky-bucket nature of the debouncer which is\n // achieved by setting waitMs === maxWaitMs. If both are not defined we\n // default to 0 which would wait until the end of the execution frame.\n waitMs ?? maxWaitMs ?? 0,\n );\n\n // Return the last computed result while we \"debounce\" further calls.\n return result;\n },\n\n cancel: () => {\n // Reset all \"in-flight\" state of the debouncer. Notice that we keep the\n // cached value!\n\n if (coolDownTimeoutId !== undefined) {\n const timeoutId = coolDownTimeoutId;\n coolDownTimeoutId = undefined;\n clearTimeout(timeoutId);\n }\n\n if (maxWaitTimeoutId !== undefined) {\n const timeoutId = maxWaitTimeoutId;\n maxWaitTimeoutId = undefined;\n clearTimeout(timeoutId);\n }\n\n latestCallArgs = undefined;\n },\n\n flush: () => {\n // Flush is just a manual way to trigger the end of the cool-down window.\n handleCoolDownEnd();\n return result;\n },\n\n get isPending() {\n return coolDownTimeoutId !== undefined;\n },\n\n get cachedValue() {\n return result;\n },\n };\n}\n"],"mappings":"mEA+GA,SAAgB,EACd,EACA,CACE,SACA,SAAS,WACT,aAIY,CACd,GAAI,IAAc,IAAA,IAAa,IAAW,IAAA,IAAa,EAAY,EACjE,MAAU,MACR,wBAAwB,EAAU,UAAU,CAAC,gCAAgC,EAAO,UAAU,CAAC,GAChG,CAOH,IAAI,EAIA,EAIA,EAKA,EAEE,MAA2B,CAC/B,GAAI,IAAqB,IAAA,GAAW,CAElC,IAAM,EAAY,EAClB,EAAmB,IAAA,GACnB,aAAa,EAAU,CAIzB,GAAI,IAAmB,IAAA,GAGrB,MAAU,MACR,+DACD,CAGH,IAAM,EAAO,EAIb,EAAiB,IAAA,GAMjB,EAAS,EAAK,GAAG,EAAK,EAGlB,MAAgC,CACpC,GAAI,IAAsB,IAAA,GAGxB,OAIF,IAAM,EAAY,EAClB,EAAoB,IAAA,GACpB,aAAa,EAAU,CAGnB,IAAmB,IAAA,IAGrB,GAAc,EAIZ,EAAuB,GAA8B,CAGzD,EAAiB,EAEb,IAAc,IAAA,IAAa,IAAqB,IAAA,KAGlD,EAAmB,WAAW,EAAc,EAAU,GAI1D,MAAO,CACL,MAAO,GAAG,IAAS,CACjB,GAAI,IAAsB,IAAA,GAGpB,IAAW,WAEb,EAAoB,EAAK,CAOzB,EAAS,EAAK,GAAG,EAAK,KAEnB,CAGD,IAAW,WAIb,EAAoB,EAAK,CAK3B,IAAM,EAAY,EAClB,EAAoB,IAAA,GACpB,aAAa,EAAU,CAazB,MAVA,GAAoB,WAClB,EAKA,GAAU,GAAa,EACxB,CAGM,GAGT,WAAc,CAIZ,GAAI,IAAsB,IAAA,GAAW,CACnC,IAAM,EAAY,EAClB,EAAoB,IAAA,GACpB,aAAa,EAAU,CAGzB,GAAI,IAAqB,IAAA,GAAW,CAClC,IAAM,EAAY,EAClB,EAAmB,IAAA,GACnB,aAAa,EAAU,CAGzB,EAAiB,IAAA,IAGnB,WAEE,GAAmB,CACZ,GAGT,IAAI,WAAY,CACd,OAAO,IAAsB,IAAA,IAG/B,IAAI,aAAc,CAChB,OAAO,GAEV"}
|
package/dist/debounce.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e,{waitMs:t,timing:n=`trailing`,maxWaitMs:r}){if(r!==void 0&&t!==void 0&&r<t)throw Error(`debounce: maxWaitMs (${r.toString()}) cannot be less than waitMs (${t.toString()})`);let i,a,o,s,c=()=>{if(a!==void 0){let e=a;a=void 0,clearTimeout(e)}if(o===void 0)throw Error(`REMEDA[debounce]: latestCallArgs was unexpectedly undefined.`);let t=o;o=void 0,s=e(...t)},l=()=>{if(i===void 0)return;let e=i;i=void 0,clearTimeout(e),o!==void 0&&c()},u=e=>{o=e,r!==void 0&&a===void 0&&(a=setTimeout(c,r))};return{call:(...a)=>{if(i===void 0)n===`trailing`?u(a):s=e(...a);else{n!==`leading`&&u(a);let e=i;i=void 0,clearTimeout(e)}return i=setTimeout(l,t??r??0),s},cancel:()=>{if(i!==void 0){let e=i;i=void 0,clearTimeout(e)}if(a!==void 0){let e=a;a=void 0,clearTimeout(e)}o=void 0},flush:()=>(l(),s),get isPending(){return i!==void 0},get cachedValue(){return s}}}export{e as debounce};
|
|
2
|
+
//# sourceMappingURL=debounce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.js","names":[],"sources":["../src/debounce.ts"],"sourcesContent":["import type { StrictFunction } from \"./internal/types/StrictFunction\";\n\ntype Debouncer<F extends StrictFunction, IsNullable extends boolean = true> = {\n /**\n * Invoke the debounced function.\n *\n * @param args - Same as the args for the debounced function.\n * @returns The last computed value of the debounced function with the\n * latest args provided to it. If `timing` does not include `leading` then the\n * the function would return `undefined` until the first cool-down period is\n * over, otherwise the function would always return the return type of the\n * debounced function.\n */\n readonly call: (\n ...args: Parameters<F>\n ) => ReturnType<F> | (true extends IsNullable ? undefined : never);\n\n /**\n * Cancels any debounced functions without calling them, effectively resetting\n * the debouncer to the same state it is when initially created.\n */\n readonly cancel: () => void;\n\n /**\n * Similar to `cancel`, but would also trigger the `trailing` invocation if\n * the debouncer would run one at the end of the cool-down period.\n */\n readonly flush: () => ReturnType<F> | undefined;\n\n /**\n * Is `true` when there is an active cool-down period currently debouncing\n * invocations.\n */\n readonly isPending: boolean;\n\n /**\n * The last computed value of the debounced function.\n */\n readonly cachedValue: ReturnType<F> | undefined;\n};\n\ntype DebounceOptions = {\n readonly waitMs?: number;\n readonly maxWaitMs?: number;\n};\n\n/**\n * Wraps `func` with a debouncer object that \"debounces\" (delays) invocations of the function during a defined cool-down period (`waitMs`). It can be configured to invoke the function either at the start of the cool-down period, the end of it, or at both ends (`timing`).\n * It can also be configured to allow invocations during the cool-down period (`maxWaitMs`).\n * It stores the latest call's arguments so they could be used at the end of the cool-down period when invoking `func` (if configured to invoke the function at the end of the cool-down period).\n * It stores the value returned by `func` whenever its invoked. This value is returned on every call, and is accessible via the `cachedValue` property of the debouncer. Its important to note that the value might be different from the value that would be returned from running `func` with the current arguments as it is a cached value from a previous invocation.\n * **Important**: The cool-down period defines the minimum between two invocations, and not the maximum. The period will be **extended** each time a call is made until a full cool-down period has elapsed without any additional calls.\n *\n *! **DEPRECATED**: This implementation of debounce is known to have issues and might not behave as expected. It should be replaced with the `funnel` utility instead. The test file [funnel.remeda-debounce.test.ts](https://github.com/remeda/remeda/blob/main/packages/remeda/src/funnel.remeda-debounce.test.ts) offers a reference implementation that replicates `debounce` via `funnel`!\n *\n * @param func - The function to debounce, the returned `call` function will have\n * the exact same signature.\n * @param options - An object allowing further customization of the debouncer:\n * - `timing?: 'leading' | 'trailing' |'both'`. The default is `'trailing'`.\n * `leading` would result in the function being invoked at the start of the\n * cool-down period; `trailing` would result in the function being invoked at\n * the end of the cool-down period (using the args from the last call to the\n * debouncer). When `both` is selected the `trailing` invocation would only\n * take place if there were more than one call to the debouncer during the\n * cool-down period. **DEFAULT: 'trailing'**\n * - `waitMs?: number`. The length of the cool-down period in milliseconds. The\n * debouncer would wait until this amount of time has passed without **any**\n * additional calls to the debouncer before triggering the end-of-cool-down-\n * period event. When this happens, the function would be invoked (if `timing`\n * isn't `'leading'`) and the debouncer state would be reset. **DEFAULT: 0**\n * - `maxWaitMs?: number`. The length of time since a debounced call (a call\n * that the debouncer prevented from being invoked) was made until it would be\n * invoked. Because the debouncer can be continually triggered and thus never\n * reach the end of the cool-down period, this allows the function to still\n * be invoked occasionally. IMPORTANT: This param is ignored when `timing` is\n * `'leading'`.\n * @returns A debouncer object. The main function is `call`. In addition to it\n * the debouncer comes with the following additional functions and properties:\n * - `cancel` method to cancel delayed `func` invocations\n * - `flush` method to end the cool-down period immediately.\n * - `cachedValue` the latest return value of an invocation (if one occurred).\n * - `isPending` flag to check if there is an inflight cool-down window.\n * @signature\n * debounce(func, options);\n * @example\n * const debouncer = debounce(identity(), { timing: 'trailing', waitMs: 1000 });\n * const result1 = debouncer.call(1); // => undefined\n * const result2 = debouncer.call(2); // => undefined\n * // after 1 second\n * const result3 = debouncer.call(3); // => 2\n * // after 1 second\n * debouncer.cachedValue; // => 3\n * @dataFirst\n * @category Function\n * @deprecated This implementation of debounce is known to have issues and might\n * not behave as expected. It should be replaced with the `funnel` utility\n * instead. The test file `funnel.remeda-debounce.test.ts` offers a reference\n * implementation that replicates `debounce` via `funnel`.\n * @see https://css-tricks.com/debouncing-throttling-explained-examples/\n */\nexport function debounce<F extends StrictFunction>(\n func: F,\n options: DebounceOptions & { readonly timing?: \"trailing\" },\n): Debouncer<F>;\nexport function debounce<F extends StrictFunction>(\n func: F,\n options:\n | (DebounceOptions & { readonly timing: \"both\" })\n | (Omit<DebounceOptions, \"maxWaitMs\"> & { readonly timing: \"leading\" }),\n): Debouncer<F, false /* call CAN'T return null */>;\n\nexport function debounce<F extends StrictFunction>(\n func: F,\n {\n waitMs,\n timing = \"trailing\",\n maxWaitMs,\n }: DebounceOptions & {\n readonly timing?: \"both\" | \"leading\" | \"trailing\";\n },\n): Debouncer<F> {\n if (maxWaitMs !== undefined && waitMs !== undefined && maxWaitMs < waitMs) {\n throw new Error(\n `debounce: maxWaitMs (${maxWaitMs.toString()}) cannot be less than waitMs (${waitMs.toString()})`,\n );\n }\n\n // All these are part of the debouncer runtime state:\n\n // The timeout is the main object we use to tell if there's an active cool-\n // down period or not.\n let coolDownTimeoutId: ReturnType<typeof setTimeout> | undefined;\n\n // We use an additional timeout to track how long the last debounced call is\n // waiting.\n let maxWaitTimeoutId: ReturnType<typeof setTimeout> | undefined;\n\n // For 'trailing' invocations we need to keep the args around until we\n // actually invoke the function.\n let latestCallArgs: Parameters<F> | undefined;\n\n // To make any value of the debounced function we need to be able to return a\n // value. For any invocation except the first one when 'leading' is enabled we\n // will return this cached value.\n let result: ReturnType<F> | undefined;\n\n const handleInvoke = (): void => {\n if (maxWaitTimeoutId !== undefined) {\n // We are invoking the function so the wait is over...\n const timeoutId = maxWaitTimeoutId;\n maxWaitTimeoutId = undefined;\n clearTimeout(timeoutId);\n }\n\n /* v8 ignore if -- This protects us against changes to the logic, there is no known flow we can simulate to reach this condition. It can only happen if a previous timeout isn't cleared (or faces a race condition clearing). @preserve */\n if (latestCallArgs === undefined) {\n // If you see this error pop up when using this function please report\n // it on the Remeda github page!\n throw new Error(\n \"REMEDA[debounce]: latestCallArgs was unexpectedly undefined.\",\n );\n }\n\n const args = latestCallArgs;\n // Make sure the args aren't accidentally used again, this is mainly\n // relevant for the check above where we'll fail a subsequent call to\n // 'trailingEdge'.\n latestCallArgs = undefined;\n\n // Invoke the function and store the results locally.\n // @ts-expect-error [ts2345, ts2322] -- TypeScript infers the generic sub-\n // types too eagerly, making itself blind to the fact that the types match\n // here.\n result = func(...args);\n };\n\n const handleCoolDownEnd = (): void => {\n if (coolDownTimeoutId === undefined) {\n // It's rare to get here, it should only happen when `flush` is called\n // when the cool-down window isn't active.\n return;\n }\n\n // Make sure there are no more timers running.\n const timeoutId = coolDownTimeoutId;\n coolDownTimeoutId = undefined;\n clearTimeout(timeoutId);\n // Then reset state so a new cool-down window can begin on the next call.\n\n if (latestCallArgs !== undefined) {\n // If we have a debounced call waiting to be invoked at the end of the\n // cool-down period we need to invoke it now.\n handleInvoke();\n }\n };\n\n const handleDebouncedCall = (args: Parameters<F>): void => {\n // We save the latest call args so that (if and) when we invoke the function\n // in the future, we have args to invoke it with.\n latestCallArgs = args;\n\n if (maxWaitMs !== undefined && maxWaitTimeoutId === undefined) {\n // We only need to start the maxWait timeout once, on the first debounced\n // call that is now being delayed.\n maxWaitTimeoutId = setTimeout(handleInvoke, maxWaitMs);\n }\n };\n\n return {\n call: (...args) => {\n if (coolDownTimeoutId === undefined) {\n // This call is starting a new cool-down window!\n\n if (timing === \"trailing\") {\n // Only when the timing is \"trailing\" is the first call \"debounced\".\n handleDebouncedCall(args);\n } else {\n // Otherwise for \"leading\" and \"both\" the first call is actually\n // called directly and not via a timeout.\n // @ts-expect-error [ts2345, ts2322] -- TypeScript infers the generic\n // sub-types too eagerly, making itself blind to the fact that the\n // types match here.\n result = func(...args);\n }\n } else {\n // There's an inflight cool-down window.\n\n if (timing !== \"leading\") {\n // When the timing is 'leading' all following calls are just ignored\n // until the cool-down period ends. But for the other timings the call\n // is \"debounced\".\n handleDebouncedCall(args);\n }\n\n // The current timeout is no longer relevant because we need to wait the\n // full `waitMs` time from this call.\n const timeoutId = coolDownTimeoutId;\n coolDownTimeoutId = undefined;\n clearTimeout(timeoutId);\n }\n\n coolDownTimeoutId = setTimeout(\n handleCoolDownEnd,\n // If waitMs is not defined but maxWaitMs *is* it means the user is only\n // interested in the leaky-bucket nature of the debouncer which is\n // achieved by setting waitMs === maxWaitMs. If both are not defined we\n // default to 0 which would wait until the end of the execution frame.\n waitMs ?? maxWaitMs ?? 0,\n );\n\n // Return the last computed result while we \"debounce\" further calls.\n return result;\n },\n\n cancel: () => {\n // Reset all \"in-flight\" state of the debouncer. Notice that we keep the\n // cached value!\n\n if (coolDownTimeoutId !== undefined) {\n const timeoutId = coolDownTimeoutId;\n coolDownTimeoutId = undefined;\n clearTimeout(timeoutId);\n }\n\n if (maxWaitTimeoutId !== undefined) {\n const timeoutId = maxWaitTimeoutId;\n maxWaitTimeoutId = undefined;\n clearTimeout(timeoutId);\n }\n\n latestCallArgs = undefined;\n },\n\n flush: () => {\n // Flush is just a manual way to trigger the end of the cool-down window.\n handleCoolDownEnd();\n return result;\n },\n\n get isPending() {\n return coolDownTimeoutId !== undefined;\n },\n\n get cachedValue() {\n return result;\n },\n };\n}\n"],"mappings":"AA+GA,SAAgB,EACd,EACA,CACE,SACA,SAAS,WACT,aAIY,CACd,GAAI,IAAc,IAAA,IAAa,IAAW,IAAA,IAAa,EAAY,EACjE,MAAU,MACR,wBAAwB,EAAU,UAAU,CAAC,gCAAgC,EAAO,UAAU,CAAC,GAChG,CAOH,IAAI,EAIA,EAIA,EAKA,EAEE,MAA2B,CAC/B,GAAI,IAAqB,IAAA,GAAW,CAElC,IAAM,EAAY,EAClB,EAAmB,IAAA,GACnB,aAAa,EAAU,CAIzB,GAAI,IAAmB,IAAA,GAGrB,MAAU,MACR,+DACD,CAGH,IAAM,EAAO,EAIb,EAAiB,IAAA,GAMjB,EAAS,EAAK,GAAG,EAAK,EAGlB,MAAgC,CACpC,GAAI,IAAsB,IAAA,GAGxB,OAIF,IAAM,EAAY,EAClB,EAAoB,IAAA,GACpB,aAAa,EAAU,CAGnB,IAAmB,IAAA,IAGrB,GAAc,EAIZ,EAAuB,GAA8B,CAGzD,EAAiB,EAEb,IAAc,IAAA,IAAa,IAAqB,IAAA,KAGlD,EAAmB,WAAW,EAAc,EAAU,GAI1D,MAAO,CACL,MAAO,GAAG,IAAS,CACjB,GAAI,IAAsB,IAAA,GAGpB,IAAW,WAEb,EAAoB,EAAK,CAOzB,EAAS,EAAK,GAAG,EAAK,KAEnB,CAGD,IAAW,WAIb,EAAoB,EAAK,CAK3B,IAAM,EAAY,EAClB,EAAoB,IAAA,GACpB,aAAa,EAAU,CAazB,MAVA,GAAoB,WAClB,EAKA,GAAU,GAAa,EACxB,CAGM,GAGT,WAAc,CAIZ,GAAI,IAAsB,IAAA,GAAW,CACnC,IAAM,EAAY,EAClB,EAAoB,IAAA,GACpB,aAAa,EAAU,CAGzB,GAAI,IAAqB,IAAA,GAAW,CAClC,IAAM,EAAY,EAClB,EAAmB,IAAA,GACnB,aAAa,EAAU,CAGzB,EAAiB,IAAA,IAGnB,WAEE,GAAmB,CACZ,GAGT,IAAI,WAAY,CACd,OAAO,IAAsB,IAAA,IAG/B,IAAI,aAAc,CAChB,OAAO,GAEV"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultTo.cjs","names":["purry"],"sources":["../src/defaultTo.ts"],"sourcesContent":["import type { IsEqual } from \"type-fest\";\nimport { purry } from \"./purry\";\nimport type { RemedaTypeError } from \"./internal/types/RemedaTypeError\";\n\ntype FallbackOf<T> =\n IsEqual<T, NonNullable<T>> extends true\n ? RemedaTypeError<\n \"defaultTo\",\n \"no unnecessary fallback\",\n // The type is `never` because it will never be used ;)\n { type: never; metadata: T }\n >\n : T;\n\n/**\n * A stricter wrapper around the [Nullish coalescing operator `??`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator)\n * that ensures that the fallback matches the type of the data. Only works\n * when data can be `null` or `undefined`.\n *\n * Notice that `Number.NaN` is not nullish and would not result in returning the\n * fallback!\n *\n * @param data - A nullish value.\n * @param fallback - A value of the same type as `data` that would be returned\n * when `data` is nullish.\n * @signature\n * defaultTo(data, fallback);\n * @example\n * defaultTo(\"hello\" as string | undefined, \"world\"); //=> \"hello\"\n * defaultTo(undefined as string | undefined, \"world\"); //=> \"world\"\n * @dataFirst\n * @category Other\n */\nexport function defaultTo<T, const Fallback extends FallbackOf<T>>(\n data: T,\n fallback: Fallback,\n): NonNullable<T> | Fallback;\n\n/**\n * A stricter wrapper around the [Nullish coalescing operator `??`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator)\n * that ensures that the fallback matches the type of the data, and that the\n * data is nullish (`null` or `undefined`).\n *\n * Notice that `Number.NaN` is not nullish and would not result in returning the\n * fallback!\n *\n * @param fallback - A value of the same type as `data` that would be returned\n * when `data` is nullish.\n * @signature\n * defaultTo(fallback)(data);\n * @example\n * pipe(\"hello\" as string | undefined, defaultTo(\"world\")); //=> \"hello\"\n * pipe(undefined as string | undefined, defaultTo(\"world\")); //=> \"world\"\n * @dataLast\n * @category Other\n */\nexport function defaultTo<T, const Fallback extends FallbackOf<T>>(\n fallback: Fallback,\n): (data: T) => NonNullable<T> | Fallback;\n\nexport function defaultTo(...args: readonly unknown[]): unknown {\n return purry(defaultToImplementation, args);\n}\n\nconst defaultToImplementation = <T, Fallback extends FallbackOf<T>>(\n data: T,\n fallback: Fallback,\n): NonNullable<T> | Fallback => data ?? fallback;\n"],"mappings":"kGA4DA,SAAgB,EAAU,GAAG,EAAmC,CAC9D,OAAOA,EAAAA,MAAM,EAAyB,EAAK,CAG7C,MAAM,GACJ,EACA,IAC8B,GAAQ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultTo.js","names":[],"sources":["../src/defaultTo.ts"],"sourcesContent":["import type { IsEqual } from \"type-fest\";\nimport { purry } from \"./purry\";\nimport type { RemedaTypeError } from \"./internal/types/RemedaTypeError\";\n\ntype FallbackOf<T> =\n IsEqual<T, NonNullable<T>> extends true\n ? RemedaTypeError<\n \"defaultTo\",\n \"no unnecessary fallback\",\n // The type is `never` because it will never be used ;)\n { type: never; metadata: T }\n >\n : T;\n\n/**\n * A stricter wrapper around the [Nullish coalescing operator `??`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator)\n * that ensures that the fallback matches the type of the data. Only works\n * when data can be `null` or `undefined`.\n *\n * Notice that `Number.NaN` is not nullish and would not result in returning the\n * fallback!\n *\n * @param data - A nullish value.\n * @param fallback - A value of the same type as `data` that would be returned\n * when `data` is nullish.\n * @signature\n * defaultTo(data, fallback);\n * @example\n * defaultTo(\"hello\" as string | undefined, \"world\"); //=> \"hello\"\n * defaultTo(undefined as string | undefined, \"world\"); //=> \"world\"\n * @dataFirst\n * @category Other\n */\nexport function defaultTo<T, const Fallback extends FallbackOf<T>>(\n data: T,\n fallback: Fallback,\n): NonNullable<T> | Fallback;\n\n/**\n * A stricter wrapper around the [Nullish coalescing operator `??`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator)\n * that ensures that the fallback matches the type of the data, and that the\n * data is nullish (`null` or `undefined`).\n *\n * Notice that `Number.NaN` is not nullish and would not result in returning the\n * fallback!\n *\n * @param fallback - A value of the same type as `data` that would be returned\n * when `data` is nullish.\n * @signature\n * defaultTo(fallback)(data);\n * @example\n * pipe(\"hello\" as string | undefined, defaultTo(\"world\")); //=> \"hello\"\n * pipe(undefined as string | undefined, defaultTo(\"world\")); //=> \"world\"\n * @dataLast\n * @category Other\n */\nexport function defaultTo<T, const Fallback extends FallbackOf<T>>(\n fallback: Fallback,\n): (data: T) => NonNullable<T> | Fallback;\n\nexport function defaultTo(...args: readonly unknown[]): unknown {\n return purry(defaultToImplementation, args);\n}\n\nconst defaultToImplementation = <T, Fallback extends FallbackOf<T>>(\n data: T,\n fallback: Fallback,\n): NonNullable<T> | Fallback => data ?? fallback;\n"],"mappings":"mCA4DA,SAAgB,EAAU,GAAG,EAAmC,CAC9D,OAAO,EAAM,EAAyB,EAAK,CAG7C,MAAM,GACJ,EACA,IAC8B,GAAQ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./utilityEvaluators-CW0M8vMV.cjs`),t=require(`./purryFromLazy-CwB5T8yd.cjs`);function n(...e){return t.t(r,e)}function r(t){if(t.length===0)return e.r;let n=new Map;for(let e of t)n.set(e,(n.get(e)??0)+1);return t=>{let r=n.get(t);return r===void 0||r===0?{done:!1,hasNext:!0,next:t}:(n.set(t,r-1),e.t)}}exports.difference=n;
|
|
2
|
+
//# sourceMappingURL=difference.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"difference.cjs","names":["purryFromLazy","lazyIdentityEvaluator","SKIP_ITEM"],"sources":["../src/difference.ts"],"sourcesContent":["import { purryFromLazy } from \"./internal/purryFromLazy\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport { SKIP_ITEM, lazyIdentityEvaluator } from \"./internal/utilityEvaluators\";\n\n/**\n * Excludes the values from `other` array. The output maintains the same order\n * as the input. The inputs are treated as multi-sets/bags (multiple copies of\n * items are treated as unique items).\n *\n * @param data - The input items.\n * @param other - The values to exclude.\n * @signature\n * difference(data, other)\n * @example\n * difference([1, 2, 3, 4], [2, 5, 3]); // => [1, 4]\n * difference([1, 1, 2, 2], [1]); // => [1, 2, 2]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function difference<T>(data: readonly T[], other: readonly T[]): T[];\n\n/**\n * Excludes the values from `other` array. The output maintains the same order\n * as the input. The inputs are treated as multi-sets/bags (multiple copies of\n * items are treated as unique items).\n *\n * @param other - The values to exclude.\n * @signature\n * difference(other)(data)\n * @example\n * pipe([1, 2, 3, 4], difference([2, 5, 3])); // => [1, 4]\n * pipe([1, 1, 2, 2], difference([1])); // => [1, 2, 2]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function difference<T>(other: readonly T[]): (data: readonly T[]) => T[];\n\nexport function difference(...args: readonly unknown[]): unknown {\n return purryFromLazy(lazyImplementation, args);\n}\n\nfunction lazyImplementation<T>(other: readonly T[]): LazyEvaluator<T> {\n if (other.length === 0) {\n return lazyIdentityEvaluator;\n }\n\n // We need to build a more efficient data structure that would allow us to\n // keep track of the number of times we've seen a value in the other array.\n const remaining = new Map<T, number>();\n for (const value of other) {\n remaining.set(value, (remaining.get(value) ?? 0) + 1);\n }\n\n return (value) => {\n const copies = remaining.get(value);\n\n if (copies === undefined || copies === 0) {\n // The item is either not part of the other array or we've dropped enough\n // copies of it so we return it.\n return { done: false, hasNext: true, next: value };\n }\n\n // The item is equal to an item in the other array and there are still\n // copies of it to \"account\" for so we skip this one and remove it from our\n // ongoing tally.\n remaining.set(value, copies - 1);\n return SKIP_ITEM;\n };\n}\n"],"mappings":"iKAuCA,SAAgB,EAAW,GAAG,EAAmC,CAC/D,OAAOA,EAAAA,EAAc,EAAoB,EAAK,CAGhD,SAAS,EAAsB,EAAuC,CACpE,GAAI,EAAM,SAAW,EACnB,OAAOC,EAAAA,EAKT,IAAM,EAAY,IAAI,IACtB,IAAK,IAAM,KAAS,EAClB,EAAU,IAAI,GAAQ,EAAU,IAAI,EAAM,EAAI,GAAK,EAAE,CAGvD,MAAQ,IAAU,CAChB,IAAM,EAAS,EAAU,IAAI,EAAM,CAYnC,OAVI,IAAW,IAAA,IAAa,IAAW,EAG9B,CAAE,KAAM,GAAO,QAAS,GAAM,KAAM,EAAO,EAMpD,EAAU,IAAI,EAAO,EAAS,EAAE,CACzBC,EAAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as e,t}from"./utilityEvaluators-BQqW5Ir5.js";import{t as n}from"./purryFromLazy-B-_oTxzb.js";function r(...e){return n(i,e)}function i(n){if(n.length===0)return e;let r=new Map;for(let e of n)r.set(e,(r.get(e)??0)+1);return e=>{let n=r.get(e);return n===void 0||n===0?{done:!1,hasNext:!0,next:e}:(r.set(e,n-1),t)}}export{r as difference};
|
|
2
|
+
//# sourceMappingURL=difference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"difference.js","names":[],"sources":["../src/difference.ts"],"sourcesContent":["import { purryFromLazy } from \"./internal/purryFromLazy\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport { SKIP_ITEM, lazyIdentityEvaluator } from \"./internal/utilityEvaluators\";\n\n/**\n * Excludes the values from `other` array. The output maintains the same order\n * as the input. The inputs are treated as multi-sets/bags (multiple copies of\n * items are treated as unique items).\n *\n * @param data - The input items.\n * @param other - The values to exclude.\n * @signature\n * difference(data, other)\n * @example\n * difference([1, 2, 3, 4], [2, 5, 3]); // => [1, 4]\n * difference([1, 1, 2, 2], [1]); // => [1, 2, 2]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function difference<T>(data: readonly T[], other: readonly T[]): T[];\n\n/**\n * Excludes the values from `other` array. The output maintains the same order\n * as the input. The inputs are treated as multi-sets/bags (multiple copies of\n * items are treated as unique items).\n *\n * @param other - The values to exclude.\n * @signature\n * difference(other)(data)\n * @example\n * pipe([1, 2, 3, 4], difference([2, 5, 3])); // => [1, 4]\n * pipe([1, 1, 2, 2], difference([1])); // => [1, 2, 2]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function difference<T>(other: readonly T[]): (data: readonly T[]) => T[];\n\nexport function difference(...args: readonly unknown[]): unknown {\n return purryFromLazy(lazyImplementation, args);\n}\n\nfunction lazyImplementation<T>(other: readonly T[]): LazyEvaluator<T> {\n if (other.length === 0) {\n return lazyIdentityEvaluator;\n }\n\n // We need to build a more efficient data structure that would allow us to\n // keep track of the number of times we've seen a value in the other array.\n const remaining = new Map<T, number>();\n for (const value of other) {\n remaining.set(value, (remaining.get(value) ?? 0) + 1);\n }\n\n return (value) => {\n const copies = remaining.get(value);\n\n if (copies === undefined || copies === 0) {\n // The item is either not part of the other array or we've dropped enough\n // copies of it so we return it.\n return { done: false, hasNext: true, next: value };\n }\n\n // The item is equal to an item in the other array and there are still\n // copies of it to \"account\" for so we skip this one and remove it from our\n // ongoing tally.\n remaining.set(value, copies - 1);\n return SKIP_ITEM;\n };\n}\n"],"mappings":"sGAuCA,SAAgB,EAAW,GAAG,EAAmC,CAC/D,OAAO,EAAc,EAAoB,EAAK,CAGhD,SAAS,EAAsB,EAAuC,CACpE,GAAI,EAAM,SAAW,EACnB,OAAO,EAKT,IAAM,EAAY,IAAI,IACtB,IAAK,IAAM,KAAS,EAClB,EAAU,IAAI,GAAQ,EAAU,IAAI,EAAM,EAAI,GAAK,EAAE,CAGvD,MAAQ,IAAU,CAChB,IAAM,EAAS,EAAU,IAAI,EAAM,CAYnC,OAVI,IAAW,IAAA,IAAa,IAAW,EAG9B,CAAE,KAAM,GAAO,QAAS,GAAM,KAAM,EAAO,EAMpD,EAAU,IAAI,EAAO,EAAS,EAAE,CACzB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./utilityEvaluators-CW0M8vMV.cjs`),t=require(`./purryFromLazy-CwB5T8yd.cjs`);function n(...e){return t.t(r,e)}const r=(t,n)=>r=>t.every(e=>!n(r,e))?{done:!1,hasNext:!0,next:r}:e.t;exports.differenceWith=n;
|
|
2
|
+
//# sourceMappingURL=differenceWith.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"differenceWith.cjs","names":["purryFromLazy","SKIP_ITEM"],"sources":["../src/differenceWith.ts"],"sourcesContent":["import { purryFromLazy } from \"./internal/purryFromLazy\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport { SKIP_ITEM } from \"./internal/utilityEvaluators\";\n\ntype IsEqual<T, Other> = (data: T, other: Other) => boolean;\n\n/**\n * Excludes the values from `other` array.\n * Elements are compared by custom comparator isEquals.\n *\n * @param data - The source array.\n * @param other - The values to exclude.\n * @param isEqual - The comparator.\n * @signature\n * differenceWith(data, other, isEqual)\n * @example\n * differenceWith(\n * [{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }],\n * [2, 5, 3],\n * ({ a }, b) => a === b,\n * ); //=> [{ a: 1 }, { a: 4 }]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function differenceWith<T, Other>(\n data: readonly T[],\n other: readonly Other[],\n isEqual: IsEqual<T, Other>,\n): T[];\n\n/**\n * Excludes the values from `other` array.\n * Elements are compared by custom comparator isEquals.\n *\n * @param other - The values to exclude.\n * @param isEqual - The comparator.\n * @signature\n * differenceWith(other, isEqual)(data)\n * @example\n * pipe(\n * [{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }, { a: 5 }, { a: 6 }],\n * differenceWith([2, 3], ({ a }, b) => a === b),\n * ); //=> [{ a: 1 }, { a: 4 }, { a: 5 }, { a: 6 }]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function differenceWith<T, Other>(\n other: readonly Other[],\n isEqual: IsEqual<T, Other>,\n): (data: readonly T[]) => T[];\n\nexport function differenceWith(...args: readonly unknown[]): unknown {\n return purryFromLazy(lazyImplementation, args);\n}\n\nconst lazyImplementation =\n <T, Other>(\n other: readonly Other[],\n isEqual: IsEqual<T, Other>,\n ): LazyEvaluator<T> =>\n (value) =>\n other.every((otherValue) => !isEqual(value, otherValue))\n ? { done: false, hasNext: true, next: value }\n : SKIP_ITEM;\n"],"mappings":"iKAqDA,SAAgB,EAAe,GAAG,EAAmC,CACnE,OAAOA,EAAAA,EAAc,EAAoB,EAAK,CAGhD,MAAM,GAEF,EACA,IAED,GACC,EAAM,MAAO,GAAe,CAAC,EAAQ,EAAO,EAAW,CAAC,CACpD,CAAE,KAAM,GAAO,QAAS,GAAM,KAAM,EAAO,CAC3CC,EAAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"differenceWith.js","names":[],"sources":["../src/differenceWith.ts"],"sourcesContent":["import { purryFromLazy } from \"./internal/purryFromLazy\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport { SKIP_ITEM } from \"./internal/utilityEvaluators\";\n\ntype IsEqual<T, Other> = (data: T, other: Other) => boolean;\n\n/**\n * Excludes the values from `other` array.\n * Elements are compared by custom comparator isEquals.\n *\n * @param data - The source array.\n * @param other - The values to exclude.\n * @param isEqual - The comparator.\n * @signature\n * differenceWith(data, other, isEqual)\n * @example\n * differenceWith(\n * [{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }],\n * [2, 5, 3],\n * ({ a }, b) => a === b,\n * ); //=> [{ a: 1 }, { a: 4 }]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function differenceWith<T, Other>(\n data: readonly T[],\n other: readonly Other[],\n isEqual: IsEqual<T, Other>,\n): T[];\n\n/**\n * Excludes the values from `other` array.\n * Elements are compared by custom comparator isEquals.\n *\n * @param other - The values to exclude.\n * @param isEqual - The comparator.\n * @signature\n * differenceWith(other, isEqual)(data)\n * @example\n * pipe(\n * [{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }, { a: 5 }, { a: 6 }],\n * differenceWith([2, 3], ({ a }, b) => a === b),\n * ); //=> [{ a: 1 }, { a: 4 }, { a: 5 }, { a: 6 }]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function differenceWith<T, Other>(\n other: readonly Other[],\n isEqual: IsEqual<T, Other>,\n): (data: readonly T[]) => T[];\n\nexport function differenceWith(...args: readonly unknown[]): unknown {\n return purryFromLazy(lazyImplementation, args);\n}\n\nconst lazyImplementation =\n <T, Other>(\n other: readonly Other[],\n isEqual: IsEqual<T, Other>,\n ): LazyEvaluator<T> =>\n (value) =>\n other.every((otherValue) => !isEqual(value, otherValue))\n ? { done: false, hasNext: true, next: value }\n : SKIP_ITEM;\n"],"mappings":"+FAqDA,SAAgB,EAAe,GAAG,EAAmC,CACnE,OAAO,EAAc,EAAoB,EAAK,CAGhD,MAAM,GAEF,EACA,IAED,GACC,EAAM,MAAO,GAAe,CAAC,EAAQ,EAAO,EAAW,CAAC,CACpD,CAAE,KAAM,GAAO,QAAS,GAAM,KAAM,EAAO,CAC3C"}
|
package/dist/divide.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"divide.cjs","names":["purry"],"sources":["../src/divide.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Divides two numbers.\n *\n * @param value - The number.\n * @param divisor - The number to divide the value by.\n * @signature\n * divide(value, divisor);\n * @example\n * divide(12, 3) // => 4\n * reduce([1, 2, 3, 4], divide, 24) // => 1\n * @dataFirst\n * @category Number\n */\nexport function divide(value: bigint, divisor: bigint): bigint;\nexport function divide(value: number, divisor: number): number;\n\n/**\n * Divides two numbers.\n *\n * @param divisor - The number to divide the value by.\n * @signature\n * divide(divisor)(value);\n * @example\n * divide(3)(12) // => 4\n * map([2, 4, 6, 8], divide(2)) // => [1, 2, 3, 4]\n * @dataLast\n * @category Number\n */\nexport function divide(divisor: bigint): (value: bigint) => bigint;\nexport function divide(divisor: number): (value: number) => number;\n\nexport function divide(...args: readonly unknown[]): unknown {\n return purry(divideImplementation, args);\n}\n\n// The implementation only uses `number` types, but that's just because it's\n// hard to tell typescript that both value and divisor would be of the same\n// type.\nconst divideImplementation = (value: number, divisor: number): number =>\n value / divisor;\n"],"mappings":"kGAiCA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAOA,EAAAA,MAAM,EAAsB,EAAK,CAM1C,MAAM,GAAwB,EAAe,IAC3C,EAAQ"}
|
package/dist/divide.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"divide.js","names":[],"sources":["../src/divide.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Divides two numbers.\n *\n * @param value - The number.\n * @param divisor - The number to divide the value by.\n * @signature\n * divide(value, divisor);\n * @example\n * divide(12, 3) // => 4\n * reduce([1, 2, 3, 4], divide, 24) // => 1\n * @dataFirst\n * @category Number\n */\nexport function divide(value: bigint, divisor: bigint): bigint;\nexport function divide(value: number, divisor: number): number;\n\n/**\n * Divides two numbers.\n *\n * @param divisor - The number to divide the value by.\n * @signature\n * divide(divisor)(value);\n * @example\n * divide(3)(12) // => 4\n * map([2, 4, 6, 8], divide(2)) // => [1, 2, 3, 4]\n * @dataLast\n * @category Number\n */\nexport function divide(divisor: bigint): (value: bigint) => bigint;\nexport function divide(divisor: number): (value: number) => number;\n\nexport function divide(...args: readonly unknown[]): unknown {\n return purry(divideImplementation, args);\n}\n\n// The implementation only uses `number` types, but that's just because it's\n// hard to tell typescript that both value and divisor would be of the same\n// type.\nconst divideImplementation = (value: number, divisor: number): number =>\n value / divisor;\n"],"mappings":"mCAiCA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAO,EAAM,EAAsB,EAAK,CAM1C,MAAM,GAAwB,EAAe,IAC3C,EAAQ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doNothing.cjs","names":[],"sources":["../src/doNothing.ts"],"sourcesContent":["/**\n * A function that takes any arguments and does nothing with them. This is\n * useful as a placeholder for any function or API that requires a **void**\n * function (a function that doesn't return a value). This could also be used in\n * combination with a ternary or other conditional execution to allow disabling\n * a function call for a specific case.\n *\n * Notice that this is a dataLast impl where the function needs to be invoked\n * to get the \"do nothing\" function.\n *\n * See also:\n * * `constant` - A function that ignores it's arguments and returns the same value on every invocation.\n * * `identity` - A function that returns the first argument it receives.\n *\n * @signature\n * doNothing();\n * @example\n * myApi({ onSuccess: handleSuccess, onError: doNothing() });\n * myApi({ onSuccess: isDemoMode ? doNothing(): handleSuccess });\n * @dataLast\n * @category Function\n */\nexport function doNothing(): typeof doesNothing {\n // Notice that the exported identity function is just the \"factory\" for the\n // function. We do it this way so that all \"Function\" utilities have a similar\n // API where the function is called, and not just used \"headless\". e.g.\n // `doNothing()` and not `doNothing`, just like the API for `constant(1)`.\n return doesNothing;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- There is no other way to make typescript infer the function arguments \"backwards\" in data-last invocations without the Args type parameter. @see: https://github.com/typescript-eslint/typescript-eslint/issues/9887\nfunction doesNothing<Args extends readonly unknown[]>(..._args: Args): void {\n /* do nothing */\n}\n"],"mappings":"mEAsBA,SAAgB,GAAgC,CAK9C,OAAO,EAIT,SAAS,EAA6C,GAAG,EAAmB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doNothing.js","names":[],"sources":["../src/doNothing.ts"],"sourcesContent":["/**\n * A function that takes any arguments and does nothing with them. This is\n * useful as a placeholder for any function or API that requires a **void**\n * function (a function that doesn't return a value). This could also be used in\n * combination with a ternary or other conditional execution to allow disabling\n * a function call for a specific case.\n *\n * Notice that this is a dataLast impl where the function needs to be invoked\n * to get the \"do nothing\" function.\n *\n * See also:\n * * `constant` - A function that ignores it's arguments and returns the same value on every invocation.\n * * `identity` - A function that returns the first argument it receives.\n *\n * @signature\n * doNothing();\n * @example\n * myApi({ onSuccess: handleSuccess, onError: doNothing() });\n * myApi({ onSuccess: isDemoMode ? doNothing(): handleSuccess });\n * @dataLast\n * @category Function\n */\nexport function doNothing(): typeof doesNothing {\n // Notice that the exported identity function is just the \"factory\" for the\n // function. We do it this way so that all \"Function\" utilities have a similar\n // API where the function is called, and not just used \"headless\". e.g.\n // `doNothing()` and not `doNothing`, just like the API for `constant(1)`.\n return doesNothing;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- There is no other way to make typescript infer the function arguments \"backwards\" in data-last invocations without the Args type parameter. @see: https://github.com/typescript-eslint/typescript-eslint/issues/9887\nfunction doesNothing<Args extends readonly unknown[]>(..._args: Args): void {\n /* do nothing */\n}\n"],"mappings":"AAsBA,SAAgB,GAAgC,CAK9C,OAAO,EAIT,SAAS,EAA6C,GAAG,EAAmB"}
|
package/dist/drop.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`),t=require(`./utilityEvaluators-CW0M8vMV.cjs`);function n(...t){return e.purry(r,t,i)}const r=(e,t)=>t<0?[...e]:e.slice(t);function i(e){if(e<=0)return t.r;let n=e;return e=>n>0?(--n,t.t):{done:!1,hasNext:!0,next:e}}exports.drop=n;
|
|
2
|
+
//# sourceMappingURL=drop.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drop.cjs","names":["purry","lazyIdentityEvaluator","SKIP_ITEM"],"sources":["../src/drop.ts"],"sourcesContent":["import type { IsInteger, IsNegative, Writable } from \"type-fest\";\nimport type { ClampedIntegerSubtract } from \"./internal/types/ClampedIntegerSubtract\";\nimport type { CoercedArray } from \"./internal/types/CoercedArray\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport type { PartialArray } from \"./internal/types/PartialArray\";\nimport type { TupleParts } from \"./internal/types/TupleParts\";\nimport { SKIP_ITEM, lazyIdentityEvaluator } from \"./internal/utilityEvaluators\";\nimport { purry } from \"./purry\";\n\ntype Drop<T extends IterableContainer, N extends number> =\n IsNegative<N> extends true\n ? // Negative numbers result in nothing being dropped, we return a shallow\n // clone of the array.\n Writable<T>\n : IsInteger<N> extends true\n ? ClampedIntegerSubtract<\n N,\n TupleParts<T>[\"required\"][\"length\"]\n > extends infer RemainingPrefix extends number\n ? RemainingPrefix extends 0\n ? // The drop will occur within the required part of the tuple, we\n // simply remove those elements from it and reconstruct the rest of\n // the tuple.\n [\n ...DropFixedTuple<TupleParts<T>[\"required\"], N>,\n ...PartialArray<TupleParts<T>[\"optional\"]>,\n ...CoercedArray<TupleParts<T>[\"item\"]>,\n ...TupleParts<T>[\"suffix\"],\n ]\n : ClampedIntegerSubtract<\n RemainingPrefix,\n TupleParts<T>[\"optional\"][\"length\"]\n > extends infer RemainingOptional extends number\n ? RemainingOptional extends 0\n ? // The drop will occur within the optional part of the tuple, we\n // completely remove the required part, remove enough elements\n // from the optional part, and reconstruct the rest of the\n // tuple.\n [\n ...PartialArray<\n DropFixedTuple<TupleParts<T>[\"optional\"], RemainingPrefix>\n >,\n ...CoercedArray<TupleParts<T>[\"item\"]>,\n ...TupleParts<T>[\"suffix\"],\n ]\n : // The drop will occur within the rest element or the suffix.\n // Because the suffix can contain any number of elements this\n // case adds more complexity as we need to consider all\n // possible (relevant) lengths. We start by considering the\n // case where there are enough elements within the rest\n // param; this means we still maintain the rest element as it\n // could contain even more elements, and we add the suffix\n // untouched.\n | [\n ...CoercedArray<TupleParts<T>[\"item\"]>,\n ...TupleParts<T>[\"suffix\"],\n ]\n // Additionally, we need to consider the case where the rest\n // element has up to the same number of elements as the\n // suffix; this will result in removing the rest element\n // entirely, and dropping elements from the suffix. We do this\n // for all possible values from 0 to N where N is the\n // remaining value after we handled the prefix. We can exclude\n // the 0 case because it is contained in the previous case.\n | Exclude<\n DropFixedTuple<\n TupleParts<T>[\"suffix\"],\n RemainingOptional,\n true /* IncludePrefixes */\n >,\n TupleParts<T>[\"suffix\"]\n >\n : never\n : never\n : // We can't compute accurate types for non-integer numbers so we\n // fallback to the \"legacy\" typing where we convert our output to a\n // simple array. This is also the case when N is not a literal value\n // (e.g. it is `number`).\n // TODO: We can improve this type by returning a union of all possible dropped shapes (e.g. the equivalent of Drop<T, 1> | Drop<T, 2> | Drop<T, 3> | ...).\n T[number][];\n\ntype DropFixedTuple<\n T,\n N,\n // This flag controls if we want a union of all possible prefixes, or just the\n // final tuple with all N items dropped.\n IncludePrefixes = false,\n Dropped extends unknown[] = [],\n> = Dropped[\"length\"] extends N\n ? T\n : T extends readonly [unknown, ...infer Rest]\n ?\n | DropFixedTuple<Rest, N, IncludePrefixes, [...Dropped, unknown]>\n | (true extends IncludePrefixes ? T : never)\n : [];\n\n/**\n * Removes first `n` elements from the `array`.\n *\n * @param array - The target array.\n * @param n - The number of elements to skip.\n * @signature\n * drop(array, n)\n * @example\n * drop([1, 2, 3, 4, 5], 2) // => [3, 4, 5]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function drop<T extends IterableContainer, N extends number>(\n array: T,\n n: N,\n): Drop<T, N>;\n\n/**\n * Removes first `n` elements from the `array`.\n *\n * @param n - The number of elements to skip.\n * @signature\n * drop(n)(array)\n * @example\n * drop(2)([1, 2, 3, 4, 5]) // => [3, 4, 5]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function drop<N extends number>(\n n: N,\n): <T extends IterableContainer>(array: T) => Drop<T, N>;\n\nexport function drop(...args: readonly unknown[]): unknown {\n return purry(dropImplementation, args, lazyImplementation);\n}\n\nconst dropImplementation = <T extends IterableContainer>(\n array: T,\n n: number,\n): T[number][] => (n < 0 ? [...array] : array.slice(n));\n\nfunction lazyImplementation<T>(n: number): LazyEvaluator<T> {\n if (n <= 0) {\n return lazyIdentityEvaluator;\n }\n\n let left = n;\n return (value) => {\n if (left > 0) {\n left -= 1;\n return SKIP_ITEM;\n }\n return { done: false, hasNext: true, next: value };\n };\n}\n"],"mappings":"gJAmIA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAOA,EAAAA,MAAM,EAAoB,EAAM,EAAmB,CAG5D,MAAM,GACJ,EACA,IACiB,EAAI,EAAI,CAAC,GAAG,EAAM,CAAG,EAAM,MAAM,EAAE,CAEtD,SAAS,EAAsB,EAA6B,CAC1D,GAAI,GAAK,EACP,OAAOC,EAAAA,EAGT,IAAI,EAAO,EACX,MAAQ,IACF,EAAO,GACT,IACOC,EAAAA,GAEF,CAAE,KAAM,GAAO,QAAS,GAAM,KAAM,EAAO"}
|
package/dist/drop.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{purry as e}from"./purry.js";import{r as t,t as n}from"./utilityEvaluators-BQqW5Ir5.js";function r(...t){return e(i,t,a)}const i=(e,t)=>t<0?[...e]:e.slice(t);function a(e){if(e<=0)return t;let r=e;return e=>r>0?(--r,n):{done:!1,hasNext:!0,next:e}}export{r as drop};
|
|
2
|
+
//# sourceMappingURL=drop.js.map
|
package/dist/drop.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drop.js","names":[],"sources":["../src/drop.ts"],"sourcesContent":["import type { IsInteger, IsNegative, Writable } from \"type-fest\";\nimport type { ClampedIntegerSubtract } from \"./internal/types/ClampedIntegerSubtract\";\nimport type { CoercedArray } from \"./internal/types/CoercedArray\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport type { PartialArray } from \"./internal/types/PartialArray\";\nimport type { TupleParts } from \"./internal/types/TupleParts\";\nimport { SKIP_ITEM, lazyIdentityEvaluator } from \"./internal/utilityEvaluators\";\nimport { purry } from \"./purry\";\n\ntype Drop<T extends IterableContainer, N extends number> =\n IsNegative<N> extends true\n ? // Negative numbers result in nothing being dropped, we return a shallow\n // clone of the array.\n Writable<T>\n : IsInteger<N> extends true\n ? ClampedIntegerSubtract<\n N,\n TupleParts<T>[\"required\"][\"length\"]\n > extends infer RemainingPrefix extends number\n ? RemainingPrefix extends 0\n ? // The drop will occur within the required part of the tuple, we\n // simply remove those elements from it and reconstruct the rest of\n // the tuple.\n [\n ...DropFixedTuple<TupleParts<T>[\"required\"], N>,\n ...PartialArray<TupleParts<T>[\"optional\"]>,\n ...CoercedArray<TupleParts<T>[\"item\"]>,\n ...TupleParts<T>[\"suffix\"],\n ]\n : ClampedIntegerSubtract<\n RemainingPrefix,\n TupleParts<T>[\"optional\"][\"length\"]\n > extends infer RemainingOptional extends number\n ? RemainingOptional extends 0\n ? // The drop will occur within the optional part of the tuple, we\n // completely remove the required part, remove enough elements\n // from the optional part, and reconstruct the rest of the\n // tuple.\n [\n ...PartialArray<\n DropFixedTuple<TupleParts<T>[\"optional\"], RemainingPrefix>\n >,\n ...CoercedArray<TupleParts<T>[\"item\"]>,\n ...TupleParts<T>[\"suffix\"],\n ]\n : // The drop will occur within the rest element or the suffix.\n // Because the suffix can contain any number of elements this\n // case adds more complexity as we need to consider all\n // possible (relevant) lengths. We start by considering the\n // case where there are enough elements within the rest\n // param; this means we still maintain the rest element as it\n // could contain even more elements, and we add the suffix\n // untouched.\n | [\n ...CoercedArray<TupleParts<T>[\"item\"]>,\n ...TupleParts<T>[\"suffix\"],\n ]\n // Additionally, we need to consider the case where the rest\n // element has up to the same number of elements as the\n // suffix; this will result in removing the rest element\n // entirely, and dropping elements from the suffix. We do this\n // for all possible values from 0 to N where N is the\n // remaining value after we handled the prefix. We can exclude\n // the 0 case because it is contained in the previous case.\n | Exclude<\n DropFixedTuple<\n TupleParts<T>[\"suffix\"],\n RemainingOptional,\n true /* IncludePrefixes */\n >,\n TupleParts<T>[\"suffix\"]\n >\n : never\n : never\n : // We can't compute accurate types for non-integer numbers so we\n // fallback to the \"legacy\" typing where we convert our output to a\n // simple array. This is also the case when N is not a literal value\n // (e.g. it is `number`).\n // TODO: We can improve this type by returning a union of all possible dropped shapes (e.g. the equivalent of Drop<T, 1> | Drop<T, 2> | Drop<T, 3> | ...).\n T[number][];\n\ntype DropFixedTuple<\n T,\n N,\n // This flag controls if we want a union of all possible prefixes, or just the\n // final tuple with all N items dropped.\n IncludePrefixes = false,\n Dropped extends unknown[] = [],\n> = Dropped[\"length\"] extends N\n ? T\n : T extends readonly [unknown, ...infer Rest]\n ?\n | DropFixedTuple<Rest, N, IncludePrefixes, [...Dropped, unknown]>\n | (true extends IncludePrefixes ? T : never)\n : [];\n\n/**\n * Removes first `n` elements from the `array`.\n *\n * @param array - The target array.\n * @param n - The number of elements to skip.\n * @signature\n * drop(array, n)\n * @example\n * drop([1, 2, 3, 4, 5], 2) // => [3, 4, 5]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function drop<T extends IterableContainer, N extends number>(\n array: T,\n n: N,\n): Drop<T, N>;\n\n/**\n * Removes first `n` elements from the `array`.\n *\n * @param n - The number of elements to skip.\n * @signature\n * drop(n)(array)\n * @example\n * drop(2)([1, 2, 3, 4, 5]) // => [3, 4, 5]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function drop<N extends number>(\n n: N,\n): <T extends IterableContainer>(array: T) => Drop<T, N>;\n\nexport function drop(...args: readonly unknown[]): unknown {\n return purry(dropImplementation, args, lazyImplementation);\n}\n\nconst dropImplementation = <T extends IterableContainer>(\n array: T,\n n: number,\n): T[number][] => (n < 0 ? [...array] : array.slice(n));\n\nfunction lazyImplementation<T>(n: number): LazyEvaluator<T> {\n if (n <= 0) {\n return lazyIdentityEvaluator;\n }\n\n let left = n;\n return (value) => {\n if (left > 0) {\n left -= 1;\n return SKIP_ITEM;\n }\n return { done: false, hasNext: true, next: value };\n };\n}\n"],"mappings":"8FAmIA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAO,EAAM,EAAoB,EAAM,EAAmB,CAG5D,MAAM,GACJ,EACA,IACiB,EAAI,EAAI,CAAC,GAAG,EAAM,CAAG,EAAM,MAAM,EAAE,CAEtD,SAAS,EAAsB,EAA6B,CAC1D,GAAI,GAAK,EACP,OAAO,EAGT,IAAI,EAAO,EACX,MAAQ,IACF,EAAO,GACT,IACO,GAEF,CAAE,KAAM,GAAO,QAAS,GAAM,KAAM,EAAO"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./heap-14xVkDB1.cjs`),t=require(`./purryOrderRules-B8pzD03D.cjs`);function n(...e){return t.n(r,e)}function r(t,n,r){if(r>=t.length)return[];if(r<=0)return[...t];let i=t.slice(0,r);e.n(i,n);let a=[],o=t.slice(r);for(let t of o){let r=e.t(i,n,t);a.push(r??t)}return a}exports.dropFirstBy=n;
|
|
2
|
+
//# sourceMappingURL=dropFirstBy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropFirstBy.cjs","names":["purryOrderRulesWithArgument","heapMaybeInsert"],"sources":["../src/dropFirstBy.ts"],"sourcesContent":["import { heapify, heapMaybeInsert } from \"./internal/heap\";\nimport {\n purryOrderRulesWithArgument,\n type OrderRule,\n} from \"./internal/purryOrderRules\";\nimport type { CompareFunction } from \"./internal/types/CompareFunction\";\nimport type { NonEmptyArray } from \"./internal/types/NonEmptyArray\";\n\n/**\n * Drop the first `n` items from `data` based on the provided ordering criteria. This allows you to avoid sorting the array before dropping the items. The complexity of this function is *O(Nlogn)* where `N` is the length of the array.\n *\n * For the opposite operation (to keep `n` elements) see `takeFirstBy`.\n *\n * @param data - The input array.\n * @param n - The number of items to drop. If `n` is non-positive no items would be dropped and a *clone* of the input would be returned, if `n` is bigger then data.length no items would be returned.\n * @param rules - A variadic array of order rules defining the sorting criteria. Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, \"desc\"]` for descending order.\n * @returns A subset of the input array.\n * @signature\n * dropFirstBy(data, n, ...rules);\n * @example\n * dropFirstBy(['aa', 'aaaa', 'a', 'aaa'], 2, x => x.length); // => ['aaa', 'aaaa']\n * @dataFirst\n * @category Array\n */\nexport function dropFirstBy<T>(\n data: readonly T[],\n n: number,\n ...rules: Readonly<NonEmptyArray<OrderRule<T>>>\n): T[];\n\n/**\n * Drop the first `n` items from `data` based on the provided ordering criteria. This allows you to avoid sorting the array before dropping the items. The complexity of this function is *O(Nlogn)* where `N` is the length of the array.\n *\n * For the opposite operation (to keep `n` elements) see `takeFirstBy`.\n *\n * @param n - The number of items to drop. If `n` is non-positive no items would be dropped and a *clone* of the input would be returned, if `n` is bigger then data.length no items would be returned.\n * @param rules - A variadic array of order rules defining the sorting criteria. Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, \"desc\"]` for descending order.\n * @returns A subset of the input array.\n * @signature\n * dropFirstBy(n, ...rules)(data);\n * @example\n * pipe(['aa', 'aaaa', 'a', 'aaa'], dropFirstBy(2, x => x.length)); // => ['aaa', 'aaaa']\n * @dataLast\n * @category Array\n */\nexport function dropFirstBy<T>(\n n: number,\n ...rules: Readonly<NonEmptyArray<OrderRule<T>>>\n): (data: readonly T[]) => T[];\n\nexport function dropFirstBy(...args: readonly unknown[]): unknown {\n return purryOrderRulesWithArgument(dropFirstByImplementation, args);\n}\n\nfunction dropFirstByImplementation<T>(\n data: readonly T[],\n compareFn: CompareFunction<T>,\n n: number,\n): T[] {\n if (n >= data.length) {\n return [];\n }\n\n if (n <= 0) {\n return [...data];\n }\n\n const heap = data.slice(0, n);\n heapify(heap, compareFn);\n\n const out = [];\n\n const rest = data.slice(n);\n for (const item of rest) {\n const previousHead = heapMaybeInsert(heap, compareFn, item);\n out.push(previousHead ?? item);\n }\n\n return out;\n}\n"],"mappings":"sJAkDA,SAAgB,EAAY,GAAG,EAAmC,CAChE,OAAOA,EAAAA,EAA4B,EAA2B,EAAK,CAGrE,SAAS,EACP,EACA,EACA,EACK,CACL,GAAI,GAAK,EAAK,OACZ,MAAO,EAAE,CAGX,GAAI,GAAK,EACP,MAAO,CAAC,GAAG,EAAK,CAGlB,IAAM,EAAO,EAAK,MAAM,EAAG,EAAE,CAC7B,EAAA,EAAQ,EAAM,EAAU,CAExB,IAAM,EAAM,EAAE,CAER,EAAO,EAAK,MAAM,EAAE,CAC1B,IAAK,IAAM,KAAQ,EAAM,CACvB,IAAM,EAAeC,EAAAA,EAAgB,EAAM,EAAW,EAAK,CAC3D,EAAI,KAAK,GAAgB,EAAK,CAGhC,OAAO"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{n as e,t}from"./heap-OOe_F8_z.js";import{n}from"./purryOrderRules-4JgY6z4X.js";function r(...e){return n(i,e)}function i(n,r,i){if(i>=n.length)return[];if(i<=0)return[...n];let a=n.slice(0,i);e(a,r);let o=[],s=n.slice(i);for(let e of s){let n=t(a,r,e);o.push(n??e)}return o}export{r as dropFirstBy};
|
|
2
|
+
//# sourceMappingURL=dropFirstBy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropFirstBy.js","names":[],"sources":["../src/dropFirstBy.ts"],"sourcesContent":["import { heapify, heapMaybeInsert } from \"./internal/heap\";\nimport {\n purryOrderRulesWithArgument,\n type OrderRule,\n} from \"./internal/purryOrderRules\";\nimport type { CompareFunction } from \"./internal/types/CompareFunction\";\nimport type { NonEmptyArray } from \"./internal/types/NonEmptyArray\";\n\n/**\n * Drop the first `n` items from `data` based on the provided ordering criteria. This allows you to avoid sorting the array before dropping the items. The complexity of this function is *O(Nlogn)* where `N` is the length of the array.\n *\n * For the opposite operation (to keep `n` elements) see `takeFirstBy`.\n *\n * @param data - The input array.\n * @param n - The number of items to drop. If `n` is non-positive no items would be dropped and a *clone* of the input would be returned, if `n` is bigger then data.length no items would be returned.\n * @param rules - A variadic array of order rules defining the sorting criteria. Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, \"desc\"]` for descending order.\n * @returns A subset of the input array.\n * @signature\n * dropFirstBy(data, n, ...rules);\n * @example\n * dropFirstBy(['aa', 'aaaa', 'a', 'aaa'], 2, x => x.length); // => ['aaa', 'aaaa']\n * @dataFirst\n * @category Array\n */\nexport function dropFirstBy<T>(\n data: readonly T[],\n n: number,\n ...rules: Readonly<NonEmptyArray<OrderRule<T>>>\n): T[];\n\n/**\n * Drop the first `n` items from `data` based on the provided ordering criteria. This allows you to avoid sorting the array before dropping the items. The complexity of this function is *O(Nlogn)* where `N` is the length of the array.\n *\n * For the opposite operation (to keep `n` elements) see `takeFirstBy`.\n *\n * @param n - The number of items to drop. If `n` is non-positive no items would be dropped and a *clone* of the input would be returned, if `n` is bigger then data.length no items would be returned.\n * @param rules - A variadic array of order rules defining the sorting criteria. Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, \"desc\"]` for descending order.\n * @returns A subset of the input array.\n * @signature\n * dropFirstBy(n, ...rules)(data);\n * @example\n * pipe(['aa', 'aaaa', 'a', 'aaa'], dropFirstBy(2, x => x.length)); // => ['aaa', 'aaaa']\n * @dataLast\n * @category Array\n */\nexport function dropFirstBy<T>(\n n: number,\n ...rules: Readonly<NonEmptyArray<OrderRule<T>>>\n): (data: readonly T[]) => T[];\n\nexport function dropFirstBy(...args: readonly unknown[]): unknown {\n return purryOrderRulesWithArgument(dropFirstByImplementation, args);\n}\n\nfunction dropFirstByImplementation<T>(\n data: readonly T[],\n compareFn: CompareFunction<T>,\n n: number,\n): T[] {\n if (n >= data.length) {\n return [];\n }\n\n if (n <= 0) {\n return [...data];\n }\n\n const heap = data.slice(0, n);\n heapify(heap, compareFn);\n\n const out = [];\n\n const rest = data.slice(n);\n for (const item of rest) {\n const previousHead = heapMaybeInsert(heap, compareFn, item);\n out.push(previousHead ?? item);\n }\n\n return out;\n}\n"],"mappings":"sFAkDA,SAAgB,EAAY,GAAG,EAAmC,CAChE,OAAO,EAA4B,EAA2B,EAAK,CAGrE,SAAS,EACP,EACA,EACA,EACK,CACL,GAAI,GAAK,EAAK,OACZ,MAAO,EAAE,CAGX,GAAI,GAAK,EACP,MAAO,CAAC,GAAG,EAAK,CAGlB,IAAM,EAAO,EAAK,MAAM,EAAG,EAAE,CAC7B,EAAQ,EAAM,EAAU,CAExB,IAAM,EAAM,EAAE,CAER,EAAO,EAAK,MAAM,EAAE,CAC1B,IAAK,IAAM,KAAQ,EAAM,CACvB,IAAM,EAAe,EAAgB,EAAM,EAAW,EAAK,CAC3D,EAAI,KAAK,GAAgB,EAAK,CAGhC,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropLast.cjs","names":["purry"],"sources":["../src/dropLast.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\n/**\n * Removes last `n` elements from the `array`.\n *\n * @param array - The target array.\n * @param n - The number of elements to skip.\n * @signature\n * dropLast(array, n)\n * @example\n * dropLast([1, 2, 3, 4, 5], 2) // => [1, 2, 3]\n * @dataFirst\n * @category Array\n */\nexport function dropLast<T extends IterableContainer>(\n array: T,\n n: number,\n): T[number][];\n\n/**\n * Removes last `n` elements from the `array`.\n *\n * @param n - The number of elements to skip.\n * @signature\n * dropLast(n)(array)\n * @example\n * dropLast(2)([1, 2, 3, 4, 5]) // => [1, 2, 3]\n * @dataLast\n * @category Array\n */\nexport function dropLast(\n n: number,\n): <T extends IterableContainer>(array: T) => T[number][];\n\nexport function dropLast(...args: readonly unknown[]): unknown {\n return purry(dropLastImplementation, args);\n}\n\nconst dropLastImplementation = <T extends IterableContainer>(\n array: T,\n n: number,\n): T[number][] =>\n n > 0 ? array.slice(0, Math.max(0, array.length - n)) : [...array];\n"],"mappings":"kGAmCA,SAAgB,EAAS,GAAG,EAAmC,CAC7D,OAAOA,EAAAA,MAAM,EAAwB,EAAK,CAG5C,MAAM,GACJ,EACA,IAEA,EAAI,EAAI,EAAM,MAAM,EAAG,KAAK,IAAI,EAAG,EAAM,OAAS,EAAE,CAAC,CAAG,CAAC,GAAG,EAAM"}
|
package/dist/dropLast.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropLast.js","names":[],"sources":["../src/dropLast.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\n/**\n * Removes last `n` elements from the `array`.\n *\n * @param array - The target array.\n * @param n - The number of elements to skip.\n * @signature\n * dropLast(array, n)\n * @example\n * dropLast([1, 2, 3, 4, 5], 2) // => [1, 2, 3]\n * @dataFirst\n * @category Array\n */\nexport function dropLast<T extends IterableContainer>(\n array: T,\n n: number,\n): T[number][];\n\n/**\n * Removes last `n` elements from the `array`.\n *\n * @param n - The number of elements to skip.\n * @signature\n * dropLast(n)(array)\n * @example\n * dropLast(2)([1, 2, 3, 4, 5]) // => [1, 2, 3]\n * @dataLast\n * @category Array\n */\nexport function dropLast(\n n: number,\n): <T extends IterableContainer>(array: T) => T[number][];\n\nexport function dropLast(...args: readonly unknown[]): unknown {\n return purry(dropLastImplementation, args);\n}\n\nconst dropLastImplementation = <T extends IterableContainer>(\n array: T,\n n: number,\n): T[number][] =>\n n > 0 ? array.slice(0, Math.max(0, array.length - n)) : [...array];\n"],"mappings":"mCAmCA,SAAgB,EAAS,GAAG,EAAmC,CAC7D,OAAO,EAAM,EAAwB,EAAK,CAG5C,MAAM,GACJ,EACA,IAEA,EAAI,EAAI,EAAM,MAAM,EAAG,KAAK,IAAI,EAAG,EAAM,OAAS,EAAE,CAAC,CAAG,CAAC,GAAG,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){for(let n=e.length-1;n>=0;n--)if(!t(e[n],n,e))return e.slice(0,n+1);return[]}exports.dropLastWhile=t;
|
|
2
|
+
//# sourceMappingURL=dropLastWhile.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropLastWhile.cjs","names":["purry"],"sources":["../src/dropLastWhile.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\n/**\n * Removes elements from the end of the array until the predicate returns false.\n *\n * The predicate is applied to each element in the array starting from the end and moving towards the beginning, until the predicate returns false. The returned array includes elements from the beginning of the array, up to and including the element that produced false for the predicate.\n *\n * @param data - The array.\n * @param predicate - The predicate.\n * @signature\n * dropLastWhile(data, predicate)\n * @example\n * dropLastWhile([1, 2, 10, 3, 4], x => x < 10) // => [1, 2, 10]\n * @dataFirst\n * @category Array\n */\nexport function dropLastWhile<T extends IterableContainer>(\n data: T,\n predicate: (item: T[number], index: number, data: T) => boolean,\n): T[number][];\n\n/**\n * Removes elements from the end of the array until the predicate returns false.\n *\n * The predicate is applied to each element in the array starting from the end and moving towards the beginning, until the predicate returns false. The returned array includes elements from the beginning of the array, up to and including the element that produced false for the predicate.\n *\n * @param predicate - The predicate.\n * @signature\n * dropLastWhile(predicate)(data)\n * @example\n * pipe([1, 2, 10, 3, 4], dropLastWhile(x => x < 10)) // => [1, 2, 10]\n * @dataLast\n * @category Array\n */\nexport function dropLastWhile<T extends IterableContainer>(\n predicate: (item: T[number], index: number, data: T) => boolean,\n): (data: T) => T[number][];\n\nexport function dropLastWhile(...args: readonly unknown[]): unknown {\n return purry(dropLastWhileImplementation, args);\n}\n\nfunction dropLastWhileImplementation<T extends IterableContainer>(\n data: T,\n predicate: (item: T[number], index: number, data: T) => boolean,\n): T[number][] {\n for (let i = data.length - 1; i >= 0; i--) {\n if (!predicate(data[i], i, data)) {\n return data.slice(0, i + 1);\n }\n }\n return [];\n}\n"],"mappings":"kGAuCA,SAAgB,EAAc,GAAG,EAAmC,CAClE,OAAOA,EAAAA,MAAM,EAA6B,EAAK,CAGjD,SAAS,EACP,EACA,EACa,CACb,IAAK,IAAI,EAAI,EAAK,OAAS,EAAG,GAAK,EAAG,IACpC,GAAI,CAAC,EAAU,EAAK,GAAI,EAAG,EAAK,CAC9B,OAAO,EAAK,MAAM,EAAG,EAAI,EAAE,CAG/B,MAAO,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropLastWhile.js","names":[],"sources":["../src/dropLastWhile.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\n/**\n * Removes elements from the end of the array until the predicate returns false.\n *\n * The predicate is applied to each element in the array starting from the end and moving towards the beginning, until the predicate returns false. The returned array includes elements from the beginning of the array, up to and including the element that produced false for the predicate.\n *\n * @param data - The array.\n * @param predicate - The predicate.\n * @signature\n * dropLastWhile(data, predicate)\n * @example\n * dropLastWhile([1, 2, 10, 3, 4], x => x < 10) // => [1, 2, 10]\n * @dataFirst\n * @category Array\n */\nexport function dropLastWhile<T extends IterableContainer>(\n data: T,\n predicate: (item: T[number], index: number, data: T) => boolean,\n): T[number][];\n\n/**\n * Removes elements from the end of the array until the predicate returns false.\n *\n * The predicate is applied to each element in the array starting from the end and moving towards the beginning, until the predicate returns false. The returned array includes elements from the beginning of the array, up to and including the element that produced false for the predicate.\n *\n * @param predicate - The predicate.\n * @signature\n * dropLastWhile(predicate)(data)\n * @example\n * pipe([1, 2, 10, 3, 4], dropLastWhile(x => x < 10)) // => [1, 2, 10]\n * @dataLast\n * @category Array\n */\nexport function dropLastWhile<T extends IterableContainer>(\n predicate: (item: T[number], index: number, data: T) => boolean,\n): (data: T) => T[number][];\n\nexport function dropLastWhile(...args: readonly unknown[]): unknown {\n return purry(dropLastWhileImplementation, args);\n}\n\nfunction dropLastWhileImplementation<T extends IterableContainer>(\n data: T,\n predicate: (item: T[number], index: number, data: T) => boolean,\n): T[number][] {\n for (let i = data.length - 1; i >= 0; i--) {\n if (!predicate(data[i], i, data)) {\n return data.slice(0, i + 1);\n }\n }\n return [];\n}\n"],"mappings":"mCAuCA,SAAgB,EAAc,GAAG,EAAmC,CAClE,OAAO,EAAM,EAA6B,EAAK,CAGjD,SAAS,EACP,EACA,EACa,CACb,IAAK,IAAI,EAAI,EAAK,OAAS,EAAG,GAAK,EAAG,IACpC,GAAI,CAAC,EAAU,EAAK,GAAI,EAAG,EAAK,CAC9B,OAAO,EAAK,MAAM,EAAG,EAAI,EAAE,CAG/B,MAAO,EAAE"}
|
|
@@ -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){for(let[n,r]of e.entries())if(!t(r,n,e))return e.slice(n);return[]}exports.dropWhile=t;
|
|
2
|
+
//# sourceMappingURL=dropWhile.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropWhile.cjs","names":["purry"],"sources":["../src/dropWhile.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\n/**\n * Removes elements from the beginning of the array until the predicate returns false.\n *\n * The predicate is applied to each element in the array, until the predicate returns false. The returned array includes the rest of the elements, starting with the element that produced false for the predicate.\n *\n * @param data - The array.\n * @param predicate - The predicate.\n * @signature\n * dropWhile(data, predicate)\n * @example\n * dropWhile([1, 2, 10, 3, 4], x => x < 10) // => [10, 3, 4]\n * @dataFirst\n * @category Array\n */\nexport function dropWhile<T extends IterableContainer>(\n data: T,\n predicate: (item: T[number], index: number, data: T) => boolean,\n): T[number][];\n\n/**\n * Removes elements from the beginning of the array until the predicate returns false.\n *\n * The predicate is applied to each element in the array, until the predicate returns false. The returned array includes the rest of the elements, starting with the element that produced false for the predicate.\n *\n * @param predicate - The predicate.\n * @signature\n * dropWhile(predicate)(data)\n * @example\n * pipe([1, 2, 10, 3, 4], dropWhile(x => x < 10)) // => [10, 3, 4]\n * @dataLast\n * @category Array\n */\nexport function dropWhile<T extends IterableContainer>(\n predicate: (item: T[number], index: number, data: T) => boolean,\n): (data: T) => T[number][];\n\nexport function dropWhile(...args: readonly unknown[]): unknown {\n return purry(dropWhileImplementation, args);\n}\n\nfunction dropWhileImplementation<T extends IterableContainer>(\n data: T,\n predicate: (item: T[number], index: number, data: T) => boolean,\n): T[number][] {\n for (const [index, item] of data.entries()) {\n if (!predicate(item, index, data)) {\n return data.slice(index);\n }\n }\n return [];\n}\n"],"mappings":"kGAuCA,SAAgB,EAAU,GAAG,EAAmC,CAC9D,OAAOA,EAAAA,MAAM,EAAyB,EAAK,CAG7C,SAAS,EACP,EACA,EACa,CACb,IAAK,GAAM,CAAC,EAAO,KAAS,EAAK,SAAS,CACxC,GAAI,CAAC,EAAU,EAAM,EAAO,EAAK,CAC/B,OAAO,EAAK,MAAM,EAAM,CAG5B,MAAO,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropWhile.js","names":[],"sources":["../src/dropWhile.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\n/**\n * Removes elements from the beginning of the array until the predicate returns false.\n *\n * The predicate is applied to each element in the array, until the predicate returns false. The returned array includes the rest of the elements, starting with the element that produced false for the predicate.\n *\n * @param data - The array.\n * @param predicate - The predicate.\n * @signature\n * dropWhile(data, predicate)\n * @example\n * dropWhile([1, 2, 10, 3, 4], x => x < 10) // => [10, 3, 4]\n * @dataFirst\n * @category Array\n */\nexport function dropWhile<T extends IterableContainer>(\n data: T,\n predicate: (item: T[number], index: number, data: T) => boolean,\n): T[number][];\n\n/**\n * Removes elements from the beginning of the array until the predicate returns false.\n *\n * The predicate is applied to each element in the array, until the predicate returns false. The returned array includes the rest of the elements, starting with the element that produced false for the predicate.\n *\n * @param predicate - The predicate.\n * @signature\n * dropWhile(predicate)(data)\n * @example\n * pipe([1, 2, 10, 3, 4], dropWhile(x => x < 10)) // => [10, 3, 4]\n * @dataLast\n * @category Array\n */\nexport function dropWhile<T extends IterableContainer>(\n predicate: (item: T[number], index: number, data: T) => boolean,\n): (data: T) => T[number][];\n\nexport function dropWhile(...args: readonly unknown[]): unknown {\n return purry(dropWhileImplementation, args);\n}\n\nfunction dropWhileImplementation<T extends IterableContainer>(\n data: T,\n predicate: (item: T[number], index: number, data: T) => boolean,\n): T[number][] {\n for (const [index, item] of data.entries()) {\n if (!predicate(item, index, data)) {\n return data.slice(index);\n }\n }\n return [];\n}\n"],"mappings":"mCAuCA,SAAgB,EAAU,GAAG,EAAmC,CAC9D,OAAO,EAAM,EAAyB,EAAK,CAG7C,SAAS,EACP,EACA,EACa,CACb,IAAK,GAAM,CAAC,EAAO,KAAS,EAAK,SAAS,CACxC,GAAI,CAAC,EAAU,EAAM,EAAO,EAAK,CAC/B,OAAO,EAAK,MAAM,EAAM,CAG5B,MAAO,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endsWith.cjs","names":["purry"],"sources":["../src/endsWith.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Determines whether a string ends with the provided suffix, and refines the\n * output type if possible.\n *\n * This function is a wrapper around the built-in [`String.prototype.endsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)\n * method, but doesn't expose the `endPosition` parameter. To check only up to a\n * specific position, use `endsWith(sliceString(data, 0, endPosition), suffix)`.\n *\n * @param data - The input string.\n * @param suffix - The string to check for at the end.\n * @signature\n * endsWith(data, suffix);\n * @example\n * endsWith(\"hello world\", \"hello\"); // false\n * endsWith(\"hello world\", \"world\"); // true\n * @dataFirst\n * @category String\n */\nexport function endsWith<T extends string, Suffix extends string>(\n data: T,\n suffix: string extends Suffix ? never : Suffix,\n): data is T & `${string}${Suffix}`;\nexport function endsWith(data: string, suffix: string): boolean;\n\n/**\n * Determines whether a string ends with the provided suffix, and refines the\n * output type if possible.\n *\n * This function is a wrapper around the built-in [`String.prototype.endsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)\n * method, but doesn't expose the `endPosition` parameter. To check only up to a\n * specific position, use `endsWith(sliceString(data, 0, endPosition), suffix)`.\n *\n * @param suffix - The string to check for at the end.\n * @signature\n * endsWith(suffix)(data);\n * @example\n * pipe(\"hello world\", endsWith(\"hello\")); // false\n * pipe(\"hello world\", endsWith(\"world\")); // true\n * @dataLast\n * @category String\n */\nexport function endsWith<Suffix extends string>(\n suffix: string extends Suffix ? never : Suffix,\n): <T extends string>(data: T) => data is T & `${string}${Suffix}`;\nexport function endsWith(suffix: string): (data: string) => boolean;\n\nexport function endsWith(...args: readonly unknown[]): unknown {\n return purry(endsWithImplementation, args);\n}\n\nconst endsWithImplementation = (data: string, suffix: string): boolean =>\n data.endsWith(suffix);\n"],"mappings":"kGAgDA,SAAgB,EAAS,GAAG,EAAmC,CAC7D,OAAOA,EAAAA,MAAM,EAAwB,EAAK,CAG5C,MAAM,GAA0B,EAAc,IAC5C,EAAK,SAAS,EAAO"}
|
package/dist/endsWith.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endsWith.js","names":[],"sources":["../src/endsWith.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Determines whether a string ends with the provided suffix, and refines the\n * output type if possible.\n *\n * This function is a wrapper around the built-in [`String.prototype.endsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)\n * method, but doesn't expose the `endPosition` parameter. To check only up to a\n * specific position, use `endsWith(sliceString(data, 0, endPosition), suffix)`.\n *\n * @param data - The input string.\n * @param suffix - The string to check for at the end.\n * @signature\n * endsWith(data, suffix);\n * @example\n * endsWith(\"hello world\", \"hello\"); // false\n * endsWith(\"hello world\", \"world\"); // true\n * @dataFirst\n * @category String\n */\nexport function endsWith<T extends string, Suffix extends string>(\n data: T,\n suffix: string extends Suffix ? never : Suffix,\n): data is T & `${string}${Suffix}`;\nexport function endsWith(data: string, suffix: string): boolean;\n\n/**\n * Determines whether a string ends with the provided suffix, and refines the\n * output type if possible.\n *\n * This function is a wrapper around the built-in [`String.prototype.endsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)\n * method, but doesn't expose the `endPosition` parameter. To check only up to a\n * specific position, use `endsWith(sliceString(data, 0, endPosition), suffix)`.\n *\n * @param suffix - The string to check for at the end.\n * @signature\n * endsWith(suffix)(data);\n * @example\n * pipe(\"hello world\", endsWith(\"hello\")); // false\n * pipe(\"hello world\", endsWith(\"world\")); // true\n * @dataLast\n * @category String\n */\nexport function endsWith<Suffix extends string>(\n suffix: string extends Suffix ? never : Suffix,\n): <T extends string>(data: T) => data is T & `${string}${Suffix}`;\nexport function endsWith(suffix: string): (data: string) => boolean;\n\nexport function endsWith(...args: readonly unknown[]): unknown {\n return purry(endsWithImplementation, args);\n}\n\nconst endsWithImplementation = (data: string, suffix: string): boolean =>\n data.endsWith(suffix);\n"],"mappings":"mCAgDA,SAAgB,EAAS,GAAG,EAAmC,CAC7D,OAAO,EAAM,EAAwB,EAAK,CAG5C,MAAM,GAA0B,EAAc,IAC5C,EAAK,SAAS,EAAO"}
|
package/dist/entries.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entries.cjs","names":["purry"],"sources":["../src/entries.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-object-type --\n * We want to match the typing of the built-in Object.entries as much as\n * possible!\n */\nimport type { Simplify, ValueOf } from \"type-fest\";\nimport { purry } from \"./purry\";\nimport type { ToString } from \"./internal/types/ToString\";\n\ntype Entry<T> = Simplify<\n ValueOf<{\n // `Object.entries` only returns enumerable keys, skipping symbols.\n [P in Exclude<keyof T, symbol>]-?: [\n // and all keys are converted to strings.\n key: ToString<P>,\n // Optionality doesn't play a factor in the result of entries because its\n // a typing thing, not a runtime thing. We need to remove any `undefined`\n // added just because the prop is optional.\n value: Required<T>[P],\n ];\n }>\n>;\n\n/**\n * Returns an array of key/values of the enumerable properties of an object.\n *\n * @param data - Object to return keys and values of.\n * @signature\n * entries(object)\n * @example\n * entries({ a: 1, b: 2, c: 3 }); // => [['a', 1], ['b', 2], ['c', 3]]\n * @dataFirst\n * @category Object\n */\nexport function entries<T extends {}>(data: T): Entry<T>[];\n\n/**\n * Returns an array of key/values of the enumerable properties of an object.\n *\n * @signature\n * entries()(object)\n * @example\n * pipe({ a: 1, b: 2, c: 3 }, entries()); // => [['a', 1], ['b', 2], ['c', 3]]\n * @dataLast\n * @category Object\n */\nexport function entries(): <T extends {}>(data: T) => Entry<T>[];\n\nexport function entries(...args: readonly unknown[]): unknown {\n return purry(Object.entries, args);\n}\n"],"mappings":"kGA+CA,SAAgB,EAAQ,GAAG,EAAmC,CAC5D,OAAOA,EAAAA,MAAM,OAAO,QAAS,EAAK"}
|
package/dist/entries.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entries.js","names":[],"sources":["../src/entries.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-object-type --\n * We want to match the typing of the built-in Object.entries as much as\n * possible!\n */\nimport type { Simplify, ValueOf } from \"type-fest\";\nimport { purry } from \"./purry\";\nimport type { ToString } from \"./internal/types/ToString\";\n\ntype Entry<T> = Simplify<\n ValueOf<{\n // `Object.entries` only returns enumerable keys, skipping symbols.\n [P in Exclude<keyof T, symbol>]-?: [\n // and all keys are converted to strings.\n key: ToString<P>,\n // Optionality doesn't play a factor in the result of entries because its\n // a typing thing, not a runtime thing. We need to remove any `undefined`\n // added just because the prop is optional.\n value: Required<T>[P],\n ];\n }>\n>;\n\n/**\n * Returns an array of key/values of the enumerable properties of an object.\n *\n * @param data - Object to return keys and values of.\n * @signature\n * entries(object)\n * @example\n * entries({ a: 1, b: 2, c: 3 }); // => [['a', 1], ['b', 2], ['c', 3]]\n * @dataFirst\n * @category Object\n */\nexport function entries<T extends {}>(data: T): Entry<T>[];\n\n/**\n * Returns an array of key/values of the enumerable properties of an object.\n *\n * @signature\n * entries()(object)\n * @example\n * pipe({ a: 1, b: 2, c: 3 }, entries()); // => [['a', 1], ['b', 2], ['c', 3]]\n * @dataLast\n * @category Object\n */\nexport function entries(): <T extends {}>(data: T) => Entry<T>[];\n\nexport function entries(...args: readonly unknown[]): unknown {\n return purry(Object.entries, args);\n}\n"],"mappings":"mCA+CA,SAAgB,EAAQ,GAAG,EAAmC,CAC5D,OAAO,EAAM,OAAO,QAAS,EAAK"}
|
package/dist/evolve.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){if(typeof e!=`object`||!e)return e;let r={...e};for(let[e,i]of Object.entries(t))e in r&&(r[e]=typeof i==`function`?i(r[e]):n(r[e],i));return r}exports.evolve=t;
|
|
2
|
+
//# sourceMappingURL=evolve.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evolve.cjs","names":["purry"],"sources":["../src/evolve.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\n/**\n * Basic structure of `evolver` parameter of the function `evolve`.\n */\ntype GenericEvolver = {\n readonly [P in string]: GenericEvolver | ((data: unknown) => unknown);\n};\n\n/**\n * Creates an assumed `evolver` type from the type of `data` argument.\n *\n * @example\n * interface Data {\n * id: number;\n * quartile: number[];\n * time?: { elapsed: number; remaining?: number };\n * }\n * type Nested = Evolver<Data>; // => type Nested = {\n * // id?: ((data: number) => unknown) | undefined;\n * // quartile?: ((data: number[]) => unknown) | undefined;\n * // time?:\n * // | ((data: { elapsed: number; remaining?: number | undefined }) => unknown)\n * // | {\n * // elapsed?: ((data: number) => unknown) | undefined;\n * // remaining?: ((data: number) => unknown) | undefined;\n * // }\n * // | undefined;\n * // };\n */\ntype Evolver<T> = T extends object\n ? T extends IterableContainer\n ? never\n : {\n readonly [K in keyof T]?: K extends symbol\n ? never\n : Evolver<T[K]> | ((data: Required<T>[K]) => unknown);\n }\n : never;\n\n/**\n * Creates return type from the type of arguments of `evolve`.\n */\ntype Evolved<T, E> = T extends object\n ? {\n -readonly [K in keyof T]: K extends keyof E\n ? E[K] extends (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Functions aren't inferred correctly when using `unknown` for the params.\n ...arg: any\n ) => infer R\n ? R\n : Evolved<T[K], E[K]>\n : Required<T>[K];\n }\n : T;\n\n/**\n * Creates a new object by applying functions that is included in `evolver` object parameter\n * to the `data` object parameter according to their corresponding path.\n *\n * Functions included in `evolver` object will not be invoked\n * if its corresponding key does not exist in the `data` object.\n * Also, values included in `data` object will be kept as is\n * if its corresponding key does not exist in the `evolver` object.\n *\n * @param object - Object whose value is applied to the corresponding function\n * that is defined in `evolver` at the same path.\n * @param evolver - Object that include functions that is applied to\n * the corresponding value of `data` object at the same path.\n * @signature\n * evolve(data, evolver)\n * @example\n * const evolver = {\n * count: add(1),\n * time: { elapsed: add(1), remaining: add(-1) },\n * };\n * const data = {\n * id: 10,\n * count: 10,\n * time: { elapsed: 100, remaining: 1400 },\n * };\n * evolve(data, evolver)\n * // => {\n * // id: 10,\n * // count: 11,\n * // time: { elapsed: 101, remaining: 1399 },\n * // }\n * @dataFirst\n * @category Object\n */\nexport function evolve<T extends object, E extends Evolver<T>>(\n object: T,\n evolver: E,\n): Evolved<T, E>;\n\n/**\n * Creates a new object by applying functions that is included in `evolver` object parameter\n * to the `data` object parameter according to their corresponding path.\n *\n * Functions included in `evolver` object will not be invoked\n * if its corresponding key does not exist in the `data` object.\n * Also, values included in `data` object will not be used\n * if its corresponding key does not exist in the `evolver` object.\n *\n * @param evolver - Object that include functions that is applied to\n * the corresponding value of `data` object at the same path.\n * @signature\n * evolve(evolver)(data)\n * @example\n * const evolver = {\n * count: add(1),\n * time: { elapsed: add(1), remaining: add(-1) },\n * };\n * const data = {\n * id: 10,\n * count: 10,\n * time: { elapsed: 100, remaining: 1400 },\n * };\n * pipe(data, evolve(evolver))\n * // => {\n * // id: 10,\n * // count: 11,\n * // time: { elapsed: 101, remaining: 1399 },\n * // }\n * @dataLast\n * @category Object\n */\nexport function evolve<T extends object, E extends Evolver<T>>(\n evolver: E,\n): (object: T) => Evolved<T, E>;\n\nexport function evolve(...args: readonly unknown[]): unknown {\n return purry(evolveImplementation, args);\n}\n\nfunction evolveImplementation(data: unknown, evolver: GenericEvolver): unknown {\n if (typeof data !== \"object\" || data === null) {\n return data;\n }\n\n const out: Record<string, unknown> = { ...data };\n\n for (const [key, value] of Object.entries(evolver)) {\n if (key in out) {\n out[key] =\n typeof value === \"function\"\n ? value(out[key])\n : evolveImplementation(out[key], value);\n }\n }\n\n return out;\n}\n"],"mappings":"kGAoIA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAOA,EAAAA,MAAM,EAAsB,EAAK,CAG1C,SAAS,EAAqB,EAAe,EAAkC,CAC7E,GAAI,OAAO,GAAS,WAAY,EAC9B,OAAO,EAGT,IAAM,EAA+B,CAAE,GAAG,EAAM,CAEhD,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAQ,CAC5C,KAAO,IACT,EAAI,GACF,OAAO,GAAU,WACb,EAAM,EAAI,GAAK,CACf,EAAqB,EAAI,GAAM,EAAM,EAI/C,OAAO"}
|
package/dist/evolve.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){if(typeof e!=`object`||!e)return e;let r={...e};for(let[e,i]of Object.entries(t))e in r&&(r[e]=typeof i==`function`?i(r[e]):n(r[e],i));return r}export{t as evolve};
|
|
2
|
+
//# sourceMappingURL=evolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evolve.js","names":[],"sources":["../src/evolve.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\n/**\n * Basic structure of `evolver` parameter of the function `evolve`.\n */\ntype GenericEvolver = {\n readonly [P in string]: GenericEvolver | ((data: unknown) => unknown);\n};\n\n/**\n * Creates an assumed `evolver` type from the type of `data` argument.\n *\n * @example\n * interface Data {\n * id: number;\n * quartile: number[];\n * time?: { elapsed: number; remaining?: number };\n * }\n * type Nested = Evolver<Data>; // => type Nested = {\n * // id?: ((data: number) => unknown) | undefined;\n * // quartile?: ((data: number[]) => unknown) | undefined;\n * // time?:\n * // | ((data: { elapsed: number; remaining?: number | undefined }) => unknown)\n * // | {\n * // elapsed?: ((data: number) => unknown) | undefined;\n * // remaining?: ((data: number) => unknown) | undefined;\n * // }\n * // | undefined;\n * // };\n */\ntype Evolver<T> = T extends object\n ? T extends IterableContainer\n ? never\n : {\n readonly [K in keyof T]?: K extends symbol\n ? never\n : Evolver<T[K]> | ((data: Required<T>[K]) => unknown);\n }\n : never;\n\n/**\n * Creates return type from the type of arguments of `evolve`.\n */\ntype Evolved<T, E> = T extends object\n ? {\n -readonly [K in keyof T]: K extends keyof E\n ? E[K] extends (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Functions aren't inferred correctly when using `unknown` for the params.\n ...arg: any\n ) => infer R\n ? R\n : Evolved<T[K], E[K]>\n : Required<T>[K];\n }\n : T;\n\n/**\n * Creates a new object by applying functions that is included in `evolver` object parameter\n * to the `data` object parameter according to their corresponding path.\n *\n * Functions included in `evolver` object will not be invoked\n * if its corresponding key does not exist in the `data` object.\n * Also, values included in `data` object will be kept as is\n * if its corresponding key does not exist in the `evolver` object.\n *\n * @param object - Object whose value is applied to the corresponding function\n * that is defined in `evolver` at the same path.\n * @param evolver - Object that include functions that is applied to\n * the corresponding value of `data` object at the same path.\n * @signature\n * evolve(data, evolver)\n * @example\n * const evolver = {\n * count: add(1),\n * time: { elapsed: add(1), remaining: add(-1) },\n * };\n * const data = {\n * id: 10,\n * count: 10,\n * time: { elapsed: 100, remaining: 1400 },\n * };\n * evolve(data, evolver)\n * // => {\n * // id: 10,\n * // count: 11,\n * // time: { elapsed: 101, remaining: 1399 },\n * // }\n * @dataFirst\n * @category Object\n */\nexport function evolve<T extends object, E extends Evolver<T>>(\n object: T,\n evolver: E,\n): Evolved<T, E>;\n\n/**\n * Creates a new object by applying functions that is included in `evolver` object parameter\n * to the `data` object parameter according to their corresponding path.\n *\n * Functions included in `evolver` object will not be invoked\n * if its corresponding key does not exist in the `data` object.\n * Also, values included in `data` object will not be used\n * if its corresponding key does not exist in the `evolver` object.\n *\n * @param evolver - Object that include functions that is applied to\n * the corresponding value of `data` object at the same path.\n * @signature\n * evolve(evolver)(data)\n * @example\n * const evolver = {\n * count: add(1),\n * time: { elapsed: add(1), remaining: add(-1) },\n * };\n * const data = {\n * id: 10,\n * count: 10,\n * time: { elapsed: 100, remaining: 1400 },\n * };\n * pipe(data, evolve(evolver))\n * // => {\n * // id: 10,\n * // count: 11,\n * // time: { elapsed: 101, remaining: 1399 },\n * // }\n * @dataLast\n * @category Object\n */\nexport function evolve<T extends object, E extends Evolver<T>>(\n evolver: E,\n): (object: T) => Evolved<T, E>;\n\nexport function evolve(...args: readonly unknown[]): unknown {\n return purry(evolveImplementation, args);\n}\n\nfunction evolveImplementation(data: unknown, evolver: GenericEvolver): unknown {\n if (typeof data !== \"object\" || data === null) {\n return data;\n }\n\n const out: Record<string, unknown> = { ...data };\n\n for (const [key, value] of Object.entries(evolver)) {\n if (key in out) {\n out[key] =\n typeof value === \"function\"\n ? value(out[key])\n : evolveImplementation(out[key], value);\n }\n }\n\n return out;\n}\n"],"mappings":"mCAoIA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAO,EAAM,EAAsB,EAAK,CAG1C,SAAS,EAAqB,EAAe,EAAkC,CAC7E,GAAI,OAAO,GAAS,WAAY,EAC9B,OAAO,EAGT,IAAM,EAA+B,CAAE,GAAG,EAAM,CAEhD,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAQ,CAC5C,KAAO,IACT,EAAI,GACF,OAAO,GAAU,WACb,EAAM,EAAI,GAAK,CACf,EAAqB,EAAI,GAAM,EAAM,EAI/C,OAAO"}
|
package/dist/filter.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`),t=require(`./utilityEvaluators-CW0M8vMV.cjs`);function n(...t){return e.purry(r,t,i)}const r=(e,t)=>e.filter(t),i=e=>(n,r,i)=>e(n,r,i)?{done:!1,hasNext:!0,next:n}:t.t;exports.filter=n;
|
|
2
|
+
//# sourceMappingURL=filter.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.cjs","names":["purry","SKIP_ITEM"],"sources":["../src/filter.ts"],"sourcesContent":["import type { Writable } from \"type-fest\";\nimport type { FilteredArray } from \"./internal/types/FilteredArray\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport { SKIP_ITEM } from \"./internal/utilityEvaluators\";\nimport { purry } from \"./purry\";\n\n// When the predicate used for filter isn't refining (like a type-predicate) we\n// can narrow the result slightly if it's also trivial (it returns the same\n// result for all items). This is uncommon, but can be useful to \"short-circuit\"\n// the filter.\ntype NonRefinedFilteredArray<\n T extends IterableContainer,\n IsItemIncluded extends boolean,\n> = boolean extends IsItemIncluded\n ? // We don't know which items of the array the predicate would allow in the\n // output so we can only safely say that the result is an array with items\n // from the input array.\n // TODO: Theoretically we could build an output shape that would take into account the **order** of elements in the input array by reconstructing it with every single element in it either included or not, but this type can grow to a union of as much as 2^n options which might not be usable in practice.\n T[number][]\n : IsItemIncluded extends true\n ? // If the predicate is always true we return a shallow copy of the array.\n // If it was originally readonly we need to strip that away.\n Writable<T>\n : // If the predicate is always false we will always return an empty\n // array.\n [];\n\n/**\n * Creates a shallow copy of a portion of a given array, filtered down to just\n * the elements from the given array that pass the test implemented by the\n * provided function. Equivalent to `Array.prototype.filter`.\n *\n * @param data - The array to filter.\n * @param predicate - A function to execute for each element in the array. It\n * should return `true` to keep the element in the resulting array, and `false`\n * otherwise. A type-predicate can also be used to narrow the result.\n * @returns A shallow copy of the given array containing just the elements that\n * pass the test. If no elements pass the test, an empty array is returned.\n * @signature\n * filter(data, predicate)\n * @example\n * filter([1, 2, 3], x => x % 2 === 1) // => [1, 3]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function filter<\n T extends IterableContainer,\n Condition extends T[number],\n>(\n data: T,\n predicate: (value: T[number], index: number, data: T) => value is Condition,\n): FilteredArray<T, Condition>;\nexport function filter<\n T extends IterableContainer,\n IsItemIncluded extends boolean,\n>(\n data: T,\n predicate: (value: T[number], index: number, data: T) => IsItemIncluded,\n): NonRefinedFilteredArray<T, IsItemIncluded>;\n\n/**\n * Creates a shallow copy of a portion of a given array, filtered down to just\n * the elements from the given array that pass the test implemented by the\n * provided function. Equivalent to `Array.prototype.filter`.\n *\n * @param predicate - A function to execute for each element in the array. It\n * should return `true` to keep the element in the resulting array, and `false`\n * otherwise.\n * @returns A shallow copy of the given array containing just the elements that\n * pass the test. If no elements pass the test, an empty array is returned.\n * @signature\n * filter(predicate)(data)\n * @example\n * pipe([1, 2, 3], filter(x => x % 2 === 1)) // => [1, 3]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function filter<\n T extends IterableContainer,\n Condition extends T[number],\n>(\n predicate: (value: T[number], index: number, data: T) => value is Condition,\n): (data: T) => FilteredArray<T, Condition>;\nexport function filter<\n T extends IterableContainer,\n IsItemIncluded extends boolean,\n>(\n predicate: (value: T[number], index: number, data: T) => IsItemIncluded,\n): (data: T) => NonRefinedFilteredArray<T, IsItemIncluded>;\n\nexport function filter(...args: readonly unknown[]): unknown {\n return purry(filterImplementation, args, lazyImplementation);\n}\n\nconst filterImplementation = <T>(\n data: readonly T[],\n predicate: (value: T, index: number, array: readonly T[]) => boolean,\n): T[] => data.filter(predicate);\n\nconst lazyImplementation =\n <T>(\n predicate: (value: T, index: number, data: readonly T[]) => boolean,\n ): LazyEvaluator<T> =>\n (value, index, data) =>\n predicate(value, index, data)\n ? { done: false, hasNext: true, next: value }\n : SKIP_ITEM;\n"],"mappings":"gJA6FA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAOA,EAAAA,MAAM,EAAsB,EAAM,EAAmB,CAG9D,MAAM,GACJ,EACA,IACQ,EAAK,OAAO,EAAU,CAE1B,EAEF,IAED,EAAO,EAAO,IACb,EAAU,EAAO,EAAO,EAAK,CACzB,CAAE,KAAM,GAAO,QAAS,GAAM,KAAM,EAAO,CAC3CC,EAAAA"}
|
package/dist/filter.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.js","names":[],"sources":["../src/filter.ts"],"sourcesContent":["import type { Writable } from \"type-fest\";\nimport type { FilteredArray } from \"./internal/types/FilteredArray\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport { SKIP_ITEM } from \"./internal/utilityEvaluators\";\nimport { purry } from \"./purry\";\n\n// When the predicate used for filter isn't refining (like a type-predicate) we\n// can narrow the result slightly if it's also trivial (it returns the same\n// result for all items). This is uncommon, but can be useful to \"short-circuit\"\n// the filter.\ntype NonRefinedFilteredArray<\n T extends IterableContainer,\n IsItemIncluded extends boolean,\n> = boolean extends IsItemIncluded\n ? // We don't know which items of the array the predicate would allow in the\n // output so we can only safely say that the result is an array with items\n // from the input array.\n // TODO: Theoretically we could build an output shape that would take into account the **order** of elements in the input array by reconstructing it with every single element in it either included or not, but this type can grow to a union of as much as 2^n options which might not be usable in practice.\n T[number][]\n : IsItemIncluded extends true\n ? // If the predicate is always true we return a shallow copy of the array.\n // If it was originally readonly we need to strip that away.\n Writable<T>\n : // If the predicate is always false we will always return an empty\n // array.\n [];\n\n/**\n * Creates a shallow copy of a portion of a given array, filtered down to just\n * the elements from the given array that pass the test implemented by the\n * provided function. Equivalent to `Array.prototype.filter`.\n *\n * @param data - The array to filter.\n * @param predicate - A function to execute for each element in the array. It\n * should return `true` to keep the element in the resulting array, and `false`\n * otherwise. A type-predicate can also be used to narrow the result.\n * @returns A shallow copy of the given array containing just the elements that\n * pass the test. If no elements pass the test, an empty array is returned.\n * @signature\n * filter(data, predicate)\n * @example\n * filter([1, 2, 3], x => x % 2 === 1) // => [1, 3]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function filter<\n T extends IterableContainer,\n Condition extends T[number],\n>(\n data: T,\n predicate: (value: T[number], index: number, data: T) => value is Condition,\n): FilteredArray<T, Condition>;\nexport function filter<\n T extends IterableContainer,\n IsItemIncluded extends boolean,\n>(\n data: T,\n predicate: (value: T[number], index: number, data: T) => IsItemIncluded,\n): NonRefinedFilteredArray<T, IsItemIncluded>;\n\n/**\n * Creates a shallow copy of a portion of a given array, filtered down to just\n * the elements from the given array that pass the test implemented by the\n * provided function. Equivalent to `Array.prototype.filter`.\n *\n * @param predicate - A function to execute for each element in the array. It\n * should return `true` to keep the element in the resulting array, and `false`\n * otherwise.\n * @returns A shallow copy of the given array containing just the elements that\n * pass the test. If no elements pass the test, an empty array is returned.\n * @signature\n * filter(predicate)(data)\n * @example\n * pipe([1, 2, 3], filter(x => x % 2 === 1)) // => [1, 3]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function filter<\n T extends IterableContainer,\n Condition extends T[number],\n>(\n predicate: (value: T[number], index: number, data: T) => value is Condition,\n): (data: T) => FilteredArray<T, Condition>;\nexport function filter<\n T extends IterableContainer,\n IsItemIncluded extends boolean,\n>(\n predicate: (value: T[number], index: number, data: T) => IsItemIncluded,\n): (data: T) => NonRefinedFilteredArray<T, IsItemIncluded>;\n\nexport function filter(...args: readonly unknown[]): unknown {\n return purry(filterImplementation, args, lazyImplementation);\n}\n\nconst filterImplementation = <T>(\n data: readonly T[],\n predicate: (value: T, index: number, array: readonly T[]) => boolean,\n): T[] => data.filter(predicate);\n\nconst lazyImplementation =\n <T>(\n predicate: (value: T, index: number, data: readonly T[]) => boolean,\n ): LazyEvaluator<T> =>\n (value, index, data) =>\n predicate(value, index, data)\n ? { done: false, hasNext: true, next: value }\n : SKIP_ITEM;\n"],"mappings":"kFA6FA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAO,EAAM,EAAsB,EAAM,EAAmB,CAG9D,MAAM,GACJ,EACA,IACQ,EAAK,OAAO,EAAU,CAE1B,EAEF,IAED,EAAO,EAAO,IACb,EAAU,EAAO,EAAO,EAAK,CACzB,CAAE,KAAM,GAAO,QAAS,GAAM,KAAM,EAAO,CAC3C"}
|
package/dist/find.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`),t=require(`./utilityEvaluators-CW0M8vMV.cjs`),n=require(`./toSingle-z9yHVHGr.cjs`);function r(...t){return e.purry(i,t,n.t(a))}const i=(e,t)=>e.find(t),a=e=>(n,r,i)=>e(n,r,i)?{done:!0,hasNext:!0,next:n}:t.t;exports.find=r;
|
|
2
|
+
//# sourceMappingURL=find.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.cjs","names":["purry","toSingle","SKIP_ITEM"],"sources":["../src/find.ts"],"sourcesContent":["import { toSingle } from \"./internal/toSingle\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport { SKIP_ITEM } from \"./internal/utilityEvaluators\";\nimport { purry } from \"./purry\";\n\n/**\n * Returns the first element in the provided array that satisfies the provided\n * testing function. If no values satisfy the testing function, `undefined` is\n * returned.\n *\n * Similar functions:\n * * `findLast` - If you need the last element that satisfies the provided testing function.\n * * `findIndex` - If you need the index of the found element in the array.\n * * `indexOf` - If you need to find the index of a value.\n * * `includes` - If you need to find if a value exists in an array.\n * * `some` - If you need to find if any element satisfies the provided testing function.\n * * `filter` - If you need to find all elements that satisfy the provided testing function.\n *\n * @param data - The items to search in.\n * @param predicate - A function to execute for each element in the array. It\n * should return `true` to indicate a matching element has been found, and\n * `false` otherwise. A type-predicate can also be used to narrow the result.\n * @returns The first element in the array that satisfies the provided testing\n * function. Otherwise, `undefined` is returned.\n * @signature\n * find(data, predicate)\n * @example\n * find([1, 3, 4, 6], n => n % 2 === 0) // => 4\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function find<T, S extends T>(\n data: readonly T[],\n predicate: (value: T, index: number, data: readonly T[]) => value is S,\n): S | undefined;\nexport function find<T>(\n data: readonly T[],\n predicate: (value: T, index: number, data: readonly T[]) => boolean,\n): T | undefined;\n\n/**\n * Returns the first element in the provided array that satisfies the provided\n * testing function. If no values satisfy the testing function, `undefined` is\n * returned.\n *\n * Similar functions:\n * * `findLast` - If you need the last element that satisfies the provided testing function.\n * * `findIndex` - If you need the index of the found element in the array.\n * * `indexOf` - If you need to find the index of a value.\n * * `includes` - If you need to find if a value exists in an array.\n * * `some` - If you need to find if any element satisfies the provided testing function.\n * * `filter` - If you need to find all elements that satisfy the provided testing function.\n *\n * @param predicate - A function to execute for each element in the array. It\n * should return `true` to indicate a matching element has been found, and\n * `false` otherwise. A type-predicate can also be used to narrow the result.\n * @returns The first element in the array that satisfies the provided testing\n * function. Otherwise, `undefined` is returned.\n * @signature\n * find(predicate)(data)\n * @example\n * pipe(\n * [1, 3, 4, 6],\n * find(n => n % 2 === 0)\n * ) // => 4\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function find<T, S extends T>(\n predicate: (value: T, index: number, data: readonly T[]) => value is S,\n): (data: readonly T[]) => S | undefined;\nexport function find<T>(\n predicate: (value: T, index: number, data: readonly T[]) => boolean,\n): (data: readonly T[]) => T | undefined;\n\nexport function find(...args: readonly unknown[]): unknown {\n return purry(findImplementation, args, toSingle(lazyImplementation));\n}\n\nconst findImplementation = <T, S extends T>(\n data: readonly T[],\n predicate: (value: T, index: number, data: readonly T[]) => value is S,\n): S | undefined => data.find(predicate);\n\nconst lazyImplementation =\n <T, S extends T>(\n predicate: (value: T, index: number, data: readonly T[]) => value is S,\n ): LazyEvaluator<T, S> =>\n (value, index, data) =>\n predicate(value, index, data)\n ? { done: true, hasNext: true, next: value }\n : SKIP_ITEM;\n"],"mappings":"qLA6EA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAOA,EAAAA,MAAM,EAAoB,EAAMC,EAAAA,EAAS,EAAmB,CAAC,CAGtE,MAAM,GACJ,EACA,IACkB,EAAK,KAAK,EAAU,CAElC,EAEF,IAED,EAAO,EAAO,IACb,EAAU,EAAO,EAAO,EAAK,CACzB,CAAE,KAAM,GAAM,QAAS,GAAM,KAAM,EAAO,CAC1CC,EAAAA"}
|
package/dist/find.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{purry as e}from"./purry.js";import{t}from"./utilityEvaluators-BQqW5Ir5.js";import{t as n}from"./toSingle-qs9PC5sP.js";function r(...t){return e(i,t,n(a))}const i=(e,t)=>e.find(t),a=e=>(n,r,i)=>e(n,r,i)?{done:!0,hasNext:!0,next:n}:t;export{r as find};
|
|
2
|
+
//# sourceMappingURL=find.js.map
|
package/dist/find.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.js","names":[],"sources":["../src/find.ts"],"sourcesContent":["import { toSingle } from \"./internal/toSingle\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport { SKIP_ITEM } from \"./internal/utilityEvaluators\";\nimport { purry } from \"./purry\";\n\n/**\n * Returns the first element in the provided array that satisfies the provided\n * testing function. If no values satisfy the testing function, `undefined` is\n * returned.\n *\n * Similar functions:\n * * `findLast` - If you need the last element that satisfies the provided testing function.\n * * `findIndex` - If you need the index of the found element in the array.\n * * `indexOf` - If you need to find the index of a value.\n * * `includes` - If you need to find if a value exists in an array.\n * * `some` - If you need to find if any element satisfies the provided testing function.\n * * `filter` - If you need to find all elements that satisfy the provided testing function.\n *\n * @param data - The items to search in.\n * @param predicate - A function to execute for each element in the array. It\n * should return `true` to indicate a matching element has been found, and\n * `false` otherwise. A type-predicate can also be used to narrow the result.\n * @returns The first element in the array that satisfies the provided testing\n * function. Otherwise, `undefined` is returned.\n * @signature\n * find(data, predicate)\n * @example\n * find([1, 3, 4, 6], n => n % 2 === 0) // => 4\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function find<T, S extends T>(\n data: readonly T[],\n predicate: (value: T, index: number, data: readonly T[]) => value is S,\n): S | undefined;\nexport function find<T>(\n data: readonly T[],\n predicate: (value: T, index: number, data: readonly T[]) => boolean,\n): T | undefined;\n\n/**\n * Returns the first element in the provided array that satisfies the provided\n * testing function. If no values satisfy the testing function, `undefined` is\n * returned.\n *\n * Similar functions:\n * * `findLast` - If you need the last element that satisfies the provided testing function.\n * * `findIndex` - If you need the index of the found element in the array.\n * * `indexOf` - If you need to find the index of a value.\n * * `includes` - If you need to find if a value exists in an array.\n * * `some` - If you need to find if any element satisfies the provided testing function.\n * * `filter` - If you need to find all elements that satisfy the provided testing function.\n *\n * @param predicate - A function to execute for each element in the array. It\n * should return `true` to indicate a matching element has been found, and\n * `false` otherwise. A type-predicate can also be used to narrow the result.\n * @returns The first element in the array that satisfies the provided testing\n * function. Otherwise, `undefined` is returned.\n * @signature\n * find(predicate)(data)\n * @example\n * pipe(\n * [1, 3, 4, 6],\n * find(n => n % 2 === 0)\n * ) // => 4\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function find<T, S extends T>(\n predicate: (value: T, index: number, data: readonly T[]) => value is S,\n): (data: readonly T[]) => S | undefined;\nexport function find<T>(\n predicate: (value: T, index: number, data: readonly T[]) => boolean,\n): (data: readonly T[]) => T | undefined;\n\nexport function find(...args: readonly unknown[]): unknown {\n return purry(findImplementation, args, toSingle(lazyImplementation));\n}\n\nconst findImplementation = <T, S extends T>(\n data: readonly T[],\n predicate: (value: T, index: number, data: readonly T[]) => value is S,\n): S | undefined => data.find(predicate);\n\nconst lazyImplementation =\n <T, S extends T>(\n predicate: (value: T, index: number, data: readonly T[]) => value is S,\n ): LazyEvaluator<T, S> =>\n (value, index, data) =>\n predicate(value, index, data)\n ? { done: true, hasNext: true, next: value }\n : SKIP_ITEM;\n"],"mappings":"6HA6EA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAO,EAAM,EAAoB,EAAM,EAAS,EAAmB,CAAC,CAGtE,MAAM,GACJ,EACA,IACkB,EAAK,KAAK,EAAU,CAElC,EAEF,IAED,EAAO,EAAO,IACb,EAAU,EAAO,EAAO,EAAK,CACzB,CAAE,KAAM,GAAM,QAAS,GAAM,KAAM,EAAO,CAC1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findIndex.cjs","names":["purry"],"sources":["../src/findIndex.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Returns the index of the first element in an array that satisfies the\n * provided testing function. If no elements satisfy the testing function, -1 is\n * returned.\n *\n * See also the `find` method, which returns the first element that satisfies\n * the testing function (rather than its index).\n *\n * @param data - The items to search in.\n * @param predicate - A function to execute for each element in the array. It\n * should return a `true` to indicate a matching element has been found, and a\n * `false` otherwise.\n * @returns The index of the first element in the array that passes the test.\n * Otherwise, -1.\n * @signature\n * findIndex(data, predicate)\n * @example\n * findIndex([1, 3, 4, 6], n => n % 2 === 0) // => 2\n * @dataFirst\n * @category Array\n */\nexport function findIndex<T>(\n data: readonly T[],\n predicate: (value: T, index: number, obj: readonly T[]) => boolean,\n): number;\n\n/**\n * Returns the index of the first element in an array that satisfies the\n * provided testing function. If no elements satisfy the testing function, -1 is\n * returned.\n *\n * See also the `find` method, which returns the first element that satisfies\n * the testing function (rather than its index).\n *\n * @param predicate - A function to execute for each element in the array. It\n * should return a `true` to indicate a matching element has been found, and a\n * `false` otherwise.\n * @returns The index of the first element in the array that passes the test.\n * Otherwise, -1.\n * @signature\n * findIndex(predicate)(data)\n * @example\n * pipe(\n * [1, 3, 4, 6],\n * findIndex(n => n % 2 === 0)\n * ); // => 2\n * @dataLast\n * @category Array\n */\nexport function findIndex<T>(\n predicate: (value: T, index: number, obj: readonly T[]) => boolean,\n): (data: readonly T[]) => number;\n\nexport function findIndex(...args: readonly unknown[]): unknown {\n return purry(findIndexImplementation, args);\n}\n\nconst findIndexImplementation = <T>(\n data: readonly T[],\n predicate: (value: T, index: number, obj: readonly T[]) => boolean,\n): number => data.findIndex(predicate);\n"],"mappings":"kGAuDA,SAAgB,EAAU,GAAG,EAAmC,CAC9D,OAAOA,EAAAA,MAAM,EAAyB,EAAK,CAG7C,MAAM,GACJ,EACA,IACW,EAAK,UAAU,EAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findIndex.js","names":[],"sources":["../src/findIndex.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Returns the index of the first element in an array that satisfies the\n * provided testing function. If no elements satisfy the testing function, -1 is\n * returned.\n *\n * See also the `find` method, which returns the first element that satisfies\n * the testing function (rather than its index).\n *\n * @param data - The items to search in.\n * @param predicate - A function to execute for each element in the array. It\n * should return a `true` to indicate a matching element has been found, and a\n * `false` otherwise.\n * @returns The index of the first element in the array that passes the test.\n * Otherwise, -1.\n * @signature\n * findIndex(data, predicate)\n * @example\n * findIndex([1, 3, 4, 6], n => n % 2 === 0) // => 2\n * @dataFirst\n * @category Array\n */\nexport function findIndex<T>(\n data: readonly T[],\n predicate: (value: T, index: number, obj: readonly T[]) => boolean,\n): number;\n\n/**\n * Returns the index of the first element in an array that satisfies the\n * provided testing function. If no elements satisfy the testing function, -1 is\n * returned.\n *\n * See also the `find` method, which returns the first element that satisfies\n * the testing function (rather than its index).\n *\n * @param predicate - A function to execute for each element in the array. It\n * should return a `true` to indicate a matching element has been found, and a\n * `false` otherwise.\n * @returns The index of the first element in the array that passes the test.\n * Otherwise, -1.\n * @signature\n * findIndex(predicate)(data)\n * @example\n * pipe(\n * [1, 3, 4, 6],\n * findIndex(n => n % 2 === 0)\n * ); // => 2\n * @dataLast\n * @category Array\n */\nexport function findIndex<T>(\n predicate: (value: T, index: number, obj: readonly T[]) => boolean,\n): (data: readonly T[]) => number;\n\nexport function findIndex(...args: readonly unknown[]): unknown {\n return purry(findIndexImplementation, args);\n}\n\nconst findIndexImplementation = <T>(\n data: readonly T[],\n predicate: (value: T, index: number, obj: readonly T[]) => boolean,\n): number => data.findIndex(predicate);\n"],"mappings":"mCAuDA,SAAgB,EAAU,GAAG,EAAmC,CAC9D,OAAO,EAAM,EAAyB,EAAK,CAG7C,MAAM,GACJ,EACA,IACW,EAAK,UAAU,EAAU"}
|