@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":"subtract.cjs","names":["purry"],"sources":["../src/subtract.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Subtracts two numbers.\n *\n * @param value - The number.\n * @param subtrahend - The number to subtract from the value.\n * @signature\n * subtract(value, subtrahend);\n * @example\n * subtract(10, 5) // => 5\n * subtract(10, -5) // => 15\n * reduce([1, 2, 3, 4], subtract, 20) // => 10\n * @dataFirst\n * @category Number\n */\nexport function subtract(value: bigint, subtrahend: bigint): bigint;\nexport function subtract(value: number, subtrahend: number): number;\n\n/**\n * Subtracts two numbers.\n *\n * @param subtrahend - The number to subtract from the value.\n * @signature\n * subtract(subtrahend)(value);\n * @example\n * subtract(5)(10) // => 5\n * subtract(-5)(10) // => 15\n * map([1, 2, 3, 4], subtract(1)) // => [0, 1, 2, 3]\n * @dataLast\n * @category Number\n */\nexport function subtract(subtrahend: bigint): (value: bigint) => bigint;\nexport function subtract(subtrahend: number): (value: number) => number;\n\nexport function subtract(...args: readonly unknown[]): unknown {\n return purry(subtractImplementation, 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 subtrahend would be of the same\n// type.\nconst subtractImplementation = (value: number, subtrahend: number): number =>\n value - subtrahend;\n"],"mappings":"kGAmCA,SAAgB,EAAS,GAAG,EAAmC,CAC7D,OAAOA,EAAAA,MAAM,EAAwB,EAAK,CAM5C,MAAM,GAA0B,EAAe,IAC7C,EAAQ"}
|
package/dist/subtract.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subtract.js","names":[],"sources":["../src/subtract.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Subtracts two numbers.\n *\n * @param value - The number.\n * @param subtrahend - The number to subtract from the value.\n * @signature\n * subtract(value, subtrahend);\n * @example\n * subtract(10, 5) // => 5\n * subtract(10, -5) // => 15\n * reduce([1, 2, 3, 4], subtract, 20) // => 10\n * @dataFirst\n * @category Number\n */\nexport function subtract(value: bigint, subtrahend: bigint): bigint;\nexport function subtract(value: number, subtrahend: number): number;\n\n/**\n * Subtracts two numbers.\n *\n * @param subtrahend - The number to subtract from the value.\n * @signature\n * subtract(subtrahend)(value);\n * @example\n * subtract(5)(10) // => 5\n * subtract(-5)(10) // => 15\n * map([1, 2, 3, 4], subtract(1)) // => [0, 1, 2, 3]\n * @dataLast\n * @category Number\n */\nexport function subtract(subtrahend: bigint): (value: bigint) => bigint;\nexport function subtract(subtrahend: number): (value: number) => number;\n\nexport function subtract(...args: readonly unknown[]): unknown {\n return purry(subtractImplementation, 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 subtrahend would be of the same\n// type.\nconst subtractImplementation = (value: number, subtrahend: number): number =>\n value - subtrahend;\n"],"mappings":"mCAmCA,SAAgB,EAAS,GAAG,EAAmC,CAC7D,OAAO,EAAM,EAAwB,EAAK,CAM5C,MAAM,GAA0B,EAAe,IAC7C,EAAQ"}
|
package/dist/sum.cjs
ADDED
package/dist/sum.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sum.cjs","names":["purry"],"sources":["../src/sum.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\ntype Sum<T extends IterableContainer<bigint> | IterableContainer<number>> =\n // Empty arrays would always result in a sum of (a non-bigint) 0.\n T extends readonly []\n ? 0\n : // Non-empty bigint arrays will always result in a bigint sum.\n T extends readonly [bigint, ...(readonly unknown[])]\n ? bigint\n : // But an empty bigint array would result in a non-bigint 0.\n T[number] extends bigint\n ? bigint | 0\n : // Non-bigint arrays are always handled correctly.\n number;\n\n/**\n * Sums the numbers in the array, or return 0 for an empty array.\n *\n * Works for both `number` and `bigint` arrays, but not arrays that contain both\n * types.\n *\n * IMPORTANT: The result for empty arrays would be 0 (`number`) regardless of\n * the type of the array; to avoid adding this to the return type for cases\n * where the array is known to be non-empty you can use `hasAtLeast` or\n * `isEmpty` to guard against this case.\n *\n * @param data - The array of numbers.\n * @signature\n * sum(data);\n * @example\n * sum([1, 2, 3]); // => 6\n * sum([1n, 2n, 3n]); // => 6n\n * sum([]); // => 0\n * @dataFirst\n * @category Number\n */\nexport function sum<\n T extends IterableContainer<bigint> | IterableContainer<number>,\n>(data: T): Sum<T>;\n\n/**\n * Sums the numbers in the array, or return 0 for an empty array.\n *\n * Works for both `number` and `bigint` arrays, but not arrays that contain both\n * types.\n *\n * IMPORTANT: The result for empty arrays would be 0 (`number`) regardless of\n * the type of the array; to avoid adding this to the return type for cases\n * where the array is known to be non-empty you can use `hasAtLeast` or\n * `isEmpty`to guard against this case.\n *\n * @signature\n * sum()(data);\n * @example\n * pipe([1, 2, 3], sum()); // => 6\n * pipe([1n, 2n, 3n], sum()); // => 6n\n * pipe([], sum()); // => 0\n * @dataLast\n * @category Number\n */\nexport function sum(): <\n T extends IterableContainer<bigint> | IterableContainer<number>,\n>(\n data: T,\n) => Sum<T>;\n\nexport function sum(...args: readonly unknown[]): unknown {\n return purry(sumImplementation, args);\n}\n\nfunction sumImplementation<\n T extends IterableContainer<bigint> | IterableContainer<number>,\n>(data: T): T[number] {\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers -- The rule differentiates 0 and 0n :(\n let out = typeof data[0] === \"bigint\" ? 0n : 0;\n for (const value of data) {\n // @ts-expect-error [ts2365] -- Typescript can't infer that all elements will be a number of the same type.\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n out += value;\n }\n return out;\n}\n"],"mappings":"kGAmEA,SAAgB,EAAI,GAAG,EAAmC,CACxD,OAAOA,EAAAA,MAAM,EAAmB,EAAK,CAGvC,SAAS,EAEP,EAAoB,CAEpB,IAAI,EAAM,OAAO,EAAK,IAAO,SAAW,GAAK,EAC7C,IAAK,IAAM,KAAS,EAGlB,GAAO,EAET,OAAO"}
|
package/dist/sum.js
ADDED
package/dist/sum.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sum.js","names":[],"sources":["../src/sum.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\ntype Sum<T extends IterableContainer<bigint> | IterableContainer<number>> =\n // Empty arrays would always result in a sum of (a non-bigint) 0.\n T extends readonly []\n ? 0\n : // Non-empty bigint arrays will always result in a bigint sum.\n T extends readonly [bigint, ...(readonly unknown[])]\n ? bigint\n : // But an empty bigint array would result in a non-bigint 0.\n T[number] extends bigint\n ? bigint | 0\n : // Non-bigint arrays are always handled correctly.\n number;\n\n/**\n * Sums the numbers in the array, or return 0 for an empty array.\n *\n * Works for both `number` and `bigint` arrays, but not arrays that contain both\n * types.\n *\n * IMPORTANT: The result for empty arrays would be 0 (`number`) regardless of\n * the type of the array; to avoid adding this to the return type for cases\n * where the array is known to be non-empty you can use `hasAtLeast` or\n * `isEmpty` to guard against this case.\n *\n * @param data - The array of numbers.\n * @signature\n * sum(data);\n * @example\n * sum([1, 2, 3]); // => 6\n * sum([1n, 2n, 3n]); // => 6n\n * sum([]); // => 0\n * @dataFirst\n * @category Number\n */\nexport function sum<\n T extends IterableContainer<bigint> | IterableContainer<number>,\n>(data: T): Sum<T>;\n\n/**\n * Sums the numbers in the array, or return 0 for an empty array.\n *\n * Works for both `number` and `bigint` arrays, but not arrays that contain both\n * types.\n *\n * IMPORTANT: The result for empty arrays would be 0 (`number`) regardless of\n * the type of the array; to avoid adding this to the return type for cases\n * where the array is known to be non-empty you can use `hasAtLeast` or\n * `isEmpty`to guard against this case.\n *\n * @signature\n * sum()(data);\n * @example\n * pipe([1, 2, 3], sum()); // => 6\n * pipe([1n, 2n, 3n], sum()); // => 6n\n * pipe([], sum()); // => 0\n * @dataLast\n * @category Number\n */\nexport function sum(): <\n T extends IterableContainer<bigint> | IterableContainer<number>,\n>(\n data: T,\n) => Sum<T>;\n\nexport function sum(...args: readonly unknown[]): unknown {\n return purry(sumImplementation, args);\n}\n\nfunction sumImplementation<\n T extends IterableContainer<bigint> | IterableContainer<number>,\n>(data: T): T[number] {\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers -- The rule differentiates 0 and 0n :(\n let out = typeof data[0] === \"bigint\" ? 0n : 0;\n for (const value of data) {\n // @ts-expect-error [ts2365] -- Typescript can't infer that all elements will be a number of the same type.\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n out += value;\n }\n return out;\n}\n"],"mappings":"mCAmEA,SAAgB,EAAI,GAAG,EAAmC,CACxD,OAAO,EAAM,EAAmB,EAAK,CAGvC,SAAS,EAEP,EAAoB,CAEpB,IAAI,EAAM,OAAO,EAAK,IAAO,SAAW,GAAK,EAC7C,IAAK,IAAM,KAAS,EAGlB,GAAO,EAET,OAAO"}
|
package/dist/sumBy.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`);function t(...t){return e.purry(n,t)}const n=(e,t)=>{let n=e.entries(),r=n.next();if(`done`in r&&r.done)return 0;let{value:[,i]}=r,a=t(i,0,e);for(let[r,i]of n){let n=t(i,r,e);a+=n}return a};exports.sumBy=t;
|
|
2
|
+
//# sourceMappingURL=sumBy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sumBy.cjs","names":["purry"],"sources":["../src/sumBy.ts"],"sourcesContent":["import { purry } from \"./purry\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\n\ntype SumBy<\n T extends IterableContainer,\n U extends bigint | number,\n> = T extends readonly []\n ? 0\n : T extends readonly [unknown, ...(readonly unknown[])]\n ? U\n : U | 0;\n\n/**\n * Returns the sum of the elements of an array using the provided mapper.\n *\n * Works for both `number` and `bigint` mappers, but not mappers that return both\n * types.\n *\n * IMPORTANT: The result for empty arrays would be 0 (`number`) regardless of\n * the type of the mapper; to avoid adding this to the return type for cases\n * where the array is known to be non-empty you can use `hasAtLeast` or\n * `isEmpty` to guard against this case.\n *\n * @param callbackfn - Predicate function.\n * @signature\n * sumBy(fn)(array)\n * @example\n * pipe(\n * [{a: 5}, {a: 1}, {a: 3}],\n * sumBy(x => x.a)\n * ) // 9\n *\n * pipe(\n * [{a: 5n}, {a: 1n}, {a: 3n}],\n * sumBy(x => x.a)\n * ) // 9n\n * @dataLast\n * @category Array\n */\nexport function sumBy<T extends IterableContainer>(\n callbackfn: (value: T[number], index: number, data: T) => number,\n): (items: T) => SumBy<T, number>;\nexport function sumBy<T extends IterableContainer>(\n callbackfn: (value: T[number], index: number, data: T) => bigint,\n): (items: T) => SumBy<T, bigint>;\n\n/**\n * Returns the sum of the elements of an array using the provided mapper.\n *\n * Works for both `number` and `bigint` mappers, but not mappers that can return both\n * types.\n *\n * IMPORTANT: The result for empty arrays would be 0 (`number`) regardless of\n * the type of the mapper; to avoid adding this to the return type for cases\n * where the array is known to be non-empty you can use `hasAtLeast` or\n * `isEmpty` to guard against this case.\n *\n * @param data - The array.\n * @param callbackfn - Predicate function.\n * @signature\n * sumBy(array, fn)\n * @example\n * sumBy(\n * [{a: 5}, {a: 1}, {a: 3}],\n * x => x.a\n * ) // 9\n * sumBy(\n * [{a: 5n}, {a: 1n}, {a: 3n}],\n * x => x.a\n * ) // 9n\n * @dataFirst\n * @category Array\n */\nexport function sumBy<T extends IterableContainer>(\n data: T,\n callbackfn: (value: T[number], index: number, data: T) => number,\n): SumBy<T, number>;\nexport function sumBy<T extends IterableContainer>(\n data: T,\n callbackfn: (value: T[number], index: number, data: T) => bigint,\n): SumBy<T, bigint>;\n\nexport function sumBy(...args: readonly unknown[]): unknown {\n return purry(sumByImplementation, args);\n}\n\nconst sumByImplementation = <T>(\n array: readonly T[],\n callbackfn: (value: T, index: number, data: readonly T[]) => bigint | number,\n): bigint | number => {\n const iter = array.entries();\n\n const firstEntry = iter.next();\n if (\"done\" in firstEntry && firstEntry.done) {\n return 0;\n }\n\n const {\n value: [, firstValue],\n } = firstEntry;\n let sum = callbackfn(firstValue, 0, array);\n for (const [index, item] of iter) {\n const summand = callbackfn(item, index, array);\n\n // @ts-expect-error [ts2365] -- Typescript can't infer that all elements will be a number of the same type.\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n sum += summand;\n }\n return sum;\n};\n"],"mappings":"kGAkFA,SAAgB,EAAM,GAAG,EAAmC,CAC1D,OAAOA,EAAAA,MAAM,EAAqB,EAAK,CAGzC,MAAM,GACJ,EACA,IACoB,CACpB,IAAM,EAAO,EAAM,SAAS,CAEtB,EAAa,EAAK,MAAM,CAC9B,GAAI,SAAU,GAAc,EAAW,KACrC,MAAO,GAGT,GAAM,CACJ,MAAO,EAAG,IACR,EACA,EAAM,EAAW,EAAY,EAAG,EAAM,CAC1C,IAAK,GAAM,CAAC,EAAO,KAAS,EAAM,CAChC,IAAM,EAAU,EAAW,EAAM,EAAO,EAAM,CAI9C,GAAO,EAET,OAAO"}
|
package/dist/sumBy.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sumBy.js","names":[],"sources":["../src/sumBy.ts"],"sourcesContent":["import { purry } from \"./purry\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\n\ntype SumBy<\n T extends IterableContainer,\n U extends bigint | number,\n> = T extends readonly []\n ? 0\n : T extends readonly [unknown, ...(readonly unknown[])]\n ? U\n : U | 0;\n\n/**\n * Returns the sum of the elements of an array using the provided mapper.\n *\n * Works for both `number` and `bigint` mappers, but not mappers that return both\n * types.\n *\n * IMPORTANT: The result for empty arrays would be 0 (`number`) regardless of\n * the type of the mapper; to avoid adding this to the return type for cases\n * where the array is known to be non-empty you can use `hasAtLeast` or\n * `isEmpty` to guard against this case.\n *\n * @param callbackfn - Predicate function.\n * @signature\n * sumBy(fn)(array)\n * @example\n * pipe(\n * [{a: 5}, {a: 1}, {a: 3}],\n * sumBy(x => x.a)\n * ) // 9\n *\n * pipe(\n * [{a: 5n}, {a: 1n}, {a: 3n}],\n * sumBy(x => x.a)\n * ) // 9n\n * @dataLast\n * @category Array\n */\nexport function sumBy<T extends IterableContainer>(\n callbackfn: (value: T[number], index: number, data: T) => number,\n): (items: T) => SumBy<T, number>;\nexport function sumBy<T extends IterableContainer>(\n callbackfn: (value: T[number], index: number, data: T) => bigint,\n): (items: T) => SumBy<T, bigint>;\n\n/**\n * Returns the sum of the elements of an array using the provided mapper.\n *\n * Works for both `number` and `bigint` mappers, but not mappers that can return both\n * types.\n *\n * IMPORTANT: The result for empty arrays would be 0 (`number`) regardless of\n * the type of the mapper; to avoid adding this to the return type for cases\n * where the array is known to be non-empty you can use `hasAtLeast` or\n * `isEmpty` to guard against this case.\n *\n * @param data - The array.\n * @param callbackfn - Predicate function.\n * @signature\n * sumBy(array, fn)\n * @example\n * sumBy(\n * [{a: 5}, {a: 1}, {a: 3}],\n * x => x.a\n * ) // 9\n * sumBy(\n * [{a: 5n}, {a: 1n}, {a: 3n}],\n * x => x.a\n * ) // 9n\n * @dataFirst\n * @category Array\n */\nexport function sumBy<T extends IterableContainer>(\n data: T,\n callbackfn: (value: T[number], index: number, data: T) => number,\n): SumBy<T, number>;\nexport function sumBy<T extends IterableContainer>(\n data: T,\n callbackfn: (value: T[number], index: number, data: T) => bigint,\n): SumBy<T, bigint>;\n\nexport function sumBy(...args: readonly unknown[]): unknown {\n return purry(sumByImplementation, args);\n}\n\nconst sumByImplementation = <T>(\n array: readonly T[],\n callbackfn: (value: T, index: number, data: readonly T[]) => bigint | number,\n): bigint | number => {\n const iter = array.entries();\n\n const firstEntry = iter.next();\n if (\"done\" in firstEntry && firstEntry.done) {\n return 0;\n }\n\n const {\n value: [, firstValue],\n } = firstEntry;\n let sum = callbackfn(firstValue, 0, array);\n for (const [index, item] of iter) {\n const summand = callbackfn(item, index, array);\n\n // @ts-expect-error [ts2365] -- Typescript can't infer that all elements will be a number of the same type.\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n sum += summand;\n }\n return sum;\n};\n"],"mappings":"mCAkFA,SAAgB,EAAM,GAAG,EAAmC,CAC1D,OAAO,EAAM,EAAqB,EAAK,CAGzC,MAAM,GACJ,EACA,IACoB,CACpB,IAAM,EAAO,EAAM,SAAS,CAEtB,EAAa,EAAK,MAAM,CAC9B,GAAI,SAAU,GAAc,EAAW,KACrC,MAAO,GAGT,GAAM,CACJ,MAAO,EAAG,IACR,EACA,EAAM,EAAW,EAAY,EAAG,EAAM,CAC1C,IAAK,GAAM,CAAC,EAAO,KAAS,EAAM,CAChC,IAAM,EAAU,EAAW,EAAM,EAAO,EAAM,CAI9C,GAAO,EAET,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swapInPlace-BrVgf3c3.js","names":[],"sources":["../src/internal/swapInPlace.ts"],"sourcesContent":["/**\n * An efficient hack to swap the values at two indices in an array *in-place*.\n */\nexport function swapInPlace(\n // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types -- Intentional\n data: unknown[],\n i: number,\n j: number,\n): void {\n // We use destructuring to perform an in-place swap *without* needing a\n // temporary variable\n [data[i], data[j]] = [data[j], data[i]];\n}\n"],"mappings":"AAGA,SAAgB,EAEd,EACA,EACA,EACM,CAGN,CAAC,EAAK,GAAI,EAAK,IAAM,CAAC,EAAK,GAAI,EAAK,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swapInPlace-IOnMIay9.cjs","names":[],"sources":["../src/internal/swapInPlace.ts"],"sourcesContent":["/**\n * An efficient hack to swap the values at two indices in an array *in-place*.\n */\nexport function swapInPlace(\n // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types -- Intentional\n data: unknown[],\n i: number,\n j: number,\n): void {\n // We use destructuring to perform an in-place swap *without* needing a\n // temporary variable\n [data[i], data[j]] = [data[j], data[i]];\n}\n"],"mappings":"AAGA,SAAgB,EAEd,EACA,EACA,EACM,CAGN,CAAC,EAAK,GAAI,EAAK,IAAM,CAAC,EAAK,GAAI,EAAK,GAAG"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`);function t(...t){return e.purry(n,t)}const n=(e,t,n)=>typeof e==`string`?r([...e],t,n).join(``):r(e,t,n);function r(e,t,n){let r=[...e];if(Number.isNaN(t)||Number.isNaN(n))return r;let i=t<0?e.length+t:t,a=n<0?e.length+n:n;return i<0||i>e.length||a<0||a>e.length?r:(r[i]=e[a],r[a]=e[i],r)}exports.swapIndices=t;
|
|
2
|
+
//# sourceMappingURL=swapIndices.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swapIndices.cjs","names":["purry"],"sources":["../src/swapIndices.ts"],"sourcesContent":["import type { And, IsEqual, Join } from \"type-fest\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\ntype Difference<A extends number, B extends number> =\n TupleOfLength<A> extends [...infer U, ...TupleOfLength<B>]\n ? U[\"length\"]\n : never;\n\ntype isLessThan<A extends number, B extends number> =\n IsEqual<A, B> extends true\n ? false\n : 0 extends A\n ? true\n : 0 extends B\n ? false\n : isLessThan<Difference<A, 1>, Difference<B, 1>>;\n\ntype TupleOfLength<\n L extends number,\n T extends IterableContainer = [],\n> = T[\"length\"] extends L ? T : TupleOfLength<L, [...T, unknown]>;\n\ntype IsNonNegative<T extends number> = number extends T\n ? false\n : `${T}` extends `-${string}`\n ? false\n : true;\n\ntype CharactersTuple<T extends string> = string extends T\n ? string[]\n : T extends `${infer C}${infer R}`\n ? [C, ...CharactersTuple<R>]\n : [];\n\ntype SwapArrayInternal<\n T extends IterableContainer,\n Index1 extends number,\n Index2 extends number,\n Position extends readonly unknown[] = [],\n Original extends IterableContainer = T,\n> = T extends readonly [infer AtPosition, ...infer Rest]\n ? [\n Position[\"length\"] extends Index1\n ? Original[Index2]\n : Position[\"length\"] extends Index2\n ? Original[Index1]\n : AtPosition,\n ...SwapArrayInternal<\n Rest,\n Index1,\n Index2,\n [unknown, ...Position],\n Original\n >,\n ]\n : T;\n\ntype SwapString<T extends string, K1 extends number, K2 extends number> = Join<\n SwapArray<CharactersTuple<T>, K1, K2>,\n \"\"\n>;\n\ntype SwapArray<\n T extends IterableContainer,\n K1 extends number,\n K2 extends number,\n> =\n And<IsNonNegative<K1>, IsNonNegative<K2>> extends true\n ? And<isLessThan<K1, T[\"length\"]>, isLessThan<K2, T[\"length\"]>> extends true\n ? SwapArrayInternal<T, K1, K2>\n : // If the indices are not within the input arrays range the result would\n // be trivially the same as the input array.\n T\n : // TODO [>3]: Because of limitations on the typescript version used in Remeda we can't build a proper Absolute number type so we can't implement proper typing for negative indices and have to opt for a less-strict type instead. Check out the history for the PR that introduced this TODO to see how it could be implemented.\n T[number][];\n\ntype SwappedIndices<\n T extends IterableContainer | string,\n K1 extends number,\n K2 extends number,\n> = T extends string\n ? SwapString<T, K1, K2>\n : T extends IterableContainer\n ? SwapArray<T, K1, K2>\n : never;\n\n/**\n * Swaps the positions of two elements in an array or string at the provided indices.\n *\n * Negative indices are supported and would be treated as an offset from the end of the array. The resulting type thought would be less strict than when using positive indices.\n *\n * If either index is out of bounds the result would be a shallow copy of the input, as-is.\n *\n * @param data - The item to be manipulated. This can be an array, or a string.\n * @param index1 - The first index.\n * @param index2 - The second index.\n * @returns Returns the manipulated array or string.\n * @signature\n * swapIndices(data, index1, index2)\n * @example\n * swapIndices(['a', 'b', 'c'], 0, 1) // => ['b', 'a', 'c']\n * swapIndices(['a', 'b', 'c'], 1, -1) // => ['a', 'c', 'b']\n * swapIndices('abc', 0, 1) // => 'bac'\n * @dataFirst\n * @category Array\n */\nexport function swapIndices<\n T extends IterableContainer | string,\n K1 extends number,\n K2 extends number,\n>(data: T, index1: K1, index2: K2): SwappedIndices<T, K1, K2>;\n\n/**\n * Swaps the positions of two elements in an array or string at the provided indices.\n *\n * Negative indices are supported and would be treated as an offset from the end of the array. The resulting type thought would be less strict than when using positive indices.\n *\n * If either index is out of bounds the result would be a shallow copy of the input, as-is.\n *\n * @param index1 - The first index.\n * @param index2 - The second index.\n * @returns Returns the manipulated array or string.\n * @signature\n * swapIndices(index1, index2)(data)\n * @example\n * swapIndices(0, 1)(['a', 'b', 'c']) // => ['b', 'a', 'c']\n * swapIndices(0, -1)('abc') // => 'cba'\n * @dataLast\n * @category Array\n */\nexport function swapIndices<K1 extends number, K2 extends number>(\n index1: K1,\n index2: K2,\n): <T extends IterableContainer | string>(data: T) => SwappedIndices<T, K1, K2>;\n\nexport function swapIndices(...args: readonly unknown[]): unknown {\n return purry(swapIndicesImplementation, args);\n}\n\nconst swapIndicesImplementation = (\n data: IterableContainer | string,\n index1: number,\n index2: number,\n): unknown =>\n typeof data === \"string\"\n ? // eslint-disable-next-line @typescript-eslint/no-misused-spread -- TODO: I'm not sure what the right way to split the string here, there are multiple \"correct\" answers and each one is meaningfully different: https://github.com/sindresorhus/eslint-plugin-unicorn/issues/2521\n swapArray([...data], index1, index2).join(\"\")\n : swapArray(data, index1, index2);\n\nfunction swapArray(\n data: readonly unknown[],\n index1: number,\n index2: number,\n): unknown[] {\n const result = [...data];\n\n if (Number.isNaN(index1) || Number.isNaN(index2)) {\n return result;\n }\n\n const positiveIndexA = index1 < 0 ? data.length + index1 : index1;\n const positiveIndexB = index2 < 0 ? data.length + index2 : index2;\n\n if (positiveIndexA < 0 || positiveIndexA > data.length) {\n return result;\n }\n\n if (positiveIndexB < 0 || positiveIndexB > data.length) {\n return result;\n }\n\n result[positiveIndexA] = data[positiveIndexB];\n result[positiveIndexB] = data[positiveIndexA];\n\n return result;\n}\n"],"mappings":"kGAwIA,SAAgB,EAAY,GAAG,EAAmC,CAChE,OAAOA,EAAAA,MAAM,EAA2B,EAAK,CAG/C,MAAM,GACJ,EACA,EACA,IAEA,OAAO,GAAS,SAEZ,EAAU,CAAC,GAAG,EAAK,CAAE,EAAQ,EAAO,CAAC,KAAK,GAAG,CAC7C,EAAU,EAAM,EAAQ,EAAO,CAErC,SAAS,EACP,EACA,EACA,EACW,CACX,IAAM,EAAS,CAAC,GAAG,EAAK,CAExB,GAAI,OAAO,MAAM,EAAO,EAAI,OAAO,MAAM,EAAO,CAC9C,OAAO,EAGT,IAAM,EAAiB,EAAS,EAAI,EAAK,OAAS,EAAS,EACrD,EAAiB,EAAS,EAAI,EAAK,OAAS,EAAS,EAa3D,OAXI,EAAiB,GAAK,EAAiB,EAAK,QAI5C,EAAiB,GAAK,EAAiB,EAAK,OACvC,GAGT,EAAO,GAAkB,EAAK,GAC9B,EAAO,GAAkB,EAAK,GAEvB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{purry as e}from"./purry.js";function t(...t){return e(n,t)}const n=(e,t,n)=>typeof e==`string`?r([...e],t,n).join(``):r(e,t,n);function r(e,t,n){let r=[...e];if(Number.isNaN(t)||Number.isNaN(n))return r;let i=t<0?e.length+t:t,a=n<0?e.length+n:n;return i<0||i>e.length||a<0||a>e.length?r:(r[i]=e[a],r[a]=e[i],r)}export{t as swapIndices};
|
|
2
|
+
//# sourceMappingURL=swapIndices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swapIndices.js","names":[],"sources":["../src/swapIndices.ts"],"sourcesContent":["import type { And, IsEqual, Join } from \"type-fest\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\ntype Difference<A extends number, B extends number> =\n TupleOfLength<A> extends [...infer U, ...TupleOfLength<B>]\n ? U[\"length\"]\n : never;\n\ntype isLessThan<A extends number, B extends number> =\n IsEqual<A, B> extends true\n ? false\n : 0 extends A\n ? true\n : 0 extends B\n ? false\n : isLessThan<Difference<A, 1>, Difference<B, 1>>;\n\ntype TupleOfLength<\n L extends number,\n T extends IterableContainer = [],\n> = T[\"length\"] extends L ? T : TupleOfLength<L, [...T, unknown]>;\n\ntype IsNonNegative<T extends number> = number extends T\n ? false\n : `${T}` extends `-${string}`\n ? false\n : true;\n\ntype CharactersTuple<T extends string> = string extends T\n ? string[]\n : T extends `${infer C}${infer R}`\n ? [C, ...CharactersTuple<R>]\n : [];\n\ntype SwapArrayInternal<\n T extends IterableContainer,\n Index1 extends number,\n Index2 extends number,\n Position extends readonly unknown[] = [],\n Original extends IterableContainer = T,\n> = T extends readonly [infer AtPosition, ...infer Rest]\n ? [\n Position[\"length\"] extends Index1\n ? Original[Index2]\n : Position[\"length\"] extends Index2\n ? Original[Index1]\n : AtPosition,\n ...SwapArrayInternal<\n Rest,\n Index1,\n Index2,\n [unknown, ...Position],\n Original\n >,\n ]\n : T;\n\ntype SwapString<T extends string, K1 extends number, K2 extends number> = Join<\n SwapArray<CharactersTuple<T>, K1, K2>,\n \"\"\n>;\n\ntype SwapArray<\n T extends IterableContainer,\n K1 extends number,\n K2 extends number,\n> =\n And<IsNonNegative<K1>, IsNonNegative<K2>> extends true\n ? And<isLessThan<K1, T[\"length\"]>, isLessThan<K2, T[\"length\"]>> extends true\n ? SwapArrayInternal<T, K1, K2>\n : // If the indices are not within the input arrays range the result would\n // be trivially the same as the input array.\n T\n : // TODO [>3]: Because of limitations on the typescript version used in Remeda we can't build a proper Absolute number type so we can't implement proper typing for negative indices and have to opt for a less-strict type instead. Check out the history for the PR that introduced this TODO to see how it could be implemented.\n T[number][];\n\ntype SwappedIndices<\n T extends IterableContainer | string,\n K1 extends number,\n K2 extends number,\n> = T extends string\n ? SwapString<T, K1, K2>\n : T extends IterableContainer\n ? SwapArray<T, K1, K2>\n : never;\n\n/**\n * Swaps the positions of two elements in an array or string at the provided indices.\n *\n * Negative indices are supported and would be treated as an offset from the end of the array. The resulting type thought would be less strict than when using positive indices.\n *\n * If either index is out of bounds the result would be a shallow copy of the input, as-is.\n *\n * @param data - The item to be manipulated. This can be an array, or a string.\n * @param index1 - The first index.\n * @param index2 - The second index.\n * @returns Returns the manipulated array or string.\n * @signature\n * swapIndices(data, index1, index2)\n * @example\n * swapIndices(['a', 'b', 'c'], 0, 1) // => ['b', 'a', 'c']\n * swapIndices(['a', 'b', 'c'], 1, -1) // => ['a', 'c', 'b']\n * swapIndices('abc', 0, 1) // => 'bac'\n * @dataFirst\n * @category Array\n */\nexport function swapIndices<\n T extends IterableContainer | string,\n K1 extends number,\n K2 extends number,\n>(data: T, index1: K1, index2: K2): SwappedIndices<T, K1, K2>;\n\n/**\n * Swaps the positions of two elements in an array or string at the provided indices.\n *\n * Negative indices are supported and would be treated as an offset from the end of the array. The resulting type thought would be less strict than when using positive indices.\n *\n * If either index is out of bounds the result would be a shallow copy of the input, as-is.\n *\n * @param index1 - The first index.\n * @param index2 - The second index.\n * @returns Returns the manipulated array or string.\n * @signature\n * swapIndices(index1, index2)(data)\n * @example\n * swapIndices(0, 1)(['a', 'b', 'c']) // => ['b', 'a', 'c']\n * swapIndices(0, -1)('abc') // => 'cba'\n * @dataLast\n * @category Array\n */\nexport function swapIndices<K1 extends number, K2 extends number>(\n index1: K1,\n index2: K2,\n): <T extends IterableContainer | string>(data: T) => SwappedIndices<T, K1, K2>;\n\nexport function swapIndices(...args: readonly unknown[]): unknown {\n return purry(swapIndicesImplementation, args);\n}\n\nconst swapIndicesImplementation = (\n data: IterableContainer | string,\n index1: number,\n index2: number,\n): unknown =>\n typeof data === \"string\"\n ? // eslint-disable-next-line @typescript-eslint/no-misused-spread -- TODO: I'm not sure what the right way to split the string here, there are multiple \"correct\" answers and each one is meaningfully different: https://github.com/sindresorhus/eslint-plugin-unicorn/issues/2521\n swapArray([...data], index1, index2).join(\"\")\n : swapArray(data, index1, index2);\n\nfunction swapArray(\n data: readonly unknown[],\n index1: number,\n index2: number,\n): unknown[] {\n const result = [...data];\n\n if (Number.isNaN(index1) || Number.isNaN(index2)) {\n return result;\n }\n\n const positiveIndexA = index1 < 0 ? data.length + index1 : index1;\n const positiveIndexB = index2 < 0 ? data.length + index2 : index2;\n\n if (positiveIndexA < 0 || positiveIndexA > data.length) {\n return result;\n }\n\n if (positiveIndexB < 0 || positiveIndexB > data.length) {\n return result;\n }\n\n result[positiveIndexA] = data[positiveIndexB];\n result[positiveIndexB] = data[positiveIndexA];\n\n return result;\n}\n"],"mappings":"mCAwIA,SAAgB,EAAY,GAAG,EAAmC,CAChE,OAAO,EAAM,EAA2B,EAAK,CAG/C,MAAM,GACJ,EACA,EACA,IAEA,OAAO,GAAS,SAEZ,EAAU,CAAC,GAAG,EAAK,CAAE,EAAQ,EAAO,CAAC,KAAK,GAAG,CAC7C,EAAU,EAAM,EAAQ,EAAO,CAErC,SAAS,EACP,EACA,EACA,EACW,CACX,IAAM,EAAS,CAAC,GAAG,EAAK,CAExB,GAAI,OAAO,MAAM,EAAO,EAAI,OAAO,MAAM,EAAO,CAC9C,OAAO,EAGT,IAAM,EAAiB,EAAS,EAAI,EAAK,OAAS,EAAS,EACrD,EAAiB,EAAS,EAAI,EAAK,OAAS,EAAS,EAa3D,OAXI,EAAiB,GAAK,EAAiB,EAAK,QAI5C,EAAiB,GAAK,EAAiB,EAAK,OACvC,GAGT,EAAO,GAAkB,EAAK,GAC9B,EAAO,GAAkB,EAAK,GAEvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swapProps.cjs","names":["purry"],"sources":["../src/swapProps.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\ntype SwappedProps<T, K1 extends keyof T, K2 extends keyof T> = {\n [K in keyof T]: T[K1 extends K ? K2 : K2 extends K ? K1 : K];\n};\n\n/**\n * Swaps the values of two properties in an object based on the provided keys.\n *\n * @param data - The object to be manipulated.\n * @param key1 - The first property key.\n * @param key2 - The second property key.\n * @returns Returns the manipulated object.\n * @signature\n * swapProps(data, key1, key2)\n * @example\n * swapProps({a: 1, b: 2, c: 3}, 'a', 'b') // => {a: 2, b: 1, c: 3}\n * @dataFirst\n * @category Object\n */\nexport function swapProps<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T,\n>(data: T, key1: K1, key2: K2): SwappedProps<T, K1, K2>;\n\n/**\n * Swaps the values of two properties in an object based on the provided keys.\n *\n * @param key1 - The first property key.\n * @param key2 - The second property key.\n * @returns Returns the manipulated object.\n * @signature\n * swapProps(key1, key2)(data)\n * @example\n * swapProps('a', 'b')({a: 1, b: 2, c: 3}) // => {a: 2, b: 1, c: 3}\n * @dataLast\n * @category Object\n */\nexport function swapProps<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T,\n>(key1: K1, key2: K2): (data: T) => SwappedProps<T, K1, K2>;\n\nexport function swapProps(...args: readonly unknown[]): unknown {\n return purry(swapPropsImplementation, args);\n}\n\nfunction swapPropsImplementation<T extends object>(\n obj: T,\n key1: keyof T,\n key2: keyof T,\n): Record<PropertyKey, unknown> {\n const { [key1]: value1, [key2]: value2 } = obj;\n return {\n ...obj,\n [key1]: value2,\n [key2]: value1,\n };\n}\n"],"mappings":"kGA6CA,SAAgB,EAAU,GAAG,EAAmC,CAC9D,OAAOA,EAAAA,MAAM,EAAyB,EAAK,CAG7C,SAAS,EACP,EACA,EACA,EAC8B,CAC9B,GAAM,EAAG,GAAO,GAAS,GAAO,GAAW,EAC3C,MAAO,CACL,GAAG,GACF,GAAO,GACP,GAAO,EACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swapProps.js","names":[],"sources":["../src/swapProps.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\ntype SwappedProps<T, K1 extends keyof T, K2 extends keyof T> = {\n [K in keyof T]: T[K1 extends K ? K2 : K2 extends K ? K1 : K];\n};\n\n/**\n * Swaps the values of two properties in an object based on the provided keys.\n *\n * @param data - The object to be manipulated.\n * @param key1 - The first property key.\n * @param key2 - The second property key.\n * @returns Returns the manipulated object.\n * @signature\n * swapProps(data, key1, key2)\n * @example\n * swapProps({a: 1, b: 2, c: 3}, 'a', 'b') // => {a: 2, b: 1, c: 3}\n * @dataFirst\n * @category Object\n */\nexport function swapProps<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T,\n>(data: T, key1: K1, key2: K2): SwappedProps<T, K1, K2>;\n\n/**\n * Swaps the values of two properties in an object based on the provided keys.\n *\n * @param key1 - The first property key.\n * @param key2 - The second property key.\n * @returns Returns the manipulated object.\n * @signature\n * swapProps(key1, key2)(data)\n * @example\n * swapProps('a', 'b')({a: 1, b: 2, c: 3}) // => {a: 2, b: 1, c: 3}\n * @dataLast\n * @category Object\n */\nexport function swapProps<\n T extends object,\n K1 extends keyof T,\n K2 extends keyof T,\n>(key1: K1, key2: K2): (data: T) => SwappedProps<T, K1, K2>;\n\nexport function swapProps(...args: readonly unknown[]): unknown {\n return purry(swapPropsImplementation, args);\n}\n\nfunction swapPropsImplementation<T extends object>(\n obj: T,\n key1: keyof T,\n key2: keyof T,\n): Record<PropertyKey, unknown> {\n const { [key1]: value1, [key2]: value2 } = obj;\n return {\n ...obj,\n [key1]: value2,\n [key2]: value1,\n };\n}\n"],"mappings":"mCA6CA,SAAgB,EAAU,GAAG,EAAmC,CAC9D,OAAO,EAAM,EAAyB,EAAK,CAG7C,SAAS,EACP,EACA,EACA,EAC8B,CAC9B,GAAM,EAAG,GAAO,GAAS,GAAO,GAAW,EAC3C,MAAO,CACL,GAAG,GACF,GAAO,GACP,GAAO,EACT"}
|
package/dist/take.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.slice(0,t);function i(e){if(e<=0)return t.n;let n=e;return e=>(--n,{done:n<=0,hasNext:!0,next:e})}exports.take=n;
|
|
2
|
+
//# sourceMappingURL=take.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"take.cjs","names":["purry","lazyEmptyEvaluator"],"sources":["../src/take.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport { lazyEmptyEvaluator } from \"./internal/utilityEvaluators\";\nimport { purry } from \"./purry\";\n\n/**\n * Returns the first `n` elements of `array`.\n *\n * @param array - The array.\n * @param n - The number of elements to take.\n * @signature\n * take(array, n)\n * @example\n * take([1, 2, 3, 4, 3, 2, 1], 3) // => [1, 2, 3]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function take<T extends IterableContainer>(\n array: T,\n n: number,\n): T[number][];\n\n/**\n * Returns the first `n` elements of `array`.\n *\n * @param n - The number of elements to take.\n * @signature\n * take(n)(array)\n * @example\n * pipe([1, 2, 3, 4, 3, 2, 1], take(3)) // => [1, 2, 3]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function take(\n n: number,\n): <T extends IterableContainer>(array: T) => T[number][];\n\nexport function take(...args: readonly unknown[]): unknown {\n return purry(takeImplementation, args, lazyImplementation);\n}\n\nconst takeImplementation = <T extends IterableContainer>(\n array: T,\n n: number,\n): T[number][] => (n < 0 ? [] : array.slice(0, n));\n\nfunction lazyImplementation<T>(n: number): LazyEvaluator<T> {\n if (n <= 0) {\n return lazyEmptyEvaluator;\n }\n\n let remaining = n;\n return (value) => {\n remaining -= 1;\n return { done: remaining <= 0, hasNext: true, next: value };\n };\n}\n"],"mappings":"gJAuCA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAOA,EAAAA,MAAM,EAAoB,EAAM,EAAmB,CAG5D,MAAM,GACJ,EACA,IACiB,EAAI,EAAI,EAAE,CAAG,EAAM,MAAM,EAAG,EAAE,CAEjD,SAAS,EAAsB,EAA6B,CAC1D,GAAI,GAAK,EACP,OAAOC,EAAAA,EAGT,IAAI,EAAY,EAChB,MAAQ,KACN,IACO,CAAE,KAAM,GAAa,EAAG,QAAS,GAAM,KAAM,EAAO"}
|
package/dist/take.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{purry as e}from"./purry.js";import{n as t}from"./utilityEvaluators-BQqW5Ir5.js";function n(...t){return e(r,t,i)}const r=(e,t)=>t<0?[]:e.slice(0,t);function i(e){if(e<=0)return t;let n=e;return e=>(--n,{done:n<=0,hasNext:!0,next:e})}export{n as take};
|
|
2
|
+
//# sourceMappingURL=take.js.map
|
package/dist/take.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"take.js","names":[],"sources":["../src/take.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport { lazyEmptyEvaluator } from \"./internal/utilityEvaluators\";\nimport { purry } from \"./purry\";\n\n/**\n * Returns the first `n` elements of `array`.\n *\n * @param array - The array.\n * @param n - The number of elements to take.\n * @signature\n * take(array, n)\n * @example\n * take([1, 2, 3, 4, 3, 2, 1], 3) // => [1, 2, 3]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function take<T extends IterableContainer>(\n array: T,\n n: number,\n): T[number][];\n\n/**\n * Returns the first `n` elements of `array`.\n *\n * @param n - The number of elements to take.\n * @signature\n * take(n)(array)\n * @example\n * pipe([1, 2, 3, 4, 3, 2, 1], take(3)) // => [1, 2, 3]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function take(\n n: number,\n): <T extends IterableContainer>(array: T) => T[number][];\n\nexport function take(...args: readonly unknown[]): unknown {\n return purry(takeImplementation, args, lazyImplementation);\n}\n\nconst takeImplementation = <T extends IterableContainer>(\n array: T,\n n: number,\n): T[number][] => (n < 0 ? [] : array.slice(0, n));\n\nfunction lazyImplementation<T>(n: number): LazyEvaluator<T> {\n if (n <= 0) {\n return lazyEmptyEvaluator;\n }\n\n let remaining = n;\n return (value) => {\n remaining -= 1;\n return { done: remaining <= 0, hasNext: true, next: value };\n };\n}\n"],"mappings":"uFAuCA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAO,EAAM,EAAoB,EAAM,EAAmB,CAG5D,MAAM,GACJ,EACA,IACiB,EAAI,EAAI,EAAE,CAAG,EAAM,MAAM,EAAG,EAAE,CAEjD,SAAS,EAAsB,EAA6B,CAC1D,GAAI,GAAK,EACP,OAAO,EAGT,IAAI,EAAY,EAChB,MAAQ,KACN,IACO,CAAE,KAAM,GAAa,EAAG,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<=0)return[];if(r>=t.length)return[...t];let i=t.slice(0,r);e.n(i,n);let a=t.slice(r);for(let t of a)e.t(i,n,t);return i}exports.takeFirstBy=n;
|
|
2
|
+
//# sourceMappingURL=takeFirstBy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"takeFirstBy.cjs","names":["purryOrderRulesWithArgument"],"sources":["../src/takeFirstBy.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 * Take the first `n` items from `data` based on the provided ordering criteria. This allows you to avoid sorting the array before taking 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 drop `n` elements) see `dropFirstBy`.\n *\n * @param data - The input array.\n * @param n - The number of items to take. If `n` is non-positive no items would be returned, if `n` is bigger then data.length a *clone* of `data` would be returned.\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 * takeFirstBy(data, n, ...rules);\n * @example\n * takeFirstBy(['aa', 'aaaa', 'a', 'aaa'], 2, x => x.length); // => ['a', 'aa']\n * @dataFirst\n * @category Array\n */\nexport function takeFirstBy<T>(\n data: readonly T[],\n n: number,\n ...rules: Readonly<NonEmptyArray<OrderRule<T>>>\n): T[];\n\n/**\n * Take the first `n` items from `data` based on the provided ordering criteria. This allows you to avoid sorting the array before taking 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 drop `n` elements) see `dropFirstBy`.\n *\n * @param n - The number of items to take. If `n` is non-positive no items would be returned, if `n` is bigger then data.length a *clone* of `data` would be returned.\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 * takeFirstBy(n, ...rules)(data);\n * @example\n * pipe(['aa', 'aaaa', 'a', 'aaa'], takeFirstBy(2, x => x.length)); // => ['a', 'aa']\n * @dataLast\n * @category Array\n */\nexport function takeFirstBy<T>(\n n: number,\n ...rules: Readonly<NonEmptyArray<OrderRule<T>>>\n): (data: readonly T[]) => T[];\n\nexport function takeFirstBy(...args: readonly unknown[]): unknown {\n return purryOrderRulesWithArgument(takeFirstByImplementation, args);\n}\n\nfunction takeFirstByImplementation<T>(\n data: readonly T[],\n compareFn: CompareFunction<T>,\n n: number,\n): T[] {\n if (n <= 0) {\n return [];\n }\n\n if (n >= data.length) {\n return [...data];\n }\n\n const heap = data.slice(0, n);\n heapify(heap, compareFn);\n\n const rest = data.slice(n);\n for (const item of rest) {\n heapMaybeInsert(heap, compareFn, item);\n }\n\n return heap;\n}\n"],"mappings":"sJAkDA,SAAgB,EAAY,GAAG,EAAmC,CAChE,OAAOA,EAAAA,EAA4B,EAA2B,EAAK,CAGrE,SAAS,EACP,EACA,EACA,EACK,CACL,GAAI,GAAK,EACP,MAAO,EAAE,CAGX,GAAI,GAAK,EAAK,OACZ,MAAO,CAAC,GAAG,EAAK,CAGlB,IAAM,EAAO,EAAK,MAAM,EAAG,EAAE,CAC7B,EAAA,EAAQ,EAAM,EAAU,CAExB,IAAM,EAAO,EAAK,MAAM,EAAE,CAC1B,IAAK,IAAM,KAAQ,EACjB,EAAA,EAAgB,EAAM,EAAW,EAAK,CAGxC,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<=0)return[];if(i>=n.length)return[...n];let a=n.slice(0,i);e(a,r);let o=n.slice(i);for(let e of o)t(a,r,e);return a}export{r as takeFirstBy};
|
|
2
|
+
//# sourceMappingURL=takeFirstBy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"takeFirstBy.js","names":[],"sources":["../src/takeFirstBy.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 * Take the first `n` items from `data` based on the provided ordering criteria. This allows you to avoid sorting the array before taking 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 drop `n` elements) see `dropFirstBy`.\n *\n * @param data - The input array.\n * @param n - The number of items to take. If `n` is non-positive no items would be returned, if `n` is bigger then data.length a *clone* of `data` would be returned.\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 * takeFirstBy(data, n, ...rules);\n * @example\n * takeFirstBy(['aa', 'aaaa', 'a', 'aaa'], 2, x => x.length); // => ['a', 'aa']\n * @dataFirst\n * @category Array\n */\nexport function takeFirstBy<T>(\n data: readonly T[],\n n: number,\n ...rules: Readonly<NonEmptyArray<OrderRule<T>>>\n): T[];\n\n/**\n * Take the first `n` items from `data` based on the provided ordering criteria. This allows you to avoid sorting the array before taking 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 drop `n` elements) see `dropFirstBy`.\n *\n * @param n - The number of items to take. If `n` is non-positive no items would be returned, if `n` is bigger then data.length a *clone* of `data` would be returned.\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 * takeFirstBy(n, ...rules)(data);\n * @example\n * pipe(['aa', 'aaaa', 'a', 'aaa'], takeFirstBy(2, x => x.length)); // => ['a', 'aa']\n * @dataLast\n * @category Array\n */\nexport function takeFirstBy<T>(\n n: number,\n ...rules: Readonly<NonEmptyArray<OrderRule<T>>>\n): (data: readonly T[]) => T[];\n\nexport function takeFirstBy(...args: readonly unknown[]): unknown {\n return purryOrderRulesWithArgument(takeFirstByImplementation, args);\n}\n\nfunction takeFirstByImplementation<T>(\n data: readonly T[],\n compareFn: CompareFunction<T>,\n n: number,\n): T[] {\n if (n <= 0) {\n return [];\n }\n\n if (n >= data.length) {\n return [...data];\n }\n\n const heap = data.slice(0, n);\n heapify(heap, compareFn);\n\n const rest = data.slice(n);\n for (const item of rest) {\n heapMaybeInsert(heap, compareFn, item);\n }\n\n return heap;\n}\n"],"mappings":"sFAkDA,SAAgB,EAAY,GAAG,EAAmC,CAChE,OAAO,EAA4B,EAA2B,EAAK,CAGrE,SAAS,EACP,EACA,EACA,EACK,CACL,GAAI,GAAK,EACP,MAAO,EAAE,CAGX,GAAI,GAAK,EAAK,OACZ,MAAO,CAAC,GAAG,EAAK,CAGlB,IAAM,EAAO,EAAK,MAAM,EAAG,EAAE,CAC7B,EAAQ,EAAM,EAAU,CAExB,IAAM,EAAO,EAAK,MAAM,EAAE,CAC1B,IAAK,IAAM,KAAQ,EACjB,EAAgB,EAAM,EAAW,EAAK,CAGxC,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"takeLast.cjs","names":["purry"],"sources":["../src/takeLast.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\n/**\n * Takes the last `n` elements from the `array`.\n *\n * @param array - The target array.\n * @param n - The number of elements to take.\n * @signature\n * takeLast(array, n)\n * @example\n * takeLast([1, 2, 3, 4, 5], 2) // => [4, 5]\n * @dataFirst\n * @category Array\n */\nexport function takeLast<T extends IterableContainer>(\n array: T,\n n: number,\n): T[number][];\n\n/**\n * Take the last `n` elements from the `array`.\n *\n * @param n - The number of elements to take.\n * @signature\n * takeLast(n)(array)\n * @example\n * takeLast(2)([1, 2, 3, 4, 5]) // => [4, 5]\n * @dataLast\n * @category Array\n */\nexport function takeLast<T extends IterableContainer>(\n n: number,\n): (array: T) => T[number][];\n\nexport function takeLast(...args: readonly unknown[]): unknown {\n return purry(takeLastImplementation, args);\n}\n\nconst takeLastImplementation = <T extends IterableContainer>(\n array: T,\n n: number,\n): T[number][] => (n > 0 ? array.slice(Math.max(0, array.length - n)) : []);\n"],"mappings":"kGAmCA,SAAgB,EAAS,GAAG,EAAmC,CAC7D,OAAOA,EAAAA,MAAM,EAAwB,EAAK,CAG5C,MAAM,GACJ,EACA,IACiB,EAAI,EAAI,EAAM,MAAM,KAAK,IAAI,EAAG,EAAM,OAAS,EAAE,CAAC,CAAG,EAAE"}
|
package/dist/takeLast.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"takeLast.js","names":[],"sources":["../src/takeLast.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\n/**\n * Takes the last `n` elements from the `array`.\n *\n * @param array - The target array.\n * @param n - The number of elements to take.\n * @signature\n * takeLast(array, n)\n * @example\n * takeLast([1, 2, 3, 4, 5], 2) // => [4, 5]\n * @dataFirst\n * @category Array\n */\nexport function takeLast<T extends IterableContainer>(\n array: T,\n n: number,\n): T[number][];\n\n/**\n * Take the last `n` elements from the `array`.\n *\n * @param n - The number of elements to take.\n * @signature\n * takeLast(n)(array)\n * @example\n * takeLast(2)([1, 2, 3, 4, 5]) // => [4, 5]\n * @dataLast\n * @category Array\n */\nexport function takeLast<T extends IterableContainer>(\n n: number,\n): (array: T) => T[number][];\n\nexport function takeLast(...args: readonly unknown[]): unknown {\n return purry(takeLastImplementation, args);\n}\n\nconst takeLastImplementation = <T extends IterableContainer>(\n array: T,\n n: number,\n): T[number][] => (n > 0 ? array.slice(Math.max(0, array.length - n)) : []);\n"],"mappings":"mCAmCA,SAAgB,EAAS,GAAG,EAAmC,CAC7D,OAAO,EAAM,EAAwB,EAAK,CAG5C,MAAM,GACJ,EACA,IACiB,EAAI,EAAI,EAAM,MAAM,KAAK,IAAI,EAAG,EAAM,OAAS,EAAE,CAAC,CAAG,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=e.length-1;n>=0;n--)if(!t(e[n],n,e))return e.slice(n+1);return[...e]}exports.takeLastWhile=t;
|
|
2
|
+
//# sourceMappingURL=takeLastWhile.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"takeLastWhile.cjs","names":["purry"],"sources":["../src/takeLastWhile.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\n/**\n * Returns elements from the end of the array until the predicate returns false.\n * The returned elements will be in the same order as in the original array.\n *\n * @param data - The array.\n * @param predicate - The predicate.\n * @signature\n * takeLastWhile(data, predicate)\n * @example\n * takeLastWhile([1, 2, 10, 3, 4, 5], x => x < 10) // => [3, 4, 5]\n * @dataFirst\n * @category Array\n */\nexport function takeLastWhile<T extends IterableContainer, S extends T[number]>(\n data: T,\n predicate: (item: T[number], index: number, data: T) => item is S,\n): S[];\nexport function takeLastWhile<T extends IterableContainer>(\n data: T,\n predicate: (item: T[number], index: number, data: T) => boolean,\n): T[number][];\n\n/**\n * Returns elements from the end of the array until the predicate returns false.\n * The returned elements will be in the same order as in the original array.\n *\n * @param predicate - The predicate.\n * @signature\n * takeLastWhile(predicate)(data)\n * @example\n * pipe([1, 2, 10, 3, 4, 5], takeLastWhile(x => x < 10)) // => [3, 4, 5]\n * @dataLast\n * @category Array\n */\nexport function takeLastWhile<T extends IterableContainer, S extends T[number]>(\n predicate: (item: T[number], index: number, data: T) => item is S,\n): (array: T) => S[];\nexport function takeLastWhile<T extends IterableContainer>(\n predicate: (item: T[number], index: number, data: T) => boolean,\n): (data: T) => T[number][];\n\nexport function takeLastWhile(...args: readonly unknown[]): unknown {\n return purry(takeLastWhileImplementation, args);\n}\n\nfunction takeLastWhileImplementation<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(i + 1);\n }\n }\n return [...data];\n}\n"],"mappings":"kGA4CA,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,EAAI,EAAE,CAG5B,MAAO,CAAC,GAAG,EAAK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"takeLastWhile.js","names":[],"sources":["../src/takeLastWhile.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\n/**\n * Returns elements from the end of the array until the predicate returns false.\n * The returned elements will be in the same order as in the original array.\n *\n * @param data - The array.\n * @param predicate - The predicate.\n * @signature\n * takeLastWhile(data, predicate)\n * @example\n * takeLastWhile([1, 2, 10, 3, 4, 5], x => x < 10) // => [3, 4, 5]\n * @dataFirst\n * @category Array\n */\nexport function takeLastWhile<T extends IterableContainer, S extends T[number]>(\n data: T,\n predicate: (item: T[number], index: number, data: T) => item is S,\n): S[];\nexport function takeLastWhile<T extends IterableContainer>(\n data: T,\n predicate: (item: T[number], index: number, data: T) => boolean,\n): T[number][];\n\n/**\n * Returns elements from the end of the array until the predicate returns false.\n * The returned elements will be in the same order as in the original array.\n *\n * @param predicate - The predicate.\n * @signature\n * takeLastWhile(predicate)(data)\n * @example\n * pipe([1, 2, 10, 3, 4, 5], takeLastWhile(x => x < 10)) // => [3, 4, 5]\n * @dataLast\n * @category Array\n */\nexport function takeLastWhile<T extends IterableContainer, S extends T[number]>(\n predicate: (item: T[number], index: number, data: T) => item is S,\n): (array: T) => S[];\nexport function takeLastWhile<T extends IterableContainer>(\n predicate: (item: T[number], index: number, data: T) => boolean,\n): (data: T) => T[number][];\n\nexport function takeLastWhile(...args: readonly unknown[]): unknown {\n return purry(takeLastWhileImplementation, args);\n}\n\nfunction takeLastWhileImplementation<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(i + 1);\n }\n }\n return [...data];\n}\n"],"mappings":"mCA4CA,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,EAAI,EAAE,CAG5B,MAAO,CAAC,GAAG,EAAK"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`);function t(...t){return e.purry(n,t)}function n(e,t){let n=[];for(let[r,i]of e.entries()){if(!t(i,r,e))break;n.push(i)}return n}exports.takeWhile=t;
|
|
2
|
+
//# sourceMappingURL=takeWhile.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"takeWhile.cjs","names":["purry"],"sources":["../src/takeWhile.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\n/**\n * Returns elements from the array until predicate returns false.\n *\n * @param data - The array.\n * @param predicate - The predicate.\n * @signature\n * takeWhile(data, predicate)\n * @example\n * takeWhile([1, 2, 3, 4, 3, 2, 1], x => x !== 4) // => [1, 2, 3]\n * @dataFirst\n * @category Array\n */\nexport function takeWhile<T extends IterableContainer, S extends T[number]>(\n data: T,\n predicate: (item: T[number], index: number, data: T) => item is S,\n): S[];\nexport function takeWhile<T extends IterableContainer>(\n data: T,\n predicate: (item: T[number], index: number, data: T) => boolean,\n): T[number][];\n\n/**\n * Returns elements from the array until predicate returns false.\n *\n * @param predicate - The predicate.\n * @signature\n * takeWhile(predicate)(data)\n * @example\n * pipe([1, 2, 3, 4, 3, 2, 1], takeWhile(x => x !== 4)) // => [1, 2, 3]\n * @dataLast\n * @category Array\n */\nexport function takeWhile<T extends IterableContainer, S extends T[number]>(\n predicate: (item: T[number], index: number, data: T) => item is S,\n): (array: T) => S[];\nexport function takeWhile<T extends IterableContainer>(\n predicate: (item: T[number], index: number, data: T) => boolean,\n): (array: T) => T[number][];\n\nexport function takeWhile(...args: readonly unknown[]): unknown {\n return purry(takeWhileImplementation, args);\n}\n\nfunction takeWhileImplementation<T extends IterableContainer>(\n data: T,\n predicate: (item: T[number], index: number, data: T) => boolean,\n): T[number][] {\n const ret: T[number][] = [];\n for (const [index, item] of data.entries()) {\n if (!predicate(item, index, data)) {\n break;\n }\n ret.push(item);\n }\n return ret;\n}\n"],"mappings":"kGA0CA,SAAgB,EAAU,GAAG,EAAmC,CAC9D,OAAOA,EAAAA,MAAM,EAAyB,EAAK,CAG7C,SAAS,EACP,EACA,EACa,CACb,IAAM,EAAmB,EAAE,CAC3B,IAAK,GAAM,CAAC,EAAO,KAAS,EAAK,SAAS,CAAE,CAC1C,GAAI,CAAC,EAAU,EAAM,EAAO,EAAK,CAC/B,MAEF,EAAI,KAAK,EAAK,CAEhB,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"takeWhile.js","names":[],"sources":["../src/takeWhile.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\n/**\n * Returns elements from the array until predicate returns false.\n *\n * @param data - The array.\n * @param predicate - The predicate.\n * @signature\n * takeWhile(data, predicate)\n * @example\n * takeWhile([1, 2, 3, 4, 3, 2, 1], x => x !== 4) // => [1, 2, 3]\n * @dataFirst\n * @category Array\n */\nexport function takeWhile<T extends IterableContainer, S extends T[number]>(\n data: T,\n predicate: (item: T[number], index: number, data: T) => item is S,\n): S[];\nexport function takeWhile<T extends IterableContainer>(\n data: T,\n predicate: (item: T[number], index: number, data: T) => boolean,\n): T[number][];\n\n/**\n * Returns elements from the array until predicate returns false.\n *\n * @param predicate - The predicate.\n * @signature\n * takeWhile(predicate)(data)\n * @example\n * pipe([1, 2, 3, 4, 3, 2, 1], takeWhile(x => x !== 4)) // => [1, 2, 3]\n * @dataLast\n * @category Array\n */\nexport function takeWhile<T extends IterableContainer, S extends T[number]>(\n predicate: (item: T[number], index: number, data: T) => item is S,\n): (array: T) => S[];\nexport function takeWhile<T extends IterableContainer>(\n predicate: (item: T[number], index: number, data: T) => boolean,\n): (array: T) => T[number][];\n\nexport function takeWhile(...args: readonly unknown[]): unknown {\n return purry(takeWhileImplementation, args);\n}\n\nfunction takeWhileImplementation<T extends IterableContainer>(\n data: T,\n predicate: (item: T[number], index: number, data: T) => boolean,\n): T[number][] {\n const ret: T[number][] = [];\n for (const [index, item] of data.entries()) {\n if (!predicate(item, index, data)) {\n break;\n }\n ret.push(item);\n }\n return ret;\n}\n"],"mappings":"mCA0CA,SAAgB,EAAU,GAAG,EAAmC,CAC9D,OAAO,EAAM,EAAyB,EAAK,CAG7C,SAAS,EACP,EACA,EACa,CACb,IAAM,EAAmB,EAAE,CAC3B,IAAK,GAAM,CAAC,EAAO,KAAS,EAAK,SAAS,CAAE,CAC1C,GAAI,CAAC,EAAU,EAAM,EAAO,EAAK,CAC/B,MAEF,EAAI,KAAK,EAAK,CAEhB,OAAO"}
|
package/dist/tap.cjs
ADDED
package/dist/tap.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tap.cjs","names":["purry"],"sources":["../src/tap.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Calls the given function with the given value, then returns the given value.\n * The return value of the provided function is ignored.\n *\n * This allows \"tapping into\" a function sequence in a pipe, to perform side\n * effects on intermediate results.\n *\n * @param value - The value to pass into the function.\n * @param fn - The function to call.\n * @signature\n * tap(value, fn)\n * @example\n * tap(\"foo\", console.log) // => \"foo\"\n * @dataFirst\n * @category Other\n */\nexport function tap<T>(value: T, fn: (value: T) => void): T;\n\n/**\n * Calls the given function with the given value, then returns the given value.\n * The return value of the provided function is ignored.\n *\n * This allows \"tapping into\" a function sequence in a pipe, to perform side\n * effects on intermediate results.\n *\n * @param fn - The function to call.\n * @signature\n * tap(fn)(value)\n * @example\n * pipe(\n * [-5, -1, 2, 3],\n * filter(n => n > 0),\n * tap(console.log), // prints [2, 3]\n * map(n => n * 2)\n * ) // => [4, 6]\n * @dataLast\n * @category Other\n */\nexport function tap<\n T,\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- TODO: This is solvable by inlining F and wrapping the T parameter with `NoInfer` (e.g. `(value: NoInfer<T>) => unknown`); to prevent typescript from inferring it as `unknown`. This is only available in TS 5.4, which is above what we currently support (5.1).\n F extends (value: T) => unknown,\n>(fn: F): (value: T) => T;\n\nexport function tap(...args: readonly unknown[]): unknown {\n return purry(tapImplementation, args);\n}\n\nfunction tapImplementation<T>(value: T, fn: (value: T) => void): T {\n fn(value);\n return value;\n}\n"],"mappings":"kGA8CA,SAAgB,EAAI,GAAG,EAAmC,CACxD,OAAOA,EAAAA,MAAM,EAAmB,EAAK,CAGvC,SAAS,EAAqB,EAAU,EAA2B,CAEjE,OADA,EAAG,EAAM,CACF"}
|
package/dist/tap.js
ADDED
package/dist/tap.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tap.js","names":[],"sources":["../src/tap.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Calls the given function with the given value, then returns the given value.\n * The return value of the provided function is ignored.\n *\n * This allows \"tapping into\" a function sequence in a pipe, to perform side\n * effects on intermediate results.\n *\n * @param value - The value to pass into the function.\n * @param fn - The function to call.\n * @signature\n * tap(value, fn)\n * @example\n * tap(\"foo\", console.log) // => \"foo\"\n * @dataFirst\n * @category Other\n */\nexport function tap<T>(value: T, fn: (value: T) => void): T;\n\n/**\n * Calls the given function with the given value, then returns the given value.\n * The return value of the provided function is ignored.\n *\n * This allows \"tapping into\" a function sequence in a pipe, to perform side\n * effects on intermediate results.\n *\n * @param fn - The function to call.\n * @signature\n * tap(fn)(value)\n * @example\n * pipe(\n * [-5, -1, 2, 3],\n * filter(n => n > 0),\n * tap(console.log), // prints [2, 3]\n * map(n => n * 2)\n * ) // => [4, 6]\n * @dataLast\n * @category Other\n */\nexport function tap<\n T,\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters -- TODO: This is solvable by inlining F and wrapping the T parameter with `NoInfer` (e.g. `(value: NoInfer<T>) => unknown`); to prevent typescript from inferring it as `unknown`. This is only available in TS 5.4, which is above what we currently support (5.1).\n F extends (value: T) => unknown,\n>(fn: F): (value: T) => T;\n\nexport function tap(...args: readonly unknown[]): unknown {\n return purry(tapImplementation, args);\n}\n\nfunction tapImplementation<T>(value: T, fn: (value: T) => void): T {\n fn(value);\n return value;\n}\n"],"mappings":"mCA8CA,SAAgB,EAAI,GAAG,EAAmC,CACxD,OAAO,EAAM,EAAmB,EAAK,CAGvC,SAAS,EAAqB,EAAU,EAA2B,CAEjE,OADA,EAAG,EAAM,CACF"}
|
package/dist/times.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(e<1)return[];let n=Number.isInteger(e)?e:Math.floor(e),r=Array(n);for(let e=0;e<n;e++)r[e]=t(e);return r}exports.times=t;
|
|
2
|
+
//# sourceMappingURL=times.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"times.cjs","names":["purry"],"sources":["../src/times.ts"],"sourcesContent":["import type { GreaterThan } from \"type-fest\";\nimport { purry } from \"./purry\";\n\n// This number was picked by trial-and-error until typescript stops failing with\n// \"Type instantiation is excessively deep and possibly infinite. (ts2589)\".\n// See the type tests for more information.\ntype MAX_LITERAL_SIZE = 46;\n\ntype TimesArray<\n T,\n N extends number,\n Iteration extends readonly unknown[] = [],\n> = number extends N\n ? // N is not a literal number, we can't deduce the type\n T[]\n : `${N}` extends `-${number}`\n ? // N is non-positive, the mapper will never run\n []\n : `${N}` extends `${infer K extends number}.${number}`\n ? // N is not an integer, we \"floor\" the number.\n TimesArray<T, K, Iteration>\n : GreaterThan<N, MAX_LITERAL_SIZE> extends true\n ? // We can't build a literal tuple beyond this size, after that we\n // can't add more items to the tuple so we add a rest element instead.\n [...TimesArray<T, MAX_LITERAL_SIZE, Iteration>, ...T[]]\n : N extends Iteration[\"length\"]\n ? // We finished building the output tuple\n []\n : // Add another item to the tuple and recurse.\n [T, ...TimesArray<T, N, [unknown, ...Iteration]>];\n\n/**\n * Calls an input function `n` times, returning an array containing the results\n * of those function calls.\n *\n * `fn` is passed one argument: The current value of `n`, which begins at `0`\n * and is gradually incremented to `n - 1`.\n *\n * @param count - A value between `0` and `n - 1`. Increments after each\n * function call.\n * @param fn - The function to invoke. Passed one argument, the current value of\n * `n`.\n * @returns An array containing the return values of all calls to `fn`.\n * @signature\n * times(count, fn)\n * @example\n * times(5, identity()); //=> [0, 1, 2, 3, 4]\n * @dataFirst\n * @category Array\n */\nexport function times<T, N extends number>(\n count: N,\n fn: (index: number) => T,\n): TimesArray<T, N>;\n\n/**\n * Calls an input function `n` times, returning an array containing the results\n * of those function calls.\n *\n * `fn` is passed one argument: The current value of `n`, which begins at `0`\n * and is gradually incremented to `n - 1`.\n *\n * @param fn - The function to invoke. Passed one argument, the current value of\n * `n`.\n * @returns An array containing the return values of all calls to `fn`.\n * @signature\n * times(fn)(count)\n * @example\n * times(identity())(5); //=> [0, 1, 2, 3, 4]\n * @dataLast\n * @category Array\n */\nexport function times<T>(\n fn: (index: number) => T,\n): <N extends number>(count: N) => TimesArray<T, N>;\n\nexport function times(...args: readonly unknown[]): unknown {\n return purry(timesImplementation, args);\n}\n\nfunction timesImplementation<T>(count: number, fn: (index: number) => T): T[] {\n if (count < 1) {\n // We prefer to return trivial results on trivial inputs vs throwing errors.\n return [];\n }\n\n // Non-integer numbers would cause `new Array` to throw, but it makes more\n // sense to simply round them down to the nearest integer instead; but\n // rounding has some performance implications so we only do it when we have to\n const length = Number.isInteger(count) ? count : Math.floor(count);\n\n // eslint-disable-next-line unicorn/no-new-array -- This is the most efficient way to create the array, check out the benchmarks in the PR that added this comment.\n const res = new Array<T>(length);\n\n for (let i = 0; i < length; i++) {\n res[i] = fn(i);\n }\n\n return res;\n}\n"],"mappings":"kGA4EA,SAAgB,EAAM,GAAG,EAAmC,CAC1D,OAAOA,EAAAA,MAAM,EAAqB,EAAK,CAGzC,SAAS,EAAuB,EAAe,EAA+B,CAC5E,GAAI,EAAQ,EAEV,MAAO,EAAE,CAMX,IAAM,EAAS,OAAO,UAAU,EAAM,CAAG,EAAQ,KAAK,MAAM,EAAM,CAG5D,EAAU,MAAS,EAAO,CAEhC,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,IAC1B,EAAI,GAAK,EAAG,EAAE,CAGhB,OAAO"}
|
package/dist/times.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"times.js","names":[],"sources":["../src/times.ts"],"sourcesContent":["import type { GreaterThan } from \"type-fest\";\nimport { purry } from \"./purry\";\n\n// This number was picked by trial-and-error until typescript stops failing with\n// \"Type instantiation is excessively deep and possibly infinite. (ts2589)\".\n// See the type tests for more information.\ntype MAX_LITERAL_SIZE = 46;\n\ntype TimesArray<\n T,\n N extends number,\n Iteration extends readonly unknown[] = [],\n> = number extends N\n ? // N is not a literal number, we can't deduce the type\n T[]\n : `${N}` extends `-${number}`\n ? // N is non-positive, the mapper will never run\n []\n : `${N}` extends `${infer K extends number}.${number}`\n ? // N is not an integer, we \"floor\" the number.\n TimesArray<T, K, Iteration>\n : GreaterThan<N, MAX_LITERAL_SIZE> extends true\n ? // We can't build a literal tuple beyond this size, after that we\n // can't add more items to the tuple so we add a rest element instead.\n [...TimesArray<T, MAX_LITERAL_SIZE, Iteration>, ...T[]]\n : N extends Iteration[\"length\"]\n ? // We finished building the output tuple\n []\n : // Add another item to the tuple and recurse.\n [T, ...TimesArray<T, N, [unknown, ...Iteration]>];\n\n/**\n * Calls an input function `n` times, returning an array containing the results\n * of those function calls.\n *\n * `fn` is passed one argument: The current value of `n`, which begins at `0`\n * and is gradually incremented to `n - 1`.\n *\n * @param count - A value between `0` and `n - 1`. Increments after each\n * function call.\n * @param fn - The function to invoke. Passed one argument, the current value of\n * `n`.\n * @returns An array containing the return values of all calls to `fn`.\n * @signature\n * times(count, fn)\n * @example\n * times(5, identity()); //=> [0, 1, 2, 3, 4]\n * @dataFirst\n * @category Array\n */\nexport function times<T, N extends number>(\n count: N,\n fn: (index: number) => T,\n): TimesArray<T, N>;\n\n/**\n * Calls an input function `n` times, returning an array containing the results\n * of those function calls.\n *\n * `fn` is passed one argument: The current value of `n`, which begins at `0`\n * and is gradually incremented to `n - 1`.\n *\n * @param fn - The function to invoke. Passed one argument, the current value of\n * `n`.\n * @returns An array containing the return values of all calls to `fn`.\n * @signature\n * times(fn)(count)\n * @example\n * times(identity())(5); //=> [0, 1, 2, 3, 4]\n * @dataLast\n * @category Array\n */\nexport function times<T>(\n fn: (index: number) => T,\n): <N extends number>(count: N) => TimesArray<T, N>;\n\nexport function times(...args: readonly unknown[]): unknown {\n return purry(timesImplementation, args);\n}\n\nfunction timesImplementation<T>(count: number, fn: (index: number) => T): T[] {\n if (count < 1) {\n // We prefer to return trivial results on trivial inputs vs throwing errors.\n return [];\n }\n\n // Non-integer numbers would cause `new Array` to throw, but it makes more\n // sense to simply round them down to the nearest integer instead; but\n // rounding has some performance implications so we only do it when we have to\n const length = Number.isInteger(count) ? count : Math.floor(count);\n\n // eslint-disable-next-line unicorn/no-new-array -- This is the most efficient way to create the array, check out the benchmarks in the PR that added this comment.\n const res = new Array<T>(length);\n\n for (let i = 0; i < length; i++) {\n res[i] = fn(i);\n }\n\n return res;\n}\n"],"mappings":"mCA4EA,SAAgB,EAAM,GAAG,EAAmC,CAC1D,OAAO,EAAM,EAAqB,EAAK,CAGzC,SAAS,EAAuB,EAAe,EAA+B,CAC5E,GAAI,EAAQ,EAEV,MAAO,EAAE,CAMX,IAAM,EAAS,OAAO,UAAU,EAAM,CAAG,EAAQ,KAAK,MAAM,EAAM,CAG5D,EAAU,MAAS,EAAO,CAEhC,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,IAC1B,EAAI,GAAK,EAAG,EAAE,CAGhB,OAAO"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./words-CDCUnuNz.cjs`),t=/[a-z]/u;function n(e,t){return typeof e==`string`?r(e,t):t=>r(t,e)}const r=(n,{preserveConsecutiveUppercase:r=!0}={})=>e.t(t.test(n)?n:n.toLowerCase()).map((e,t)=>`${t===0?e[0].toLowerCase():e[0].toUpperCase()}${r?e.slice(1):e.slice(1).toLowerCase()}`).join(``);exports.toCamelCase=n;
|
|
2
|
+
//# sourceMappingURL=toCamelCase.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toCamelCase.cjs","names":["words"],"sources":["../src/toCamelCase.ts"],"sourcesContent":["import type {\n CamelCase,\n CamelCaseOptions as BaseCamelCaseOptions,\n} from \"type-fest\";\nimport type { OptionalOptionsWithDefaults } from \"./internal/types/OptionalOptionsWithDefaults\";\nimport { words } from \"./internal/words\";\n\nconst LOWER_CASE_CHARACTER_RE = /[a-z]/u;\n\nconst DEFAULT_PRESERVE_CONSECUTIVE_UPPERCASE = true;\n\ntype CamelCaseOptions = {\n readonly preserveConsecutiveUppercase?: boolean;\n};\n\ntype CamelCaseOptionsWithDefaults<Options extends CamelCaseOptions> =\n OptionalOptionsWithDefaults<\n CamelCaseOptions,\n Options,\n {\n // We use the runtime const for the default type so they stay coupled.\n preserveConsecutiveUppercase: typeof DEFAULT_PRESERVE_CONSECUTIVE_UPPERCASE;\n }\n >;\n\n/**\n * Converts text to **camelCase** by splitting it into words, lowercasing the\n * first word, capitalizing the rest, then joining them back together.\n *\n * Because it uses the built-in case conversion methods, the function shares\n * their _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_\n * too, making it best suited for simple strings like identifiers and internal\n * keys. For linguistic text processing, use [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)\n * with [`granularity: \"word\"`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter#parameters),\n * [`toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase),\n * and [`toLocaleUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase)\n * which are purpose-built to handle nuances in languages and locales.\n *\n * For other case manipulations see: `toLowerCase`, `toUpperCase`, `capitalize`,\n * `uncapitalize`, `toKebabCase`, `toSnakeCase`, and `toTitleCase`.\n *\n * For *PascalCase* use `capitalize(toCamelCase(data))`.\n *\n * @param data - A string.\n * @param options - An _optional_ object with the _optional_ property\n * `preserveConsecutiveUppercase` that can be used to change the way consecutive\n * uppercase characters are handled. Defaults to `true`.\n * @signature\n * toCamelCase(data);\n * toCamelCase(data, { preserveConsecutiveUppercase });\n * @example\n * toCamelCase(\"hello world\"); // \"helloWorld\"\n * toCamelCase(\"__HELLO_WORLD__\"); // \"helloWorld\"\n * toCamelCase(\"HasHTML\"); // \"hasHTML\"\n * toCamelCase(\"HasHTML\", { preserveConsecutiveUppercase: false }); // \"hasHtml\"\n * @dataFirst\n * @category String\n */\nexport function toCamelCase<T extends string, Options extends CamelCaseOptions>(\n data: T,\n options?: Options,\n): CamelCase<T, CamelCaseOptionsWithDefaults<Options> & BaseCamelCaseOptions>;\n\n/**\n * Converts text to **camelCase** by splitting it into words, lowercasing the\n * first word, capitalizing the rest, then joining them back together.\n *\n * Because it uses the built-in case conversion methods, the function shares\n * their _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_\n * too, making it best suited for simple strings like identifiers and internal\n * keys. For linguistic text processing, use [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)\n * with [`granularity: \"word\"`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter#parameters),\n * [`toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase),\n * and [`toLocaleUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase)\n * which are purpose-built to handle nuances in languages and locales.\n *\n * For other case manipulations see: `toLowerCase`, `toUpperCase`, `capitalize`,\n * `uncapitalize`, `toKebabCase`, `toSnakeCase`, and `toTitleCase`.\n *\n * For *PascalCase* use `capitalize(toCamelCase(data))`.\n *\n * @param options - An _optional_ object with the _optional_ property\n * `preserveConsecutiveUppercase` that can be used to change the way consecutive\n * uppercase characters are handled. Defaults to `true`.\n * @signature\n * toCamelCase()(data);\n * toCamelCase({ preserveConsecutiveUppercase })(data);\n * @example\n * pipe(\"hello world\", toCamelCase()); // \"helloWorld\"\n * pipe(\"__HELLO_WORLD__\", toCamelCase()); // \"helloWorld\"\n * pipe(\"HasHTML\", toCamelCase()); // \"hasHTML\"\n * pipe(\n * \"HasHTML\",\n * toCamelCase({ preserveConsecutiveUppercase: false }),\n * ); // \"hasHtml\"\n * @dataLast\n * @category String\n */\nexport function toCamelCase<Options extends CamelCaseOptions>(\n options?: Options,\n): <T extends string>(\n data: T,\n) => CamelCase<T, CamelCaseOptionsWithDefaults<Options> & BaseCamelCaseOptions>;\n\nexport function toCamelCase(\n dataOrOptions: CamelCaseOptions | string,\n options?: CamelCaseOptions,\n): unknown {\n return typeof dataOrOptions === \"string\"\n ? toCamelCaseImplementation(dataOrOptions, options)\n : (data: string) => toCamelCaseImplementation(data, dataOrOptions);\n}\n\n// Based on the type definition from type-fest.\n// @see https://github.com/sindresorhus/type-fest/blob/main/source/camel-case.d.ts#L76-L80\nconst toCamelCaseImplementation = (\n data: string,\n {\n preserveConsecutiveUppercase = DEFAULT_PRESERVE_CONSECUTIVE_UPPERCASE,\n }: CamelCaseOptions = {},\n): string =>\n words(\n LOWER_CASE_CHARACTER_RE.test(data)\n ? data\n : // If the text doesn't have **any** lower case characters we also lower\n // case everything, but if it does we need to maintain them as it\n // affects the word boundaries.\n data.toLowerCase(),\n )\n .map(\n (word, index) =>\n `${\n // The first word is uncapitalized, the rest are capitalized\n index === 0 ? word[0]!.toLowerCase() : word[0]!.toUpperCase()\n }${preserveConsecutiveUppercase ? word.slice(1) : word.slice(1).toLowerCase()}`,\n )\n .join(\"\");\n"],"mappings":"2GAOM,EAA0B,SAiGhC,SAAgB,EACd,EACA,EACS,CACT,OAAO,OAAO,GAAkB,SAC5B,EAA0B,EAAe,EAAQ,CAChD,GAAiB,EAA0B,EAAM,EAAc,CAKtE,MAAM,GACJ,EACA,CACE,+BAA+B,IACX,EAAE,GAExBA,EAAAA,EACE,EAAwB,KAAK,EAAK,CAC9B,EAIA,EAAK,aAAa,CACvB,CACE,KACE,EAAM,IACL,GAEE,IAAU,EAAI,EAAK,GAAI,aAAa,CAAG,EAAK,GAAI,aAAa,GAC5D,EAA+B,EAAK,MAAM,EAAE,CAAG,EAAK,MAAM,EAAE,CAAC,aAAa,GAChF,CACA,KAAK,GAAG"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./words-Dv8LmnKC.js";const t=/[a-z]/u;function n(e,t){return typeof e==`string`?r(e,t):t=>r(t,e)}const r=(n,{preserveConsecutiveUppercase:r=!0}={})=>e(t.test(n)?n:n.toLowerCase()).map((e,t)=>`${t===0?e[0].toLowerCase():e[0].toUpperCase()}${r?e.slice(1):e.slice(1).toLowerCase()}`).join(``);export{n as toCamelCase};
|
|
2
|
+
//# sourceMappingURL=toCamelCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toCamelCase.js","names":[],"sources":["../src/toCamelCase.ts"],"sourcesContent":["import type {\n CamelCase,\n CamelCaseOptions as BaseCamelCaseOptions,\n} from \"type-fest\";\nimport type { OptionalOptionsWithDefaults } from \"./internal/types/OptionalOptionsWithDefaults\";\nimport { words } from \"./internal/words\";\n\nconst LOWER_CASE_CHARACTER_RE = /[a-z]/u;\n\nconst DEFAULT_PRESERVE_CONSECUTIVE_UPPERCASE = true;\n\ntype CamelCaseOptions = {\n readonly preserveConsecutiveUppercase?: boolean;\n};\n\ntype CamelCaseOptionsWithDefaults<Options extends CamelCaseOptions> =\n OptionalOptionsWithDefaults<\n CamelCaseOptions,\n Options,\n {\n // We use the runtime const for the default type so they stay coupled.\n preserveConsecutiveUppercase: typeof DEFAULT_PRESERVE_CONSECUTIVE_UPPERCASE;\n }\n >;\n\n/**\n * Converts text to **camelCase** by splitting it into words, lowercasing the\n * first word, capitalizing the rest, then joining them back together.\n *\n * Because it uses the built-in case conversion methods, the function shares\n * their _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_\n * too, making it best suited for simple strings like identifiers and internal\n * keys. For linguistic text processing, use [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)\n * with [`granularity: \"word\"`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter#parameters),\n * [`toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase),\n * and [`toLocaleUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase)\n * which are purpose-built to handle nuances in languages and locales.\n *\n * For other case manipulations see: `toLowerCase`, `toUpperCase`, `capitalize`,\n * `uncapitalize`, `toKebabCase`, `toSnakeCase`, and `toTitleCase`.\n *\n * For *PascalCase* use `capitalize(toCamelCase(data))`.\n *\n * @param data - A string.\n * @param options - An _optional_ object with the _optional_ property\n * `preserveConsecutiveUppercase` that can be used to change the way consecutive\n * uppercase characters are handled. Defaults to `true`.\n * @signature\n * toCamelCase(data);\n * toCamelCase(data, { preserveConsecutiveUppercase });\n * @example\n * toCamelCase(\"hello world\"); // \"helloWorld\"\n * toCamelCase(\"__HELLO_WORLD__\"); // \"helloWorld\"\n * toCamelCase(\"HasHTML\"); // \"hasHTML\"\n * toCamelCase(\"HasHTML\", { preserveConsecutiveUppercase: false }); // \"hasHtml\"\n * @dataFirst\n * @category String\n */\nexport function toCamelCase<T extends string, Options extends CamelCaseOptions>(\n data: T,\n options?: Options,\n): CamelCase<T, CamelCaseOptionsWithDefaults<Options> & BaseCamelCaseOptions>;\n\n/**\n * Converts text to **camelCase** by splitting it into words, lowercasing the\n * first word, capitalizing the rest, then joining them back together.\n *\n * Because it uses the built-in case conversion methods, the function shares\n * their _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_\n * too, making it best suited for simple strings like identifiers and internal\n * keys. For linguistic text processing, use [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)\n * with [`granularity: \"word\"`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter#parameters),\n * [`toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase),\n * and [`toLocaleUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase)\n * which are purpose-built to handle nuances in languages and locales.\n *\n * For other case manipulations see: `toLowerCase`, `toUpperCase`, `capitalize`,\n * `uncapitalize`, `toKebabCase`, `toSnakeCase`, and `toTitleCase`.\n *\n * For *PascalCase* use `capitalize(toCamelCase(data))`.\n *\n * @param options - An _optional_ object with the _optional_ property\n * `preserveConsecutiveUppercase` that can be used to change the way consecutive\n * uppercase characters are handled. Defaults to `true`.\n * @signature\n * toCamelCase()(data);\n * toCamelCase({ preserveConsecutiveUppercase })(data);\n * @example\n * pipe(\"hello world\", toCamelCase()); // \"helloWorld\"\n * pipe(\"__HELLO_WORLD__\", toCamelCase()); // \"helloWorld\"\n * pipe(\"HasHTML\", toCamelCase()); // \"hasHTML\"\n * pipe(\n * \"HasHTML\",\n * toCamelCase({ preserveConsecutiveUppercase: false }),\n * ); // \"hasHtml\"\n * @dataLast\n * @category String\n */\nexport function toCamelCase<Options extends CamelCaseOptions>(\n options?: Options,\n): <T extends string>(\n data: T,\n) => CamelCase<T, CamelCaseOptionsWithDefaults<Options> & BaseCamelCaseOptions>;\n\nexport function toCamelCase(\n dataOrOptions: CamelCaseOptions | string,\n options?: CamelCaseOptions,\n): unknown {\n return typeof dataOrOptions === \"string\"\n ? toCamelCaseImplementation(dataOrOptions, options)\n : (data: string) => toCamelCaseImplementation(data, dataOrOptions);\n}\n\n// Based on the type definition from type-fest.\n// @see https://github.com/sindresorhus/type-fest/blob/main/source/camel-case.d.ts#L76-L80\nconst toCamelCaseImplementation = (\n data: string,\n {\n preserveConsecutiveUppercase = DEFAULT_PRESERVE_CONSECUTIVE_UPPERCASE,\n }: CamelCaseOptions = {},\n): string =>\n words(\n LOWER_CASE_CHARACTER_RE.test(data)\n ? data\n : // If the text doesn't have **any** lower case characters we also lower\n // case everything, but if it does we need to maintain them as it\n // affects the word boundaries.\n data.toLowerCase(),\n )\n .map(\n (word, index) =>\n `${\n // The first word is uncapitalized, the rest are capitalized\n index === 0 ? word[0]!.toLowerCase() : word[0]!.toUpperCase()\n }${preserveConsecutiveUppercase ? word.slice(1) : word.slice(1).toLowerCase()}`,\n )\n .join(\"\");\n"],"mappings":"wCAOA,MAAM,EAA0B,SAiGhC,SAAgB,EACd,EACA,EACS,CACT,OAAO,OAAO,GAAkB,SAC5B,EAA0B,EAAe,EAAQ,CAChD,GAAiB,EAA0B,EAAM,EAAc,CAKtE,MAAM,GACJ,EACA,CACE,+BAA+B,IACX,EAAE,GAExB,EACE,EAAwB,KAAK,EAAK,CAC9B,EAIA,EAAK,aAAa,CACvB,CACE,KACE,EAAM,IACL,GAEE,IAAU,EAAI,EAAK,GAAI,aAAa,CAAG,EAAK,GAAI,aAAa,GAC5D,EAA+B,EAAK,MAAM,EAAE,CAAG,EAAK,MAAM,EAAE,CAAC,aAAa,GAChF,CACA,KAAK,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toKebabCase.cjs","names":["purry","words"],"sources":["../src/toKebabCase.ts"],"sourcesContent":["import type { Join, Words } from \"type-fest\";\nimport { words } from \"./internal/words\";\nimport { purry } from \"./purry\";\n\ntype KebabCase<S extends string> = string extends S\n ? string\n : Lowercase<Join<Words<S>, \"-\">>;\n\n/**\n * Converts text to **kebab-case** by splitting it into words and joining them\n * back together with hyphens (`-`), then lowercasing the result.\n *\n * Because it uses [`toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase),\n * the function shares its _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_\n * too, making it best suited for simple strings like identifiers and internal\n * keys. For linguistic text processing, use [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)\n * with [`granularity: \"word\"`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter#parameters), and\n * [`toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase),\n * which are purpose-built to handle nuances in languages and locales.\n *\n * For other case manipulations see: `toLowerCase`, `toUpperCase`, `capitalize`,\n * `uncapitalize`, `toCamelCase`, `toSnakeCase`, and `toTitleCase`.\n *\n * For *COBOL-CASE* use `toUpperCase(toKebabCase(data))`.\n *\n * @param data - A string.\n * @signature\n * toKebabCase(data);\n * @example\n * toKebabCase(\"hello world\"); // \"hello-world\"\n * toKebabCase(\"__HELLO_WORLD__\"); // \"hello-world\"\n * @dataFirst\n * @category String\n */\nexport function toKebabCase<S extends string>(data: S): KebabCase<S>;\n\n/**\n * Converts text to **kebab-case** by splitting it into words and joining them\n * back together with hyphens (`-`), then lowercasing the result.\n *\n * Because it uses [`toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase),\n * the function shares its _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_\n * too, making it best suited for simple strings like identifiers and internal\n * keys. For linguistic text processing, use [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)\n * with [`granularity: \"word\"`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter#parameters), and\n * [`toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase),\n * which are purpose-built to handle nuances in languages and locales.\n *\n * For other case manipulations see: `toLowerCase`, `toUpperCase`, `capitalize`,\n * `uncapitalize`, `toCamelCase`, `toSnakeCase`, and `toTitleCase`.\n *\n * For *COBOL-CASE* use `toUpperCase(toKebabCase(data))`.\n *\n * @signature\n * toKebabCase()(data);\n * @example\n * pipe(\"hello world\", toKebabCase()); // \"hello-world\"\n * pipe(\"__HELLO_WORLD__\", toKebabCase()); // \"hello-world\"\n * @dataLast\n * @category String\n */\nexport function toKebabCase(): <S extends string>(data: S) => KebabCase<S>;\n\nexport function toKebabCase(...args: readonly unknown[]): unknown {\n return purry(toKebabCaseImplementation, args);\n}\n\nconst toKebabCaseImplementation = <S extends string>(data: S): KebabCase<S> =>\n // @ts-expect-error [ts2322] -- To avoid importing our own utilities for this\n // we are using the built-in `join` and `toLowerCase` functions which aren't\n // typed as well. This is equivalent to `toLowerCase(join(words(data), \"-\"))`\n // which TypeScript infers correctly as KebabCase.\n words(data).join(\"-\").toLowerCase();\n"],"mappings":"oIA+DA,SAAgB,EAAY,GAAG,EAAmC,CAChE,OAAOA,EAAAA,MAAM,EAA2B,EAAK,CAG/C,MAAM,EAA+C,GAKnDC,EAAAA,EAAM,EAAK,CAAC,KAAK,IAAI,CAAC,aAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toKebabCase.js","names":[],"sources":["../src/toKebabCase.ts"],"sourcesContent":["import type { Join, Words } from \"type-fest\";\nimport { words } from \"./internal/words\";\nimport { purry } from \"./purry\";\n\ntype KebabCase<S extends string> = string extends S\n ? string\n : Lowercase<Join<Words<S>, \"-\">>;\n\n/**\n * Converts text to **kebab-case** by splitting it into words and joining them\n * back together with hyphens (`-`), then lowercasing the result.\n *\n * Because it uses [`toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase),\n * the function shares its _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_\n * too, making it best suited for simple strings like identifiers and internal\n * keys. For linguistic text processing, use [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)\n * with [`granularity: \"word\"`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter#parameters), and\n * [`toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase),\n * which are purpose-built to handle nuances in languages and locales.\n *\n * For other case manipulations see: `toLowerCase`, `toUpperCase`, `capitalize`,\n * `uncapitalize`, `toCamelCase`, `toSnakeCase`, and `toTitleCase`.\n *\n * For *COBOL-CASE* use `toUpperCase(toKebabCase(data))`.\n *\n * @param data - A string.\n * @signature\n * toKebabCase(data);\n * @example\n * toKebabCase(\"hello world\"); // \"hello-world\"\n * toKebabCase(\"__HELLO_WORLD__\"); // \"hello-world\"\n * @dataFirst\n * @category String\n */\nexport function toKebabCase<S extends string>(data: S): KebabCase<S>;\n\n/**\n * Converts text to **kebab-case** by splitting it into words and joining them\n * back together with hyphens (`-`), then lowercasing the result.\n *\n * Because it uses [`toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase),\n * the function shares its _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_\n * too, making it best suited for simple strings like identifiers and internal\n * keys. For linguistic text processing, use [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)\n * with [`granularity: \"word\"`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter#parameters), and\n * [`toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase),\n * which are purpose-built to handle nuances in languages and locales.\n *\n * For other case manipulations see: `toLowerCase`, `toUpperCase`, `capitalize`,\n * `uncapitalize`, `toCamelCase`, `toSnakeCase`, and `toTitleCase`.\n *\n * For *COBOL-CASE* use `toUpperCase(toKebabCase(data))`.\n *\n * @signature\n * toKebabCase()(data);\n * @example\n * pipe(\"hello world\", toKebabCase()); // \"hello-world\"\n * pipe(\"__HELLO_WORLD__\", toKebabCase()); // \"hello-world\"\n * @dataLast\n * @category String\n */\nexport function toKebabCase(): <S extends string>(data: S) => KebabCase<S>;\n\nexport function toKebabCase(...args: readonly unknown[]): unknown {\n return purry(toKebabCaseImplementation, args);\n}\n\nconst toKebabCaseImplementation = <S extends string>(data: S): KebabCase<S> =>\n // @ts-expect-error [ts2322] -- To avoid importing our own utilities for this\n // we are using the built-in `join` and `toLowerCase` functions which aren't\n // typed as well. This is equivalent to `toLowerCase(join(words(data), \"-\"))`\n // which TypeScript infers correctly as KebabCase.\n words(data).join(\"-\").toLowerCase();\n"],"mappings":"sEA+DA,SAAgB,EAAY,GAAG,EAAmC,CAChE,OAAO,EAAM,EAA2B,EAAK,CAG/C,MAAM,EAA+C,GAKnD,EAAM,EAAK,CAAC,KAAK,IAAI,CAAC,aAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toLowerCase.cjs","names":["purry"],"sources":["../src/toLowerCase.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Replaces all uppercase characters with their lowercase equivalents.\n *\n * This function is a wrapper around the built-in\n * [`String.prototype.toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase)\n * method and shares its _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_.\n *\n * For a more linguistically accurate transformation use [`toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase),\n * and for display purposes use CSS [`text-transform: lowercase;`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform)\n * which *is* locale-aware.\n *\n * For other case manipulations see: `toUpperCase`, `capitalize`,\n * `uncapitalize`, `toCamelCase`, `toKebabCase`, `toSnakeCase`, and\n * `toTitleCase`.\n *\n * @param data - A string.\n * @signature\n * toLowerCase(data);\n * @example\n * toLowerCase(\"Hello World\"); // \"hello world\"\n * @dataFirst\n * @category String\n */\nexport function toLowerCase<T extends string>(data: T): Lowercase<T>;\n\n/**\n * Replaces all uppercase characters with their lowercase equivalents.\n *\n * This function is a wrapper around the built-in\n * [`String.prototype.toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase)\n * method and shares its _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_.\n *\n * For a more linguistically accurate transformation use [`toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase),\n * and for display purposes use CSS [`text-transform: lowercase;`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform)\n * which *is* locale-aware.\n *\n * For other case manipulations see: `toUpperCase`, `capitalize`,\n * `uncapitalize`, `toCamelCase`, `toKebabCase`, `toSnakeCase`, and\n * `toTitleCase`.\n *\n * @signature\n * toLowerCase()(data);\n * @example\n * pipe(\"Hello World\", toLowerCase()); // \"hello world\"\n * @dataLast\n * @category String\n */\nexport function toLowerCase(): <T extends string>(data: T) => Lowercase<T>;\n\nexport function toLowerCase(...args: readonly unknown[]): unknown {\n return purry(toLowerCaseImplementation, args);\n}\n\nconst toLowerCaseImplementation = <T extends string>(data: T): Lowercase<T> =>\n // @ts-expect-error [ts2322] -- TypeScript can't infer this from the code...\n data.toLowerCase();\n"],"mappings":"kGAmDA,SAAgB,EAAY,GAAG,EAAmC,CAChE,OAAOA,EAAAA,MAAM,EAA2B,EAAK,CAG/C,MAAM,EAA+C,GAEnD,EAAK,aAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toLowerCase.js","names":[],"sources":["../src/toLowerCase.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Replaces all uppercase characters with their lowercase equivalents.\n *\n * This function is a wrapper around the built-in\n * [`String.prototype.toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase)\n * method and shares its _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_.\n *\n * For a more linguistically accurate transformation use [`toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase),\n * and for display purposes use CSS [`text-transform: lowercase;`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform)\n * which *is* locale-aware.\n *\n * For other case manipulations see: `toUpperCase`, `capitalize`,\n * `uncapitalize`, `toCamelCase`, `toKebabCase`, `toSnakeCase`, and\n * `toTitleCase`.\n *\n * @param data - A string.\n * @signature\n * toLowerCase(data);\n * @example\n * toLowerCase(\"Hello World\"); // \"hello world\"\n * @dataFirst\n * @category String\n */\nexport function toLowerCase<T extends string>(data: T): Lowercase<T>;\n\n/**\n * Replaces all uppercase characters with their lowercase equivalents.\n *\n * This function is a wrapper around the built-in\n * [`String.prototype.toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase)\n * method and shares its _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_.\n *\n * For a more linguistically accurate transformation use [`toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase),\n * and for display purposes use CSS [`text-transform: lowercase;`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform)\n * which *is* locale-aware.\n *\n * For other case manipulations see: `toUpperCase`, `capitalize`,\n * `uncapitalize`, `toCamelCase`, `toKebabCase`, `toSnakeCase`, and\n * `toTitleCase`.\n *\n * @signature\n * toLowerCase()(data);\n * @example\n * pipe(\"Hello World\", toLowerCase()); // \"hello world\"\n * @dataLast\n * @category String\n */\nexport function toLowerCase(): <T extends string>(data: T) => Lowercase<T>;\n\nexport function toLowerCase(...args: readonly unknown[]): unknown {\n return purry(toLowerCaseImplementation, args);\n}\n\nconst toLowerCaseImplementation = <T extends string>(data: T): Lowercase<T> =>\n // @ts-expect-error [ts2322] -- TypeScript can't infer this from the code...\n data.toLowerCase();\n"],"mappings":"mCAmDA,SAAgB,EAAY,GAAG,EAAmC,CAChE,OAAO,EAAM,EAA2B,EAAK,CAG/C,MAAM,EAA+C,GAEnD,EAAK,aAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toSingle-qs9PC5sP.js","names":[],"sources":["../src/internal/toSingle.ts"],"sourcesContent":["import type { StrictFunction } from \"./types/StrictFunction\";\n\ntype Single<Func> = Func & { readonly single: true };\n\nexport const toSingle = <Func extends StrictFunction>(fn: Func): Single<Func> =>\n Object.assign(fn, { single: true as const });\n"],"mappings":"AAIA,MAAa,EAAyC,GACpD,OAAO,OAAO,EAAI,CAAE,OAAQ,GAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toSingle-z9yHVHGr.cjs","names":[],"sources":["../src/internal/toSingle.ts"],"sourcesContent":["import type { StrictFunction } from \"./types/StrictFunction\";\n\ntype Single<Func> = Func & { readonly single: true };\n\nexport const toSingle = <Func extends StrictFunction>(fn: Func): Single<Func> =>\n Object.assign(fn, { single: true as const });\n"],"mappings":"AAIA,MAAa,EAAyC,GACpD,OAAO,OAAO,EAAI,CAAE,OAAQ,GAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toSnakeCase.cjs","names":["purry","words"],"sources":["../src/toSnakeCase.ts"],"sourcesContent":["import type { Join, Words } from \"type-fest\";\nimport { words } from \"./internal/words\";\nimport { purry } from \"./purry\";\n\ntype SnakeCase<S extends string> = string extends S\n ? string\n : Lowercase<Join<Words<S>, \"_\">>;\n\n/**\n * Converts text to **snake_case** by splitting it into words and joining them\n * back together with underscores (`_`), then lowercasing the result.\n *\n * Because it uses [`toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase),\n * the function shares its _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_\n * too, making it best suited for simple strings like identifiers and internal\n * keys. For linguistic text processing, use [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)\n * with [`granularity: \"word\"`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter#parameters), and\n * [`toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase),\n * which are purpose-built to handle nuances in languages and locales.\n *\n * For other case manipulations see: `toLowerCase`, `toUpperCase`, `capitalize`,\n * `uncapitalize`, `toCamelCase`, `toKebabCase`, and `toTitleCase`.\n *\n * For *CONSTANT_CASE* use `toUpperCase(toSnakeCase(data))`.\n *\n * @param data - A string.\n * @signature\n * toSnakeCase(data);\n * @example\n * toSnakeCase(\"hello world\"); // \"hello_world\"\n * toSnakeCase(\"__HELLO_WORLD__\"); // \"hello_world\"\n * @dataFirst\n * @category String\n */\nexport function toSnakeCase<S extends string>(data: S): SnakeCase<S>;\n\n/**\n * Converts text to **snake_case** by splitting it into words and joining them\n * back together with underscores (`_`), then lowercasing the result.\n *\n * Because it uses [`toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase),\n * the function shares its _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_\n * too, making it best suited for simple strings like identifiers and internal\n * keys. For linguistic text processing, use [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)\n * with [`granularity: \"word\"`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter#parameters), and\n * [`toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase),\n * which are purpose-built to handle nuances in languages and locales.\n *\n * For other case manipulations see: `toLowerCase`, `toUpperCase`, `capitalize`,\n * `uncapitalize`, `toCamelCase`, `toKebabCase`, and `toTitleCase`.\n *\n * For *CONSTANT_CASE* use `toUpperCase(toSnakeCase(data))`.\n *\n * @signature\n * toSnakeCase()(data);\n * @example\n * pipe(\"hello world\", toSnakeCase()); // \"hello_world\"\n * pipe(\"__HELLO_WORLD__\", toSnakeCase()); // \"hello_world\"\n * @dataLast\n * @category String\n */\nexport function toSnakeCase(): <S extends string>(data: S) => SnakeCase<S>;\n\nexport function toSnakeCase(...args: readonly unknown[]): unknown {\n return purry(toSnakeCaseImplementation, args);\n}\n\nconst toSnakeCaseImplementation = <S extends string>(data: S): SnakeCase<S> =>\n // @ts-expect-error [ts2322] -- To avoid importing our own utilities for this\n // we are using the built-in `join` and `toLowerCase` functions which aren't\n // typed as well. This is equivalent to `toLowerCase(join(words(data), \"_\"))`\n // which TypeScript infers correctly as SnakeCase.\n words(data).join(\"_\").toLowerCase();\n"],"mappings":"oIA+DA,SAAgB,EAAY,GAAG,EAAmC,CAChE,OAAOA,EAAAA,MAAM,EAA2B,EAAK,CAG/C,MAAM,EAA+C,GAKnDC,EAAAA,EAAM,EAAK,CAAC,KAAK,IAAI,CAAC,aAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toSnakeCase.js","names":[],"sources":["../src/toSnakeCase.ts"],"sourcesContent":["import type { Join, Words } from \"type-fest\";\nimport { words } from \"./internal/words\";\nimport { purry } from \"./purry\";\n\ntype SnakeCase<S extends string> = string extends S\n ? string\n : Lowercase<Join<Words<S>, \"_\">>;\n\n/**\n * Converts text to **snake_case** by splitting it into words and joining them\n * back together with underscores (`_`), then lowercasing the result.\n *\n * Because it uses [`toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase),\n * the function shares its _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_\n * too, making it best suited for simple strings like identifiers and internal\n * keys. For linguistic text processing, use [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)\n * with [`granularity: \"word\"`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter#parameters), and\n * [`toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase),\n * which are purpose-built to handle nuances in languages and locales.\n *\n * For other case manipulations see: `toLowerCase`, `toUpperCase`, `capitalize`,\n * `uncapitalize`, `toCamelCase`, `toKebabCase`, and `toTitleCase`.\n *\n * For *CONSTANT_CASE* use `toUpperCase(toSnakeCase(data))`.\n *\n * @param data - A string.\n * @signature\n * toSnakeCase(data);\n * @example\n * toSnakeCase(\"hello world\"); // \"hello_world\"\n * toSnakeCase(\"__HELLO_WORLD__\"); // \"hello_world\"\n * @dataFirst\n * @category String\n */\nexport function toSnakeCase<S extends string>(data: S): SnakeCase<S>;\n\n/**\n * Converts text to **snake_case** by splitting it into words and joining them\n * back together with underscores (`_`), then lowercasing the result.\n *\n * Because it uses [`toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase),\n * the function shares its _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_\n * too, making it best suited for simple strings like identifiers and internal\n * keys. For linguistic text processing, use [`Intl.Segmenter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter)\n * with [`granularity: \"word\"`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter#parameters), and\n * [`toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase),\n * which are purpose-built to handle nuances in languages and locales.\n *\n * For other case manipulations see: `toLowerCase`, `toUpperCase`, `capitalize`,\n * `uncapitalize`, `toCamelCase`, `toKebabCase`, and `toTitleCase`.\n *\n * For *CONSTANT_CASE* use `toUpperCase(toSnakeCase(data))`.\n *\n * @signature\n * toSnakeCase()(data);\n * @example\n * pipe(\"hello world\", toSnakeCase()); // \"hello_world\"\n * pipe(\"__HELLO_WORLD__\", toSnakeCase()); // \"hello_world\"\n * @dataLast\n * @category String\n */\nexport function toSnakeCase(): <S extends string>(data: S) => SnakeCase<S>;\n\nexport function toSnakeCase(...args: readonly unknown[]): unknown {\n return purry(toSnakeCaseImplementation, args);\n}\n\nconst toSnakeCaseImplementation = <S extends string>(data: S): SnakeCase<S> =>\n // @ts-expect-error [ts2322] -- To avoid importing our own utilities for this\n // we are using the built-in `join` and `toLowerCase` functions which aren't\n // typed as well. This is equivalent to `toLowerCase(join(words(data), \"_\"))`\n // which TypeScript infers correctly as SnakeCase.\n words(data).join(\"_\").toLowerCase();\n"],"mappings":"sEA+DA,SAAgB,EAAY,GAAG,EAAmC,CAChE,OAAO,EAAM,EAA2B,EAAK,CAG/C,MAAM,EAA+C,GAKnD,EAAM,EAAK,CAAC,KAAK,IAAI,CAAC,aAAa"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./words-CDCUnuNz.cjs`),t=/[a-z]/u;function n(e,t){return typeof e==`string`?r(e,t):t=>r(t,e)}const r=(n,{preserveConsecutiveUppercase:r=!0}={})=>e.t(t.test(n)?n:n.toLowerCase()).map(e=>`${e[0].toUpperCase()}${r?e.slice(1):e.slice(1).toLowerCase()}`).join(` `);exports.toTitleCase=n;
|
|
2
|
+
//# sourceMappingURL=toTitleCase.cjs.map
|