@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":"toTitleCase.cjs","names":["words"],"sources":["../src/toTitleCase.ts"],"sourcesContent":["import type { IsEqual, IsLiteral, Join, Words } 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 TitleCaseOptions = {\n readonly preserveConsecutiveUppercase?: boolean;\n};\n\ntype TitleCaseOptionsWithDefaults<Options extends TitleCaseOptions> =\n OptionalOptionsWithDefaults<\n TitleCaseOptions,\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\ntype TitleCase<S extends string, Options extends TitleCaseOptions> =\n IsLiteral<S> extends true\n ? Join<\n TitleCasedArray<\n Words<IsEqual<S, Uppercase<S>> extends true ? Lowercase<S> : S>,\n TitleCaseOptionsWithDefaults<Options>\n >,\n \" \"\n >\n : string;\n\ntype TitleCasedArray<\n T extends readonly string[],\n Options extends TitleCaseOptions,\n> = {\n [I in keyof T]: Capitalize<\n Options[\"preserveConsecutiveUppercase\"] extends true\n ? T[I]\n : Lowercase<T[I]>\n >;\n};\n\n/**\n * Converts text to **Title Case** by splitting it into words, capitalizing the\n * first letter of each word, then joining them back together with spaces.\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 * making it best suited for simple strings like identifiers and internal keys.\n * 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`, `toCamelCase`, `toKebabCase`, and `toSnakeCase`.\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 * toTitleCase(data);\n * toTitleCase(data, { preserveConsecutiveUppercase });\n * @example\n * toTitleCase(\"hello world\"); // \"Hello World\"\n * toTitleCase(\"--foo-bar--\"); // \"Foo Bar\"\n * toTitleCase(\"fooBar\"); // \"Foo Bar\"\n * toTitleCase(\"__FOO_BAR__\"); // \"Foo Bar\"\n * toTitleCase(\"XMLHttpRequest\"); // \"XML Http Request\"\n * toTitleCase(\"XMLHttpRequest\", { preserveConsecutiveUppercase: false }); // \"Xml Http Request\"\n * @dataFirst\n * @category String\n */\nexport function toTitleCase<S extends string, Options extends TitleCaseOptions>(\n data: S,\n options?: Options,\n): TitleCase<S, Options>;\n\n/**\n * Converts text to **Title Case** by splitting it into words, capitalizing the\n * first letter of each word, then joining them back together with spaces.\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 * making it best suited for simple strings like identifiers and internal keys.\n * 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`, `toCamelCase`, `toKebabCase`, and `toSnakeCase`.\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 * toTitleCase()(data);\n * toTitleCase({ preserveConsecutiveUppercase })(data);\n * @example\n * pipe(\"hello world\", toTitleCase()); // \"Hello World\"\n * pipe(\"--foo-bar--\", toTitleCase()); // \"Foo Bar\"\n * pipe(\"fooBar\", toTitleCase()); // \"Foo Bar\"\n * pipe(\"__FOO_BAR__\", toTitleCase()); // \"Foo Bar\"\n * pipe(\"XMLHttpRequest\", toTitleCase()); // \"XML Http Request\"\n * pipe(\n * \"XMLHttpRequest\",\n * toTitleCase({ preserveConsecutiveUppercase: false }),\n * ); // \"Xml Http Request\"\n * @dataLast\n * @category String\n */\nexport function toTitleCase<Options extends TitleCaseOptions>(\n options?: Options,\n): <S extends string>(data: S) => TitleCase<S, Options>;\n\nexport function toTitleCase(\n dataOrOptions?: TitleCaseOptions | string,\n options?: TitleCaseOptions,\n): unknown {\n return typeof dataOrOptions === \"string\"\n ? toTitleCaseImplementation(dataOrOptions, options)\n : (data: string) => toTitleCaseImplementation(data, dataOrOptions);\n}\n\n// Similar to the implementation used in toCamelCase\nconst toTitleCaseImplementation = (\n data: string,\n {\n preserveConsecutiveUppercase = DEFAULT_PRESERVE_CONSECUTIVE_UPPERCASE,\n }: TitleCaseOptions = {},\n): string =>\n words(\n LOWER_CASE_CHARACTER_RE.test(data)\n ? data\n : // If the text doesn't have **any** lowercase characters, we lowercase\n // everything; otherwise we maintain existing case as it affects word\n // boundaries.\n data.toLowerCase(),\n )\n .map(\n (word) =>\n `${word[0]!.toUpperCase()}${\n preserveConsecutiveUppercase\n ? word.slice(1)\n : word.slice(1).toLowerCase()\n }`,\n )\n .join(\" \");\n"],"mappings":"2GAIM,EAA0B,SAqHhC,SAAgB,EACd,EACA,EACS,CACT,OAAO,OAAO,GAAkB,SAC5B,EAA0B,EAAe,EAAQ,CAChD,GAAiB,EAA0B,EAAM,EAAc,CAItE,MAAM,GACJ,EACA,CACE,+BAA+B,IACX,EAAE,GAExBA,EAAAA,EACE,EAAwB,KAAK,EAAK,CAC9B,EAIA,EAAK,aAAa,CACvB,CACE,IACE,GACC,GAAG,EAAK,GAAI,aAAa,GACvB,EACI,EAAK,MAAM,EAAE,CACb,EAAK,MAAM,EAAE,CAAC,aAAa,GAEpC,CACA,KAAK,IAAI"}
|
|
@@ -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=>`${e[0].toUpperCase()}${r?e.slice(1):e.slice(1).toLowerCase()}`).join(` `);export{n as toTitleCase};
|
|
2
|
+
//# sourceMappingURL=toTitleCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toTitleCase.js","names":[],"sources":["../src/toTitleCase.ts"],"sourcesContent":["import type { IsEqual, IsLiteral, Join, Words } 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 TitleCaseOptions = {\n readonly preserveConsecutiveUppercase?: boolean;\n};\n\ntype TitleCaseOptionsWithDefaults<Options extends TitleCaseOptions> =\n OptionalOptionsWithDefaults<\n TitleCaseOptions,\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\ntype TitleCase<S extends string, Options extends TitleCaseOptions> =\n IsLiteral<S> extends true\n ? Join<\n TitleCasedArray<\n Words<IsEqual<S, Uppercase<S>> extends true ? Lowercase<S> : S>,\n TitleCaseOptionsWithDefaults<Options>\n >,\n \" \"\n >\n : string;\n\ntype TitleCasedArray<\n T extends readonly string[],\n Options extends TitleCaseOptions,\n> = {\n [I in keyof T]: Capitalize<\n Options[\"preserveConsecutiveUppercase\"] extends true\n ? T[I]\n : Lowercase<T[I]>\n >;\n};\n\n/**\n * Converts text to **Title Case** by splitting it into words, capitalizing the\n * first letter of each word, then joining them back together with spaces.\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 * making it best suited for simple strings like identifiers and internal keys.\n * 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`, `toCamelCase`, `toKebabCase`, and `toSnakeCase`.\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 * toTitleCase(data);\n * toTitleCase(data, { preserveConsecutiveUppercase });\n * @example\n * toTitleCase(\"hello world\"); // \"Hello World\"\n * toTitleCase(\"--foo-bar--\"); // \"Foo Bar\"\n * toTitleCase(\"fooBar\"); // \"Foo Bar\"\n * toTitleCase(\"__FOO_BAR__\"); // \"Foo Bar\"\n * toTitleCase(\"XMLHttpRequest\"); // \"XML Http Request\"\n * toTitleCase(\"XMLHttpRequest\", { preserveConsecutiveUppercase: false }); // \"Xml Http Request\"\n * @dataFirst\n * @category String\n */\nexport function toTitleCase<S extends string, Options extends TitleCaseOptions>(\n data: S,\n options?: Options,\n): TitleCase<S, Options>;\n\n/**\n * Converts text to **Title Case** by splitting it into words, capitalizing the\n * first letter of each word, then joining them back together with spaces.\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 * making it best suited for simple strings like identifiers and internal keys.\n * 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`, `toCamelCase`, `toKebabCase`, and `toSnakeCase`.\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 * toTitleCase()(data);\n * toTitleCase({ preserveConsecutiveUppercase })(data);\n * @example\n * pipe(\"hello world\", toTitleCase()); // \"Hello World\"\n * pipe(\"--foo-bar--\", toTitleCase()); // \"Foo Bar\"\n * pipe(\"fooBar\", toTitleCase()); // \"Foo Bar\"\n * pipe(\"__FOO_BAR__\", toTitleCase()); // \"Foo Bar\"\n * pipe(\"XMLHttpRequest\", toTitleCase()); // \"XML Http Request\"\n * pipe(\n * \"XMLHttpRequest\",\n * toTitleCase({ preserveConsecutiveUppercase: false }),\n * ); // \"Xml Http Request\"\n * @dataLast\n * @category String\n */\nexport function toTitleCase<Options extends TitleCaseOptions>(\n options?: Options,\n): <S extends string>(data: S) => TitleCase<S, Options>;\n\nexport function toTitleCase(\n dataOrOptions?: TitleCaseOptions | string,\n options?: TitleCaseOptions,\n): unknown {\n return typeof dataOrOptions === \"string\"\n ? toTitleCaseImplementation(dataOrOptions, options)\n : (data: string) => toTitleCaseImplementation(data, dataOrOptions);\n}\n\n// Similar to the implementation used in toCamelCase\nconst toTitleCaseImplementation = (\n data: string,\n {\n preserveConsecutiveUppercase = DEFAULT_PRESERVE_CONSECUTIVE_UPPERCASE,\n }: TitleCaseOptions = {},\n): string =>\n words(\n LOWER_CASE_CHARACTER_RE.test(data)\n ? data\n : // If the text doesn't have **any** lowercase characters, we lowercase\n // everything; otherwise we maintain existing case as it affects word\n // boundaries.\n data.toLowerCase(),\n )\n .map(\n (word) =>\n `${word[0]!.toUpperCase()}${\n preserveConsecutiveUppercase\n ? word.slice(1)\n : word.slice(1).toLowerCase()\n }`,\n )\n .join(\" \");\n"],"mappings":"wCAIA,MAAM,EAA0B,SAqHhC,SAAgB,EACd,EACA,EACS,CACT,OAAO,OAAO,GAAkB,SAC5B,EAA0B,EAAe,EAAQ,CAChD,GAAiB,EAA0B,EAAM,EAAc,CAItE,MAAM,GACJ,EACA,CACE,+BAA+B,IACX,EAAE,GAExB,EACE,EAAwB,KAAK,EAAK,CAC9B,EAIA,EAAK,aAAa,CACvB,CACE,IACE,GACC,GAAG,EAAK,GAAI,aAAa,GACvB,EACI,EAAK,MAAM,EAAE,CACb,EAAK,MAAM,EAAE,CAAC,aAAa,GAEpC,CACA,KAAK,IAAI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toUpperCase.cjs","names":["purry"],"sources":["../src/toUpperCase.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Replaces all lowercase characters with their uppercase equivalents.\n *\n * This function is a wrapper around the built-in\n * [`String.prototype.toUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase)\n * method and shares its _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase#description)_.\n *\n * For a more linguistically accurate transformation use [`toLocaleUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase),\n * and for display purposes use CSS [`text-transform: uppercase;`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform)\n * which *is* locale-aware.\n *\n * For other case manipulations see: `toLowerCase`, `capitalize`,\n * `uncapitalize`, `toCamelCase`, `toKebabCase`, `toSnakeCase`, and\n * `toTitleCase`.\n *\n * @param data - A string.\n * @signature\n * toUpperCase(data);\n * @example\n * toUpperCase(\"Hello World\"); // \"HELLO WORLD\"\n * @dataFirst\n * @category String\n */\nexport function toUpperCase<T extends string>(data: T): Uppercase<T>;\n\n/**\n * Replaces all lowercase characters with their uppercase equivalents.\n *\n * This function is a wrapper around the built-in\n * [`String.prototype.toUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase)\n * method and shares its _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase#description)_.\n *\n * For a more linguistically accurate transformation use [`toLocaleUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase),\n * and for display purposes use CSS [`text-transform: uppercase;`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform)\n * which *is* locale-aware.\n *\n * For other case manipulations see: `toLowerCase`, `capitalize`,\n * `uncapitalize`, `toCamelCase`, `toKebabCase`, `toSnakeCase`, and\n * `toTitleCase`.\n *\n * @signature\n * toUpperCase()(data);\n * @example\n * pipe(\"Hello World\", toUpperCase()); // \"HELLO WORLD\"\n * @dataLast\n * @category String\n */\nexport function toUpperCase(): <T extends string>(data: T) => Uppercase<T>;\n\nexport function toUpperCase(...args: readonly unknown[]): unknown {\n return purry(toUpperCaseImplementation, args);\n}\n\nconst toUpperCaseImplementation = <T extends string>(data: T): Uppercase<T> =>\n // @ts-expect-error [ts2322] -- TypeScript can't infer this from the code...\n data.toUpperCase();\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":"toUpperCase.js","names":[],"sources":["../src/toUpperCase.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Replaces all lowercase characters with their uppercase equivalents.\n *\n * This function is a wrapper around the built-in\n * [`String.prototype.toUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase)\n * method and shares its _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase#description)_.\n *\n * For a more linguistically accurate transformation use [`toLocaleUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase),\n * and for display purposes use CSS [`text-transform: uppercase;`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform)\n * which *is* locale-aware.\n *\n * For other case manipulations see: `toLowerCase`, `capitalize`,\n * `uncapitalize`, `toCamelCase`, `toKebabCase`, `toSnakeCase`, and\n * `toTitleCase`.\n *\n * @param data - A string.\n * @signature\n * toUpperCase(data);\n * @example\n * toUpperCase(\"Hello World\"); // \"HELLO WORLD\"\n * @dataFirst\n * @category String\n */\nexport function toUpperCase<T extends string>(data: T): Uppercase<T>;\n\n/**\n * Replaces all lowercase characters with their uppercase equivalents.\n *\n * This function is a wrapper around the built-in\n * [`String.prototype.toUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase)\n * method and shares its _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase#description)_.\n *\n * For a more linguistically accurate transformation use [`toLocaleUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase),\n * and for display purposes use CSS [`text-transform: uppercase;`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform)\n * which *is* locale-aware.\n *\n * For other case manipulations see: `toLowerCase`, `capitalize`,\n * `uncapitalize`, `toCamelCase`, `toKebabCase`, `toSnakeCase`, and\n * `toTitleCase`.\n *\n * @signature\n * toUpperCase()(data);\n * @example\n * pipe(\"Hello World\", toUpperCase()); // \"HELLO WORLD\"\n * @dataLast\n * @category String\n */\nexport function toUpperCase(): <T extends string>(data: T) => Uppercase<T>;\n\nexport function toUpperCase(...args: readonly unknown[]): unknown {\n return purry(toUpperCaseImplementation, args);\n}\n\nconst toUpperCaseImplementation = <T extends string>(data: T): Uppercase<T> =>\n // @ts-expect-error [ts2322] -- TypeScript can't infer this from the code...\n data.toUpperCase();\n"],"mappings":"mCAmDA,SAAgB,EAAY,GAAG,EAAmC,CAChE,OAAO,EAAM,EAA2B,EAAK,CAG/C,MAAM,EAA+C,GAEnD,EAAK,aAAa"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e,n,r){return typeof e==`string`?t(e,n,r):r=>t(r,e,n)}function t(e,t,{omission:n=`...`,separator:r}={}){if(e.length<=t)return e;if(t<=0)return``;if(t<n.length)return n.slice(0,t);let i=t-n.length;if(typeof r==`string`){let t=e.lastIndexOf(r,i);t!==-1&&(i=t)}else if(r!==void 0){let t=r.flags.includes(`g`)?r:new RegExp(r.source,`${r.flags}g`),n;for(let{index:r}of e.matchAll(t)){if(r>i)break;n=r}n!==void 0&&(i=n)}return`${e.slice(0,i)}${n}`}exports.truncate=e;
|
|
2
|
+
//# sourceMappingURL=truncate.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"truncate.cjs","names":[],"sources":["../src/truncate.ts"],"sourcesContent":["import type {\n And,\n IsEqual,\n IsNever,\n IsStringLiteral,\n NonNegativeInteger,\n} from \"type-fest\";\nimport type { ClampedIntegerSubtract } from \"./internal/types/ClampedIntegerSubtract\";\nimport type { StringLength } from \"./internal/types/StringLength\";\n\ntype TruncateOptions = {\n readonly omission?: string;\n readonly separator?: string | RegExp;\n};\n\nconst DEFAULT_OMISSION = \"...\";\n\ntype Truncate<\n S extends string,\n N extends number,\n Options extends TruncateOptions,\n> =\n IsNever<NonNegativeInteger<N>> extends true\n ? // There's nothing we can say about the output without a literal, valid,\n // truncation length `N`.\n string\n : IsStringLiteral<S> extends true\n ? TruncateWithOptions<\n S,\n N,\n // TODO: I don't like how I handled the default options object; I want to have everything coupled between the runtime and the type system, but this feels both brittle to changes, and over-verbose.\n Options extends Pick<Required<TruncateOptions>, \"omission\">\n ? Options[\"omission\"]\n : typeof DEFAULT_OMISSION,\n Options extends Pick<Required<TruncateOptions>, \"separator\">\n ? Options[\"separator\"]\n : undefined\n >\n : // There's nothing we can say about the output without a literal input\n // string `S`, the result would always be, at best, just a `string`.\n string;\n\ntype TruncateWithOptions<\n S extends string,\n N extends number,\n Omission extends string,\n Separator extends string | RegExp | undefined,\n> =\n // Distribute the result over unions.\n N extends unknown\n ? // We can short-circuit most of our logic when N is a literal 0.\n IsEqual<N, 0> extends true\n ? \"\"\n : // Distribute the result over unions.\n Omission extends unknown\n ? // When Omission isn't literal we don't know how long it is.\n IsStringLiteral<Omission> extends true\n ? // This mirrors the runtime logic where if `n - omission.length`\n // is not positive then what we end up truncating is Omission\n // itself and not S.\n IsEqual<\n ClampedIntegerSubtract<N, StringLength<Omission>>,\n 0\n > extends true\n ? TruncateLiterals<Omission, N, \"\">\n : And<\n // When S isn't literal the output wouldn't be literal\n // either.\n IsStringLiteral<S>,\n // TODO: Handling non-trivial separators would add a ton of complexity to this type! It's possible (but hard!) to support string literals so I'm leaving this as a TODO; regular expressions are impossible because we can't get the type checker to run them.\n IsEqual<Separator, undefined>\n > extends true\n ? TruncateLiterals<S, N, Omission>\n : string\n : string\n : never\n : never;\n\n/**\n * This is the actual implementation of the truncation logic. It assumes all\n * its params are literals and valid.\n */\ntype TruncateLiterals<\n S extends string,\n N extends number,\n Omission extends string,\n Iteration extends readonly unknown[] = [],\n> = S extends `${infer Character}${infer Rest}`\n ? // The cutoff point N - omission.length leaves room for the omission.\n Iteration[\"length\"] extends ClampedIntegerSubtract<\n N,\n StringLength<Omission>\n >\n ? // The string is only truncated if its total length is longer than N; at\n // the cutoff point this is simplified to comparing the remaining suffix\n // length to the omission length.\n IsLongerThan<S, Omission> extends true\n ? Omission\n : S\n : // Reconstruct string character by character until cutoff.\n `${Character}${TruncateLiterals<Rest, N, Omission, [...Iteration, unknown]>}`\n : // Empty input string results in empty output.\n \"\";\n\n/**\n * An optimized check that efficiently checks if the string A is longer than B.\n */\ntype IsLongerThan<\n A extends string,\n B extends string,\n> = A extends `${string}${infer RestA}`\n ? B extends `${string}${infer RestB}`\n ? IsLongerThan<RestA, RestB>\n : // B is empty and A isn't!\n true\n : // A is empty, even if B is empty, A wouldn't be (strictly) longer.\n false;\n\n/**\n * Truncates strings to a maximum length, adding an ellipsis when truncated.\n *\n * Shorter strings are returned unchanged. If the omission marker is longer than\n * the maximum length, it will be truncated as well.\n *\n * The `separator` argument provides more control by optimistically searching\n * for a matching cutoff point, which could be used to avoid truncating in the\n * middle of a word or other semantic boundary.\n *\n * If you just need to limit the total length of the string, without adding an\n * `omission` or optimizing the cutoff point via `separator`, prefer\n * `sliceString` instead, which runs more efficiently.\n *\n * The function counts Unicode characters, not visual graphemes, and may split\n * emojis, denormalized diacritics, or combining characters, in the middle. For\n * display purposes, prefer CSS [`text-overflow: ellipsis`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow#ellipsis)\n * which is locale-aware and purpose-built for this task.\n *\n * @param data - The input string.\n * @param n - The maximum length of the output string. The output will **never**\n * exceed this length.\n * @param options - An optional options object.\n * @param options.omission - The string that is appended to the end of the\n * output *whenever the input string is truncated*. Default: '...'.\n * @param options.separator - A string or regular expression that defines a\n * cutoff point for the truncation. If multiple cutoff points are found, the one\n * closest to `n` will be used, and if no cutoff point is found then the\n * function will fallback to the trivial cutoff point. Regular expressions are\n * also supported. Default: <none> (which is equivalent to `\"\"` or the regular\n * expression `/./`).\n * @signature\n * truncate(data, n, { omission, separator });\n * @example\n * truncate(\"Hello, world!\", 8); //=> \"Hello...\"\n * truncate(\n * \"cat, dog, mouse\",\n * 12,\n * { omission: \"__\", separator: \",\"},\n * ); //=> \"cat, dog__\"\n * @dataFirst\n * @category String\n */\nexport function truncate<\n S extends string,\n N extends number,\n const Options extends TruncateOptions,\n>(data: S, n: N, options?: Options): Truncate<S, N, Options>;\n\n/**\n * Truncates strings to a maximum length, adding an ellipsis when truncated.\n *\n * Shorter strings are returned unchanged. If the omission marker is longer than\n * the maximum length, it will be truncated as well.\n *\n * The `separator` argument provides more control by optimistically searching\n * for a matching cutoff point, which could be used to avoid truncating in the\n * middle of a word or other semantic boundary.\n *\n * If you just need to limit the total length of the string, without adding an\n * `omission` or optimizing the cutoff point via `separator`, prefer\n * `sliceString` instead, which runs more efficiently.\n *\n * The function counts Unicode characters, not visual graphemes, and may split\n * emojis, denormalized diacritics, or combining characters, in the middle. For\n * display purposes, prefer CSS [`text-overflow: ellipsis`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow#ellipsis)\n * which is locale-aware and purpose-built for this task.\n *\n * @param n - The maximum length of the output string. The output will **never**\n * exceed this length.\n * @param options - An optional options object.\n * @param options.omission - The string that is appended to the end of the\n * output *whenever the input string is truncated*. Default: '...'.\n * @param options.separator - A string or regular expression that defines a\n * cutoff point for the truncation. If multiple cutoff points are found, the one\n * closest to `n` will be used, and if no cutoff point is found then the\n * function will fallback to the trivial cutoff point. Regular expressions are\n * also supported. Default: <none> (which is equivalent to `\"\"` or the regular\n * expression `/./`).\n * @signature\n * truncate(n, { omission, separator })(data);\n * @example\n * pipe(\"Hello, world!\" as const, truncate(8)); //=> \"Hello...\"\n * pipe(\n * \"cat, dog, mouse\" as const,\n * truncate(12, { omission: \"__\", separator: \",\"}),\n * ); //=> \"cat, dog__\"\n * @dataLast\n * @category String\n */\nexport function truncate<\n N extends number,\n const Options extends TruncateOptions,\n>(\n n: N,\n options?: Options,\n): <S extends string>(data: S) => Truncate<S, N, Options>;\n\nexport function truncate(\n dataOrN: string | number,\n nOrOptions?: number | TruncateOptions,\n options?: TruncateOptions,\n): unknown {\n return typeof dataOrN === \"string\"\n ? truncateImplementation(\n dataOrN,\n // @ts-expect-error [ts2345] -- We want to reduce runtime checks to a\n // minimum, and there's no (easy) way to couple params so that when we\n // check one, the others are inferred accordingly.\n nOrOptions,\n options,\n )\n : (data: string) =>\n truncateImplementation(\n data,\n dataOrN,\n // @ts-expect-error [ts2345] -- We want to reduce runtime checks to a\n // minimum, and there's no (easy) way to couple params so that when we\n // check one, the others are inferred accordingly.\n nOrOptions,\n );\n}\n\nfunction truncateImplementation(\n data: string,\n n: number,\n { omission = DEFAULT_OMISSION, separator }: TruncateOptions = {},\n): string {\n if (data.length <= n) {\n // No truncation needed.\n return data;\n }\n\n if (n <= 0) {\n // Avoid weirdness when n isn't positive.\n return \"\";\n }\n\n if (n < omission.length) {\n // TODO [>3]: This was an oversight, there's no value in returning just parts of the omission string itself, with no actual content. Instead, we should truncate the input without adding the omission at all in cases where the omission would completely eclipse the content.\n // Handle cases where the omission itself is too long.\n return omission.slice(0, n);\n }\n\n // Our trivial cutoff is the point where we can add the omission and reach\n // n exactly, this is what we'll use when no separator is provided.\n let cutoff = n - omission.length;\n\n if (typeof separator === \"string\") {\n const lastSeparator = data.lastIndexOf(separator, cutoff);\n if (lastSeparator !== -1) {\n // If we find the separator within the part of the string that would be\n // returned we move the cutoff further so that we also remove it.\n cutoff = lastSeparator;\n }\n } else if (separator !== undefined) {\n const globalSeparator = separator.flags.includes(\"g\")\n ? separator\n : new RegExp(separator.source, `${separator.flags}g`);\n\n let lastSeparator;\n for (const { index } of data.matchAll(globalSeparator)) {\n if (index > cutoff) {\n // We only care about separators within the part of the string that\n // would be returned anyway, once we are past that point we don't care\n // about any further separators.\n break;\n }\n lastSeparator = index;\n }\n if (lastSeparator !== undefined) {\n cutoff = lastSeparator;\n }\n }\n\n // Build the output.\n return `${data.slice(0, cutoff)}${omission}`;\n}\n"],"mappings":"mEAwNA,SAAgB,EACd,EACA,EACA,EACS,CACT,OAAO,OAAO,GAAY,SACtB,EACE,EAIA,EACA,EACD,CACA,GACC,EACE,EACA,EAIA,EACD,CAGT,SAAS,EACP,EACA,EACA,CAAE,WAAW,MAAkB,aAA+B,EAAE,CACxD,CACR,GAAI,EAAK,QAAU,EAEjB,OAAO,EAGT,GAAI,GAAK,EAEP,MAAO,GAGT,GAAI,EAAI,EAAS,OAGf,OAAO,EAAS,MAAM,EAAG,EAAE,CAK7B,IAAI,EAAS,EAAI,EAAS,OAE1B,GAAI,OAAO,GAAc,SAAU,CACjC,IAAM,EAAgB,EAAK,YAAY,EAAW,EAAO,CACrD,IAAkB,KAGpB,EAAS,WAEF,IAAc,IAAA,GAAW,CAClC,IAAM,EAAkB,EAAU,MAAM,SAAS,IAAI,CACjD,EACA,IAAI,OAAO,EAAU,OAAQ,GAAG,EAAU,MAAM,GAAG,CAEnD,EACJ,IAAK,GAAM,CAAE,WAAW,EAAK,SAAS,EAAgB,CAAE,CACtD,GAAI,EAAQ,EAIV,MAEF,EAAgB,EAEd,IAAkB,IAAA,KACpB,EAAS,GAKb,MAAO,GAAG,EAAK,MAAM,EAAG,EAAO,GAAG"}
|
package/dist/truncate.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e,n,r){return typeof e==`string`?t(e,n,r):r=>t(r,e,n)}function t(e,t,{omission:n=`...`,separator:r}={}){if(e.length<=t)return e;if(t<=0)return``;if(t<n.length)return n.slice(0,t);let i=t-n.length;if(typeof r==`string`){let t=e.lastIndexOf(r,i);t!==-1&&(i=t)}else if(r!==void 0){let t=r.flags.includes(`g`)?r:new RegExp(r.source,`${r.flags}g`),n;for(let{index:r}of e.matchAll(t)){if(r>i)break;n=r}n!==void 0&&(i=n)}return`${e.slice(0,i)}${n}`}export{e as truncate};
|
|
2
|
+
//# sourceMappingURL=truncate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"truncate.js","names":[],"sources":["../src/truncate.ts"],"sourcesContent":["import type {\n And,\n IsEqual,\n IsNever,\n IsStringLiteral,\n NonNegativeInteger,\n} from \"type-fest\";\nimport type { ClampedIntegerSubtract } from \"./internal/types/ClampedIntegerSubtract\";\nimport type { StringLength } from \"./internal/types/StringLength\";\n\ntype TruncateOptions = {\n readonly omission?: string;\n readonly separator?: string | RegExp;\n};\n\nconst DEFAULT_OMISSION = \"...\";\n\ntype Truncate<\n S extends string,\n N extends number,\n Options extends TruncateOptions,\n> =\n IsNever<NonNegativeInteger<N>> extends true\n ? // There's nothing we can say about the output without a literal, valid,\n // truncation length `N`.\n string\n : IsStringLiteral<S> extends true\n ? TruncateWithOptions<\n S,\n N,\n // TODO: I don't like how I handled the default options object; I want to have everything coupled between the runtime and the type system, but this feels both brittle to changes, and over-verbose.\n Options extends Pick<Required<TruncateOptions>, \"omission\">\n ? Options[\"omission\"]\n : typeof DEFAULT_OMISSION,\n Options extends Pick<Required<TruncateOptions>, \"separator\">\n ? Options[\"separator\"]\n : undefined\n >\n : // There's nothing we can say about the output without a literal input\n // string `S`, the result would always be, at best, just a `string`.\n string;\n\ntype TruncateWithOptions<\n S extends string,\n N extends number,\n Omission extends string,\n Separator extends string | RegExp | undefined,\n> =\n // Distribute the result over unions.\n N extends unknown\n ? // We can short-circuit most of our logic when N is a literal 0.\n IsEqual<N, 0> extends true\n ? \"\"\n : // Distribute the result over unions.\n Omission extends unknown\n ? // When Omission isn't literal we don't know how long it is.\n IsStringLiteral<Omission> extends true\n ? // This mirrors the runtime logic where if `n - omission.length`\n // is not positive then what we end up truncating is Omission\n // itself and not S.\n IsEqual<\n ClampedIntegerSubtract<N, StringLength<Omission>>,\n 0\n > extends true\n ? TruncateLiterals<Omission, N, \"\">\n : And<\n // When S isn't literal the output wouldn't be literal\n // either.\n IsStringLiteral<S>,\n // TODO: Handling non-trivial separators would add a ton of complexity to this type! It's possible (but hard!) to support string literals so I'm leaving this as a TODO; regular expressions are impossible because we can't get the type checker to run them.\n IsEqual<Separator, undefined>\n > extends true\n ? TruncateLiterals<S, N, Omission>\n : string\n : string\n : never\n : never;\n\n/**\n * This is the actual implementation of the truncation logic. It assumes all\n * its params are literals and valid.\n */\ntype TruncateLiterals<\n S extends string,\n N extends number,\n Omission extends string,\n Iteration extends readonly unknown[] = [],\n> = S extends `${infer Character}${infer Rest}`\n ? // The cutoff point N - omission.length leaves room for the omission.\n Iteration[\"length\"] extends ClampedIntegerSubtract<\n N,\n StringLength<Omission>\n >\n ? // The string is only truncated if its total length is longer than N; at\n // the cutoff point this is simplified to comparing the remaining suffix\n // length to the omission length.\n IsLongerThan<S, Omission> extends true\n ? Omission\n : S\n : // Reconstruct string character by character until cutoff.\n `${Character}${TruncateLiterals<Rest, N, Omission, [...Iteration, unknown]>}`\n : // Empty input string results in empty output.\n \"\";\n\n/**\n * An optimized check that efficiently checks if the string A is longer than B.\n */\ntype IsLongerThan<\n A extends string,\n B extends string,\n> = A extends `${string}${infer RestA}`\n ? B extends `${string}${infer RestB}`\n ? IsLongerThan<RestA, RestB>\n : // B is empty and A isn't!\n true\n : // A is empty, even if B is empty, A wouldn't be (strictly) longer.\n false;\n\n/**\n * Truncates strings to a maximum length, adding an ellipsis when truncated.\n *\n * Shorter strings are returned unchanged. If the omission marker is longer than\n * the maximum length, it will be truncated as well.\n *\n * The `separator` argument provides more control by optimistically searching\n * for a matching cutoff point, which could be used to avoid truncating in the\n * middle of a word or other semantic boundary.\n *\n * If you just need to limit the total length of the string, without adding an\n * `omission` or optimizing the cutoff point via `separator`, prefer\n * `sliceString` instead, which runs more efficiently.\n *\n * The function counts Unicode characters, not visual graphemes, and may split\n * emojis, denormalized diacritics, or combining characters, in the middle. For\n * display purposes, prefer CSS [`text-overflow: ellipsis`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow#ellipsis)\n * which is locale-aware and purpose-built for this task.\n *\n * @param data - The input string.\n * @param n - The maximum length of the output string. The output will **never**\n * exceed this length.\n * @param options - An optional options object.\n * @param options.omission - The string that is appended to the end of the\n * output *whenever the input string is truncated*. Default: '...'.\n * @param options.separator - A string or regular expression that defines a\n * cutoff point for the truncation. If multiple cutoff points are found, the one\n * closest to `n` will be used, and if no cutoff point is found then the\n * function will fallback to the trivial cutoff point. Regular expressions are\n * also supported. Default: <none> (which is equivalent to `\"\"` or the regular\n * expression `/./`).\n * @signature\n * truncate(data, n, { omission, separator });\n * @example\n * truncate(\"Hello, world!\", 8); //=> \"Hello...\"\n * truncate(\n * \"cat, dog, mouse\",\n * 12,\n * { omission: \"__\", separator: \",\"},\n * ); //=> \"cat, dog__\"\n * @dataFirst\n * @category String\n */\nexport function truncate<\n S extends string,\n N extends number,\n const Options extends TruncateOptions,\n>(data: S, n: N, options?: Options): Truncate<S, N, Options>;\n\n/**\n * Truncates strings to a maximum length, adding an ellipsis when truncated.\n *\n * Shorter strings are returned unchanged. If the omission marker is longer than\n * the maximum length, it will be truncated as well.\n *\n * The `separator` argument provides more control by optimistically searching\n * for a matching cutoff point, which could be used to avoid truncating in the\n * middle of a word or other semantic boundary.\n *\n * If you just need to limit the total length of the string, without adding an\n * `omission` or optimizing the cutoff point via `separator`, prefer\n * `sliceString` instead, which runs more efficiently.\n *\n * The function counts Unicode characters, not visual graphemes, and may split\n * emojis, denormalized diacritics, or combining characters, in the middle. For\n * display purposes, prefer CSS [`text-overflow: ellipsis`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow#ellipsis)\n * which is locale-aware and purpose-built for this task.\n *\n * @param n - The maximum length of the output string. The output will **never**\n * exceed this length.\n * @param options - An optional options object.\n * @param options.omission - The string that is appended to the end of the\n * output *whenever the input string is truncated*. Default: '...'.\n * @param options.separator - A string or regular expression that defines a\n * cutoff point for the truncation. If multiple cutoff points are found, the one\n * closest to `n` will be used, and if no cutoff point is found then the\n * function will fallback to the trivial cutoff point. Regular expressions are\n * also supported. Default: <none> (which is equivalent to `\"\"` or the regular\n * expression `/./`).\n * @signature\n * truncate(n, { omission, separator })(data);\n * @example\n * pipe(\"Hello, world!\" as const, truncate(8)); //=> \"Hello...\"\n * pipe(\n * \"cat, dog, mouse\" as const,\n * truncate(12, { omission: \"__\", separator: \",\"}),\n * ); //=> \"cat, dog__\"\n * @dataLast\n * @category String\n */\nexport function truncate<\n N extends number,\n const Options extends TruncateOptions,\n>(\n n: N,\n options?: Options,\n): <S extends string>(data: S) => Truncate<S, N, Options>;\n\nexport function truncate(\n dataOrN: string | number,\n nOrOptions?: number | TruncateOptions,\n options?: TruncateOptions,\n): unknown {\n return typeof dataOrN === \"string\"\n ? truncateImplementation(\n dataOrN,\n // @ts-expect-error [ts2345] -- We want to reduce runtime checks to a\n // minimum, and there's no (easy) way to couple params so that when we\n // check one, the others are inferred accordingly.\n nOrOptions,\n options,\n )\n : (data: string) =>\n truncateImplementation(\n data,\n dataOrN,\n // @ts-expect-error [ts2345] -- We want to reduce runtime checks to a\n // minimum, and there's no (easy) way to couple params so that when we\n // check one, the others are inferred accordingly.\n nOrOptions,\n );\n}\n\nfunction truncateImplementation(\n data: string,\n n: number,\n { omission = DEFAULT_OMISSION, separator }: TruncateOptions = {},\n): string {\n if (data.length <= n) {\n // No truncation needed.\n return data;\n }\n\n if (n <= 0) {\n // Avoid weirdness when n isn't positive.\n return \"\";\n }\n\n if (n < omission.length) {\n // TODO [>3]: This was an oversight, there's no value in returning just parts of the omission string itself, with no actual content. Instead, we should truncate the input without adding the omission at all in cases where the omission would completely eclipse the content.\n // Handle cases where the omission itself is too long.\n return omission.slice(0, n);\n }\n\n // Our trivial cutoff is the point where we can add the omission and reach\n // n exactly, this is what we'll use when no separator is provided.\n let cutoff = n - omission.length;\n\n if (typeof separator === \"string\") {\n const lastSeparator = data.lastIndexOf(separator, cutoff);\n if (lastSeparator !== -1) {\n // If we find the separator within the part of the string that would be\n // returned we move the cutoff further so that we also remove it.\n cutoff = lastSeparator;\n }\n } else if (separator !== undefined) {\n const globalSeparator = separator.flags.includes(\"g\")\n ? separator\n : new RegExp(separator.source, `${separator.flags}g`);\n\n let lastSeparator;\n for (const { index } of data.matchAll(globalSeparator)) {\n if (index > cutoff) {\n // We only care about separators within the part of the string that\n // would be returned anyway, once we are past that point we don't care\n // about any further separators.\n break;\n }\n lastSeparator = index;\n }\n if (lastSeparator !== undefined) {\n cutoff = lastSeparator;\n }\n }\n\n // Build the output.\n return `${data.slice(0, cutoff)}${omission}`;\n}\n"],"mappings":"AAwNA,SAAgB,EACd,EACA,EACA,EACS,CACT,OAAO,OAAO,GAAY,SACtB,EACE,EAIA,EACA,EACD,CACA,GACC,EACE,EACA,EAIA,EACD,CAGT,SAAS,EACP,EACA,EACA,CAAE,WAAW,MAAkB,aAA+B,EAAE,CACxD,CACR,GAAI,EAAK,QAAU,EAEjB,OAAO,EAGT,GAAI,GAAK,EAEP,MAAO,GAGT,GAAI,EAAI,EAAS,OAGf,OAAO,EAAS,MAAM,EAAG,EAAE,CAK7B,IAAI,EAAS,EAAI,EAAS,OAE1B,GAAI,OAAO,GAAc,SAAU,CACjC,IAAM,EAAgB,EAAK,YAAY,EAAW,EAAO,CACrD,IAAkB,KAGpB,EAAS,WAEF,IAAc,IAAA,GAAW,CAClC,IAAM,EAAkB,EAAU,MAAM,SAAS,IAAI,CACjD,EACA,IAAI,OAAO,EAAU,OAAQ,GAAG,EAAU,MAAM,GAAG,CAEnD,EACJ,IAAK,GAAM,CAAE,WAAW,EAAK,SAAS,EAAgB,CAAE,CACtD,GAAI,EAAQ,EAIV,MAEF,EAAgB,EAEd,IAAkB,IAAA,KACpB,EAAS,GAKb,MAAO,GAAG,EAAK,MAAM,EAAG,EAAO,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uncapitalize.cjs","names":["purry"],"sources":["../src/uncapitalize.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Makes the first character of a string lowercase while leaving the rest\n * unchanged.\n *\n * It uses the built-in [`String.prototype.toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase)\n * for the runtime and the built-in [`Uncapitalize`](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html#Uncapitalizestringtype)\n * utility type for typing and thus shares their _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_.\n *\n * For display purposes, prefer using the CSS pseudo-element [`::first-letter`](https://developer.mozilla.org/en-US/docs/Web/CSS/::first-letter) to target\n * just the first letter of the word, and [`text-transform: lowercase`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform#lowercase)\n * to lowercase it. This transformation **is** locale-aware.\n *\n * For other case manipulations see: `toUpperCase`, `toLowerCase`, `capitalize`,\n * `toCamelCase`, `toKebabCase`, `toSnakeCase`, and `toTitleCase`.\n *\n * @param data - A string.\n * @signature\n * uncapitalize(data);\n * @example\n * uncapitalize(\"HELLO WORLD\"); // \"hELLO WORLD\"\n * @dataFirst\n * @category String\n */\nexport function uncapitalize<T extends string>(data: T): Uncapitalize<T>;\n\n/**\n * Makes the first character of a string lowercase while leaving the rest\n * unchanged.\n *\n * It uses the built-in [`String.prototype.toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase)\n * for the runtime and the built-in [`Uncapitalize`](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html#Uncapitalizestringtype)\n * utility type for typing and thus shares their _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_.\n *\n * For display purposes, prefer using the CSS pseudo-element [`::first-letter`](https://developer.mozilla.org/en-US/docs/Web/CSS/::first-letter) to target\n * just the first letter of the word, and [`text-transform: lowercase`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform#lowercase)\n * to lowercase it. This transformation **is** locale-aware.\n *\n * For other case manipulations see: `toUpperCase`, `toLowerCase`, `capitalize`,\n * `toCamelCase`, `toKebabCase`, `toSnakeCase`, and `toTitleCase`.\n *\n * @signature\n * uncapitalize()(data);\n * @example\n * pipe(\"HELLO WORLD\", uncapitalize()); // \"hELLO WORLD\"\n * @dataLast\n * @category String\n */\nexport function uncapitalize(): <T extends string>(data: T) => Uncapitalize<T>;\n\nexport function uncapitalize(...args: readonly unknown[]): unknown {\n return purry(uncapitalizeImplementation, args);\n}\n\nconst uncapitalizeImplementation = <T extends string>(\n data: T,\n): Uncapitalize<T> =>\n `${data[0]?.toLowerCase() ?? \"\"}${data.slice(1)}` as Uncapitalize<T>;\n"],"mappings":"kGAmDA,SAAgB,EAAa,GAAG,EAAmC,CACjE,OAAOA,EAAAA,MAAM,EAA4B,EAAK,CAGhD,MAAM,EACJ,GAEA,GAAG,EAAK,IAAI,aAAa,EAAI,KAAK,EAAK,MAAM,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uncapitalize.js","names":[],"sources":["../src/uncapitalize.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Makes the first character of a string lowercase while leaving the rest\n * unchanged.\n *\n * It uses the built-in [`String.prototype.toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase)\n * for the runtime and the built-in [`Uncapitalize`](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html#Uncapitalizestringtype)\n * utility type for typing and thus shares their _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_.\n *\n * For display purposes, prefer using the CSS pseudo-element [`::first-letter`](https://developer.mozilla.org/en-US/docs/Web/CSS/::first-letter) to target\n * just the first letter of the word, and [`text-transform: lowercase`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform#lowercase)\n * to lowercase it. This transformation **is** locale-aware.\n *\n * For other case manipulations see: `toUpperCase`, `toLowerCase`, `capitalize`,\n * `toCamelCase`, `toKebabCase`, `toSnakeCase`, and `toTitleCase`.\n *\n * @param data - A string.\n * @signature\n * uncapitalize(data);\n * @example\n * uncapitalize(\"HELLO WORLD\"); // \"hELLO WORLD\"\n * @dataFirst\n * @category String\n */\nexport function uncapitalize<T extends string>(data: T): Uncapitalize<T>;\n\n/**\n * Makes the first character of a string lowercase while leaving the rest\n * unchanged.\n *\n * It uses the built-in [`String.prototype.toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase)\n * for the runtime and the built-in [`Uncapitalize`](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html#Uncapitalizestringtype)\n * utility type for typing and thus shares their _[locale inaccuracies](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase#description)_.\n *\n * For display purposes, prefer using the CSS pseudo-element [`::first-letter`](https://developer.mozilla.org/en-US/docs/Web/CSS/::first-letter) to target\n * just the first letter of the word, and [`text-transform: lowercase`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform#lowercase)\n * to lowercase it. This transformation **is** locale-aware.\n *\n * For other case manipulations see: `toUpperCase`, `toLowerCase`, `capitalize`,\n * `toCamelCase`, `toKebabCase`, `toSnakeCase`, and `toTitleCase`.\n *\n * @signature\n * uncapitalize()(data);\n * @example\n * pipe(\"HELLO WORLD\", uncapitalize()); // \"hELLO WORLD\"\n * @dataLast\n * @category String\n */\nexport function uncapitalize(): <T extends string>(data: T) => Uncapitalize<T>;\n\nexport function uncapitalize(...args: readonly unknown[]): unknown {\n return purry(uncapitalizeImplementation, args);\n}\n\nconst uncapitalizeImplementation = <T extends string>(\n data: T,\n): Uncapitalize<T> =>\n `${data[0]?.toLowerCase() ?? \"\"}${data.slice(1)}` as Uncapitalize<T>;\n"],"mappings":"mCAmDA,SAAgB,EAAa,GAAG,EAAmC,CACjE,OAAO,EAAM,EAA4B,EAAK,CAGhD,MAAM,EACJ,GAEA,GAAG,EAAK,IAAI,aAAa,EAAI,KAAK,EAAK,MAAM,EAAE"}
|
package/dist/unique.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./utilityEvaluators-CW0M8vMV.cjs`),t=require(`./purryFromLazy-CwB5T8yd.cjs`);function n(...e){return t.t(r,e)}function r(){let t=new Set;return n=>t.has(n)?e.t:(t.add(n),{done:!1,hasNext:!0,next:n})}exports.unique=n;
|
|
2
|
+
//# sourceMappingURL=unique.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unique.cjs","names":["purryFromLazy","SKIP_ITEM"],"sources":["../src/unique.ts"],"sourcesContent":["import { purryFromLazy } from \"./internal/purryFromLazy\";\nimport type { Deduped } from \"./internal/types/Deduped\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport { SKIP_ITEM } from \"./internal/utilityEvaluators\";\n\n/**\n * Returns a new array containing only one copy of each element in the original\n * list. Elements are compared by reference using Set.\n *\n * @param data - The array to filter.\n * @signature\n * unique(array)\n * @example\n * unique([1, 2, 2, 5, 1, 6, 7]) // => [1, 2, 5, 6, 7]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function unique<T extends IterableContainer>(data: T): Deduped<T>;\n\n/**\n * Returns a new array containing only one copy of each element in the original\n * list. Elements are compared by reference using Set.\n *\n * @signature\n * unique()(array)\n * @example\n * pipe(\n * [1, 2, 2, 5, 1, 6, 7], // only 4 iterations\n * unique(),\n * take(3)\n * ) // => [1, 2, 5]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function unique(): <T extends IterableContainer>(data: T) => Deduped<T>;\n\nexport function unique(...args: readonly unknown[]): unknown {\n return purryFromLazy(lazyImplementation, args);\n}\n\nfunction lazyImplementation<T>(): LazyEvaluator<T> {\n const set = new Set<T>();\n return (value) => {\n if (set.has(value)) {\n return SKIP_ITEM;\n }\n set.add(value);\n return { done: false, hasNext: true, next: value };\n };\n}\n"],"mappings":"iKAuCA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAOA,EAAAA,EAAc,EAAoB,EAAK,CAGhD,SAAS,GAA0C,CACjD,IAAM,EAAM,IAAI,IAChB,MAAQ,IACF,EAAI,IAAI,EAAM,CACTC,EAAAA,GAET,EAAI,IAAI,EAAM,CACP,CAAE,KAAM,GAAO,QAAS,GAAM,KAAM,EAAO"}
|
package/dist/unique.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unique.js","names":[],"sources":["../src/unique.ts"],"sourcesContent":["import { purryFromLazy } from \"./internal/purryFromLazy\";\nimport type { Deduped } from \"./internal/types/Deduped\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport { SKIP_ITEM } from \"./internal/utilityEvaluators\";\n\n/**\n * Returns a new array containing only one copy of each element in the original\n * list. Elements are compared by reference using Set.\n *\n * @param data - The array to filter.\n * @signature\n * unique(array)\n * @example\n * unique([1, 2, 2, 5, 1, 6, 7]) // => [1, 2, 5, 6, 7]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function unique<T extends IterableContainer>(data: T): Deduped<T>;\n\n/**\n * Returns a new array containing only one copy of each element in the original\n * list. Elements are compared by reference using Set.\n *\n * @signature\n * unique()(array)\n * @example\n * pipe(\n * [1, 2, 2, 5, 1, 6, 7], // only 4 iterations\n * unique(),\n * take(3)\n * ) // => [1, 2, 5]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function unique(): <T extends IterableContainer>(data: T) => Deduped<T>;\n\nexport function unique(...args: readonly unknown[]): unknown {\n return purryFromLazy(lazyImplementation, args);\n}\n\nfunction lazyImplementation<T>(): LazyEvaluator<T> {\n const set = new Set<T>();\n return (value) => {\n if (set.has(value)) {\n return SKIP_ITEM;\n }\n set.add(value);\n return { done: false, hasNext: true, next: value };\n };\n}\n"],"mappings":"+FAuCA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAO,EAAc,EAAoB,EAAK,CAGhD,SAAS,GAA0C,CACjD,IAAM,EAAM,IAAI,IAChB,MAAQ,IACF,EAAI,IAAI,EAAM,CACT,GAET,EAAI,IAAI,EAAM,CACP,CAAE,KAAM,GAAO,QAAS,GAAM,KAAM,EAAO"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./utilityEvaluators-CW0M8vMV.cjs`),t=require(`./purryFromLazy-CwB5T8yd.cjs`);function n(...e){return t.t(r,e)}function r(t){let n=t,r=new Set;return(t,i,a)=>{let o=n(t,i,a);return r.has(o)?e.t:(r.add(o),{done:!1,hasNext:!0,next:t})}}exports.uniqueBy=n;
|
|
2
|
+
//# sourceMappingURL=uniqueBy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniqueBy.cjs","names":["purryFromLazy","SKIP_ITEM"],"sources":["../src/uniqueBy.ts"],"sourcesContent":["import { purryFromLazy } from \"./internal/purryFromLazy\";\nimport type { BrandedReturn } from \"./internal/types/BrandedReturn\";\nimport type { Deduped } from \"./internal/types/Deduped\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport { SKIP_ITEM } from \"./internal/utilityEvaluators\";\n\n/**\n * Returns a new array containing only one copy of each element in the original\n * list transformed by a function. Elements are compared by reference using Set.\n *\n * @param data - The array to filter.\n * @param keyFunction - Extracts a value that would be used to compare elements.\n * @signature\n * uniqueBy(data, keyFunction)\n * @example\n * uniqueBy(\n * [{ n: 1 }, { n: 2 }, { n: 2 }, { n: 5 }, { n: 1 }, { n: 6 }, { n: 7 }],\n * (obj) => obj.n,\n * ) // => [{n: 1}, {n: 2}, {n: 5}, {n: 6}, {n: 7}]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function uniqueBy<T extends IterableContainer>(\n data: T,\n keyFunction: (item: T[number], index: number, data: T) => unknown,\n): Deduped<T>;\n\n/**\n * Returns a new array containing only one copy of each element in the original\n * list transformed by a function. Elements are compared by reference using Set.\n *\n * @param keyFunction - Extracts a value that would be used to compare elements.\n * @signature\n * uniqueBy(keyFunction)(data)\n * @example\n * pipe(\n * [{n: 1}, {n: 2}, {n: 2}, {n: 5}, {n: 1}, {n: 6}, {n: 7}], // only 4 iterations\n * uniqueBy(obj => obj.n),\n * take(3)\n * ) // => [{n: 1}, {n: 2}, {n: 5}]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function uniqueBy<T extends IterableContainer>(\n keyFunction: (item: T[number], index: number, data: T) => unknown,\n): (data: T) => Deduped<T>;\n\nexport function uniqueBy(...args: readonly unknown[]): unknown {\n return purryFromLazy(lazyImplementation, args);\n}\n\nfunction lazyImplementation<T>(\n keyFunction: (item: T, index: number, data: readonly T[]) => unknown,\n): LazyEvaluator<T> {\n // @see https://github.com/typescript-eslint/typescript-eslint/issues/9885\n const brandedKeyFunction = keyFunction as BrandedReturn<typeof keyFunction>;\n\n const set = new Set<ReturnType<typeof brandedKeyFunction>>();\n return (value, index, data) => {\n const key = brandedKeyFunction(value, index, data);\n if (set.has(key)) {\n return SKIP_ITEM;\n }\n\n set.add(key);\n return { done: false, hasNext: true, next: value };\n };\n}\n"],"mappings":"iKAkDA,SAAgB,EAAS,GAAG,EAAmC,CAC7D,OAAOA,EAAAA,EAAc,EAAoB,EAAK,CAGhD,SAAS,EACP,EACkB,CAElB,IAAM,EAAqB,EAErB,EAAM,IAAI,IAChB,OAAQ,EAAO,EAAO,IAAS,CAC7B,IAAM,EAAM,EAAmB,EAAO,EAAO,EAAK,CAMlD,OALI,EAAI,IAAI,EAAI,CACPC,EAAAA,GAGT,EAAI,IAAI,EAAI,CACL,CAAE,KAAM,GAAO,QAAS,GAAM,KAAM,EAAO"}
|
package/dist/uniqueBy.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./utilityEvaluators-BQqW5Ir5.js";import{t}from"./purryFromLazy-B-_oTxzb.js";function n(...e){return t(r,e)}function r(t){let n=t,r=new Set;return(t,i,a)=>{let o=n(t,i,a);return r.has(o)?e:(r.add(o),{done:!1,hasNext:!0,next:t})}}export{n as uniqueBy};
|
|
2
|
+
//# sourceMappingURL=uniqueBy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniqueBy.js","names":[],"sources":["../src/uniqueBy.ts"],"sourcesContent":["import { purryFromLazy } from \"./internal/purryFromLazy\";\nimport type { BrandedReturn } from \"./internal/types/BrandedReturn\";\nimport type { Deduped } from \"./internal/types/Deduped\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport { SKIP_ITEM } from \"./internal/utilityEvaluators\";\n\n/**\n * Returns a new array containing only one copy of each element in the original\n * list transformed by a function. Elements are compared by reference using Set.\n *\n * @param data - The array to filter.\n * @param keyFunction - Extracts a value that would be used to compare elements.\n * @signature\n * uniqueBy(data, keyFunction)\n * @example\n * uniqueBy(\n * [{ n: 1 }, { n: 2 }, { n: 2 }, { n: 5 }, { n: 1 }, { n: 6 }, { n: 7 }],\n * (obj) => obj.n,\n * ) // => [{n: 1}, {n: 2}, {n: 5}, {n: 6}, {n: 7}]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function uniqueBy<T extends IterableContainer>(\n data: T,\n keyFunction: (item: T[number], index: number, data: T) => unknown,\n): Deduped<T>;\n\n/**\n * Returns a new array containing only one copy of each element in the original\n * list transformed by a function. Elements are compared by reference using Set.\n *\n * @param keyFunction - Extracts a value that would be used to compare elements.\n * @signature\n * uniqueBy(keyFunction)(data)\n * @example\n * pipe(\n * [{n: 1}, {n: 2}, {n: 2}, {n: 5}, {n: 1}, {n: 6}, {n: 7}], // only 4 iterations\n * uniqueBy(obj => obj.n),\n * take(3)\n * ) // => [{n: 1}, {n: 2}, {n: 5}]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function uniqueBy<T extends IterableContainer>(\n keyFunction: (item: T[number], index: number, data: T) => unknown,\n): (data: T) => Deduped<T>;\n\nexport function uniqueBy(...args: readonly unknown[]): unknown {\n return purryFromLazy(lazyImplementation, args);\n}\n\nfunction lazyImplementation<T>(\n keyFunction: (item: T, index: number, data: readonly T[]) => unknown,\n): LazyEvaluator<T> {\n // @see https://github.com/typescript-eslint/typescript-eslint/issues/9885\n const brandedKeyFunction = keyFunction as BrandedReturn<typeof keyFunction>;\n\n const set = new Set<ReturnType<typeof brandedKeyFunction>>();\n return (value, index, data) => {\n const key = brandedKeyFunction(value, index, data);\n if (set.has(key)) {\n return SKIP_ITEM;\n }\n\n set.add(key);\n return { done: false, hasNext: true, next: value };\n };\n}\n"],"mappings":"+FAkDA,SAAgB,EAAS,GAAG,EAAmC,CAC7D,OAAO,EAAc,EAAoB,EAAK,CAGhD,SAAS,EACP,EACkB,CAElB,IAAM,EAAqB,EAErB,EAAM,IAAI,IAChB,OAAQ,EAAO,EAAO,IAAS,CAC7B,IAAM,EAAM,EAAmB,EAAO,EAAO,EAAK,CAMlD,OALI,EAAI,IAAI,EAAI,CACP,GAGT,EAAI,IAAI,EAAI,CACL,CAAE,KAAM,GAAO,QAAS,GAAM,KAAM,EAAO"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./utilityEvaluators-CW0M8vMV.cjs`),t=require(`./purryFromLazy-CwB5T8yd.cjs`);function n(...e){return t.t(r,e)}const r=t=>(n,r,i)=>i.findIndex((e,i)=>r===i||t(n,e))===r?{done:!1,hasNext:!0,next:n}:e.t;exports.uniqueWith=n;
|
|
2
|
+
//# sourceMappingURL=uniqueWith.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniqueWith.cjs","names":["purryFromLazy","SKIP_ITEM"],"sources":["../src/uniqueWith.ts"],"sourcesContent":["import { purryFromLazy } from \"./internal/purryFromLazy\";\nimport type { Deduped } from \"./internal/types/Deduped\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport { SKIP_ITEM } from \"./internal/utilityEvaluators\";\n\ntype IsEquals<T> = (a: T, b: T) => boolean;\n\n/**\n * Returns a new array containing only one copy of each element in the original\n * list. Elements are compared by custom comparator isEquals.\n *\n * @param data - The array to filter.\n * @param isEquals - The comparator.\n * @signature\n * uniqueWith(array, isEquals)\n * @example\n * uniqueWith(\n * [{a: 1}, {a: 2}, {a: 2}, {a: 5}, {a: 1}, {a: 6}, {a: 7}],\n * equals,\n * ) // => [{a: 1}, {a: 2}, {a: 5}, {a: 6}, {a: 7}]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function uniqueWith<T extends IterableContainer>(\n data: T,\n isEquals: IsEquals<T[number]>,\n): Deduped<T>;\n\n/**\n * Returns a new array containing only one copy of each element in the original\n * list. Elements are compared by custom comparator isEquals.\n *\n * @param isEquals - The comparator.\n * @signature uniqueWith(isEquals)(array)\n * @example\n * uniqueWith(equals)(\n * [{a: 1}, {a: 2}, {a: 2}, {a: 5}, {a: 1}, {a: 6}, {a: 7}],\n * ) // => [{a: 1}, {a: 2}, {a: 5}, {a: 6}, {a: 7}]\n * pipe(\n * [{a: 1}, {a: 2}, {a: 2}, {a: 5}, {a: 1}, {a: 6}, {a: 7}], // only 4 iterations\n * uniqueWith(equals),\n * take(3)\n * ) // => [{a: 1}, {a: 2}, {a: 5}]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function uniqueWith<T extends IterableContainer>(\n isEquals: IsEquals<T[number]>,\n): (data: T) => Deduped<T>;\n\nexport function uniqueWith(...args: readonly unknown[]): unknown {\n return purryFromLazy(lazyImplementation, args);\n}\n\nconst lazyImplementation =\n <T>(isEquals: IsEquals<T>): LazyEvaluator<T> =>\n (value, index, data) => {\n const firstEqualIndex = data.findIndex(\n (otherValue, otherIndex) =>\n index === otherIndex || isEquals(value, otherValue),\n );\n\n // skip items that aren't at the first equal index.\n return firstEqualIndex === index\n ? { done: false, hasNext: true, next: value }\n : SKIP_ITEM;\n };\n"],"mappings":"iKAqDA,SAAgB,EAAW,GAAG,EAAmC,CAC/D,OAAOA,EAAAA,EAAc,EAAoB,EAAK,CAGhD,MAAM,EACA,IACH,EAAO,EAAO,IACW,EAAK,WAC1B,EAAY,IACX,IAAU,GAAc,EAAS,EAAO,EAAW,CACtD,GAG0B,EACvB,CAAE,KAAM,GAAO,QAAS,GAAM,KAAM,EAAO,CAC3CC,EAAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./utilityEvaluators-BQqW5Ir5.js";import{t}from"./purryFromLazy-B-_oTxzb.js";function n(...e){return t(r,e)}const r=t=>(n,r,i)=>i.findIndex((e,i)=>r===i||t(n,e))===r?{done:!1,hasNext:!0,next:n}:e;export{n as uniqueWith};
|
|
2
|
+
//# sourceMappingURL=uniqueWith.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniqueWith.js","names":[],"sources":["../src/uniqueWith.ts"],"sourcesContent":["import { purryFromLazy } from \"./internal/purryFromLazy\";\nimport type { Deduped } from \"./internal/types/Deduped\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport { SKIP_ITEM } from \"./internal/utilityEvaluators\";\n\ntype IsEquals<T> = (a: T, b: T) => boolean;\n\n/**\n * Returns a new array containing only one copy of each element in the original\n * list. Elements are compared by custom comparator isEquals.\n *\n * @param data - The array to filter.\n * @param isEquals - The comparator.\n * @signature\n * uniqueWith(array, isEquals)\n * @example\n * uniqueWith(\n * [{a: 1}, {a: 2}, {a: 2}, {a: 5}, {a: 1}, {a: 6}, {a: 7}],\n * equals,\n * ) // => [{a: 1}, {a: 2}, {a: 5}, {a: 6}, {a: 7}]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function uniqueWith<T extends IterableContainer>(\n data: T,\n isEquals: IsEquals<T[number]>,\n): Deduped<T>;\n\n/**\n * Returns a new array containing only one copy of each element in the original\n * list. Elements are compared by custom comparator isEquals.\n *\n * @param isEquals - The comparator.\n * @signature uniqueWith(isEquals)(array)\n * @example\n * uniqueWith(equals)(\n * [{a: 1}, {a: 2}, {a: 2}, {a: 5}, {a: 1}, {a: 6}, {a: 7}],\n * ) // => [{a: 1}, {a: 2}, {a: 5}, {a: 6}, {a: 7}]\n * pipe(\n * [{a: 1}, {a: 2}, {a: 2}, {a: 5}, {a: 1}, {a: 6}, {a: 7}], // only 4 iterations\n * uniqueWith(equals),\n * take(3)\n * ) // => [{a: 1}, {a: 2}, {a: 5}]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function uniqueWith<T extends IterableContainer>(\n isEquals: IsEquals<T[number]>,\n): (data: T) => Deduped<T>;\n\nexport function uniqueWith(...args: readonly unknown[]): unknown {\n return purryFromLazy(lazyImplementation, args);\n}\n\nconst lazyImplementation =\n <T>(isEquals: IsEquals<T>): LazyEvaluator<T> =>\n (value, index, data) => {\n const firstEqualIndex = data.findIndex(\n (otherValue, otherIndex) =>\n index === otherIndex || isEquals(value, otherValue),\n );\n\n // skip items that aren't at the first equal index.\n return firstEqualIndex === index\n ? { done: false, hasNext: true, next: value }\n : SKIP_ITEM;\n };\n"],"mappings":"+FAqDA,SAAgB,EAAW,GAAG,EAAmC,CAC/D,OAAO,EAAc,EAAoB,EAAK,CAGhD,MAAM,EACA,IACH,EAAO,EAAO,IACW,EAAK,WAC1B,EAAY,IACX,IAAU,GAAc,EAAS,EAAO,EAAW,CACtD,GAG0B,EACvB,CAAE,KAAM,GAAO,QAAS,GAAM,KAAM,EAAO,CAC3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilityEvaluators-BQqW5Ir5.js","names":[],"sources":["../src/internal/utilityEvaluators.ts"],"sourcesContent":["import type { LazyResult } from \"./types/LazyResult\";\n\nconst EMPTY_PIPE = { done: true, hasNext: false } as const;\n\n/**\n * A singleton value for skipping an item in a lazy evaluator.\n */\nexport const SKIP_ITEM = { done: false, hasNext: false } as const;\n\n/**\n * A helper evaluator when we want to return an empty result. It memoizes both\n * the result and the evaluator itself to reduce memory usage.\n */\nexport const lazyEmptyEvaluator = <T>(): LazyResult<T> => EMPTY_PIPE;\n\n/**\n * A helper evaluator when we want to return a shallow clone of the input. It\n * memoizes both the evaluator itself to reduce memory usage.\n */\nexport const lazyIdentityEvaluator = <T>(value: T) =>\n ({\n hasNext: true,\n next: value,\n done: false,\n }) as const;\n"],"mappings":"AAEA,MAAM,EAAa,CAAE,KAAM,GAAM,QAAS,GAAO,CAKpC,EAAY,CAAE,KAAM,GAAO,QAAS,GAAO,CAM3C,MAA6C,EAM7C,EAA4B,IACtC,CACC,QAAS,GACT,KAAM,EACN,KAAM,GACP"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e={done:!0,hasNext:!1},t={done:!1,hasNext:!1},n=()=>e,r=e=>({hasNext:!0,next:e,done:!1});Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|
|
2
|
+
//# sourceMappingURL=utilityEvaluators-CW0M8vMV.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilityEvaluators-CW0M8vMV.cjs","names":[],"sources":["../src/internal/utilityEvaluators.ts"],"sourcesContent":["import type { LazyResult } from \"./types/LazyResult\";\n\nconst EMPTY_PIPE = { done: true, hasNext: false } as const;\n\n/**\n * A singleton value for skipping an item in a lazy evaluator.\n */\nexport const SKIP_ITEM = { done: false, hasNext: false } as const;\n\n/**\n * A helper evaluator when we want to return an empty result. It memoizes both\n * the result and the evaluator itself to reduce memory usage.\n */\nexport const lazyEmptyEvaluator = <T>(): LazyResult<T> => EMPTY_PIPE;\n\n/**\n * A helper evaluator when we want to return a shallow clone of the input. It\n * memoizes both the evaluator itself to reduce memory usage.\n */\nexport const lazyIdentityEvaluator = <T>(value: T) =>\n ({\n hasNext: true,\n next: value,\n done: false,\n }) as const;\n"],"mappings":"AAEA,MAAM,EAAa,CAAE,KAAM,GAAM,QAAS,GAAO,CAKpC,EAAY,CAAE,KAAM,GAAO,QAAS,GAAO,CAM3C,MAA6C,EAM7C,EAA4B,IACtC,CACC,QAAS,GACT,KAAM,EACN,KAAM,GACP"}
|
package/dist/values.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.cjs","names":["purry"],"sources":["../src/values.ts"],"sourcesContent":["import type { EnumerableStringKeyedValueOf } from \"./internal/types/EnumerableStringKeyedValueOf\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\ntype Values<T extends object> = T extends IterableContainer\n ? T[number][]\n : EnumerableStringKeyedValueOf<T>[];\n\n/**\n * Returns a new array containing the values of the array or object.\n *\n * @param data - Either an array or an object.\n * @signature\n * values(source)\n * @example\n * values(['x', 'y', 'z']) // => ['x', 'y', 'z']\n * values({ a: 'x', b: 'y', c: 'z' }) // => ['x', 'y', 'z']\n * @dataFirst\n * @category Object\n */\nexport function values<T extends object>(data: T): Values<T>;\n\n/**\n * Returns a new array containing the values of the array or object.\n *\n * @signature\n * values()(source)\n * @example\n * pipe(['x', 'y', 'z'], values()) // => ['x', 'y', 'z']\n * pipe({ a: 'x', b: 'y', c: 'z' }, values()) // => ['x', 'y', 'z']\n * pipe(\n * { a: 'x', b: 'y', c: 'z' },\n * values(),\n * first(),\n * ) // => 'x'\n * @dataLast\n * @category Object\n */\nexport function values(): <T extends object>(data: T) => Values<T>;\n\nexport function values(...args: readonly unknown[]): unknown {\n return purry(Object.values, args);\n}\n"],"mappings":"kGAwCA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAOA,EAAAA,MAAM,OAAO,OAAQ,EAAK"}
|
package/dist/values.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.js","names":[],"sources":["../src/values.ts"],"sourcesContent":["import type { EnumerableStringKeyedValueOf } from \"./internal/types/EnumerableStringKeyedValueOf\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\ntype Values<T extends object> = T extends IterableContainer\n ? T[number][]\n : EnumerableStringKeyedValueOf<T>[];\n\n/**\n * Returns a new array containing the values of the array or object.\n *\n * @param data - Either an array or an object.\n * @signature\n * values(source)\n * @example\n * values(['x', 'y', 'z']) // => ['x', 'y', 'z']\n * values({ a: 'x', b: 'y', c: 'z' }) // => ['x', 'y', 'z']\n * @dataFirst\n * @category Object\n */\nexport function values<T extends object>(data: T): Values<T>;\n\n/**\n * Returns a new array containing the values of the array or object.\n *\n * @signature\n * values()(source)\n * @example\n * pipe(['x', 'y', 'z'], values()) // => ['x', 'y', 'z']\n * pipe({ a: 'x', b: 'y', c: 'z' }, values()) // => ['x', 'y', 'z']\n * pipe(\n * { a: 'x', b: 'y', c: 'z' },\n * values(),\n * first(),\n * ) // => 'x'\n * @dataLast\n * @category Object\n */\nexport function values(): <T extends object>(data: T) => Values<T>;\n\nexport function values(...args: readonly unknown[]): unknown {\n return purry(Object.values, args);\n}\n"],"mappings":"mCAwCA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAO,EAAM,OAAO,OAAQ,EAAK"}
|
package/dist/when.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(...e){return e.length===2?(n,...r)=>t(n,...e,...r):t(...e)}const t=(e,t,n,...r)=>t(e,...r)?typeof n==`function`?n(e,...r):n.onTrue(e,...r):typeof n==`function`?e:n.onFalse(e,...r);exports.when=e;
|
|
2
|
+
//# sourceMappingURL=when.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when.cjs","names":[],"sources":["../src/when.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any --\n * function inference is stricter and doesn't work well when the arguments\n * aren't typed as `any` in the generic type declaration.\n */\n\nimport type { GuardType } from \"./internal/types/GuardType\";\n\n/**\n * Conditionally run a function based on a predicate, returning its result (similar to\n * the [`?:` (ternary) operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_operator).)\n * If the optional `onFalse` function is not provided, the data will be passed\n * through in those cases.\n *\n * Supports type predicates to refine the types for both branches and the return\n * value.\n *\n * Additional arguments are passed to all functions. In data-first calls, they\n * are taken as variadic arguments; but in data-last calls, they are when the\n * curried function itself is called.\n *\n * For more complex cases check out `conditional`.\n *\n * @param predicate - Decides if the `onTrue` mapper should run or not. If it's\n * a type predicate it also narrows types for the mappers and the return value.\n * @param onTrue - Function to run when the predicate returns `true`.\n * @signature\n * when(predicate, onTrue)(data, ...extraArgs)\n * when(predicate, { onTrue, onFalse })(data, ...extraArgs)\n * @example\n * pipe(data, when(isNullish, constant(42)));\n * pipe(data, when((x) => x > 3, { onTrue: add(1), onFalse: multiply(2) }));\n * map(data, when(isNullish, (x, index) => x + index));\n * @dataLast\n * @category Function\n */\nexport function when<\n T,\n ExtraArgs extends any[],\n Predicate extends (data: T, ...extraArgs: ExtraArgs) => boolean,\n OnTrue extends (\n data: GuardType<Predicate, T>,\n ...extraArgs: ExtraArgs\n ) => unknown,\n>(\n predicate: Predicate,\n onTrue: OnTrue,\n): (\n data: T,\n ...extraArgs: ExtraArgs\n) => Exclude<T, GuardType<Predicate>> | ReturnType<OnTrue>;\nexport function when<\n T,\n ExtraArgs extends any[],\n Predicate extends (data: T, ...extraArgs: ExtraArgs) => boolean,\n OnTrue extends (\n data: GuardType<Predicate, T>,\n ...extraArgs: ExtraArgs\n ) => unknown,\n OnFalse extends (\n data: Exclude<T, GuardType<Predicate>>,\n ...extraArgs: ExtraArgs\n ) => unknown,\n>(\n predicate: Predicate,\n branches: {\n readonly onTrue: OnTrue;\n readonly onFalse: OnFalse;\n },\n): (\n data: T,\n ...extraArgs: ExtraArgs\n) => ReturnType<OnFalse> | ReturnType<OnTrue>;\n\n/**\n * Conditionally run a function based on a predicate, returning its result (similar to\n * the [`?:` (ternary) operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_operator).)\n * If the optional `onFalse` function is not provided, the data will be passed\n * through in those cases.\n *\n * Supports type predicates to refine the types for both branches and the return\n * value.\n *\n * Additional arguments are passed to all functions. In data-first calls, they\n * are taken as variadic arguments; but in data-last calls, they are when the\n * curried function itself is called.\n *\n * For more complex cases check out `conditional`.\n *\n * @param data - The data to be passed to all functions, as the first param.\n * @param predicate - Decides if the `onTrue` mapper should run or not. If it's\n * a type predicate it also narrows types for the mappers and the return value.\n * @param onTrue - The function that would run when the predicate returns\n * `true`.\n * @param extraArgs - Additional arguments. These would be passed as is to the\n * `predicate`, `onTrue`, and `onFalse` functions.\n * @signature\n * when(data, predicate, onTrue, ...extraArgs)\n * when(data, predicate, { onTrue, onFalse }, ...extraArgs)\n * @example\n * when(data, isNullish, constant(42));\n * when(data, (x) => x > 3, { onTrue: add(1), onFalse: multiply(2) });\n * when(data, isString, (x, radix) => parseInt(x, radix), 10);\n * @dataFirst\n * @category Function\n */\nexport function when<\n T,\n ExtraArgs extends any[],\n Predicate extends (data: T, ...extraArgs: ExtraArgs) => boolean,\n OnTrue extends (\n data: GuardType<Predicate, T>,\n ...extraArgs: ExtraArgs\n ) => unknown,\n>(\n data: T,\n predicate: Predicate,\n onTrue: OnTrue,\n ...extraArgs: ExtraArgs\n): Exclude<T, GuardType<Predicate>> | ReturnType<OnTrue>;\nexport function when<\n T,\n ExtraArgs extends any[],\n Predicate extends (data: T, ...extraArgs: ExtraArgs) => boolean,\n OnTrue extends (\n data: GuardType<Predicate, T>,\n ...extraArgs: ExtraArgs\n ) => unknown,\n OnFalse extends (\n data: Exclude<T, GuardType<Predicate>>,\n ...extraArgs: ExtraArgs\n ) => unknown,\n>(\n data: T,\n predicate: Predicate,\n branches: {\n readonly onTrue: OnTrue;\n readonly onFalse: OnFalse;\n },\n ...extraArgs: ExtraArgs\n): ReturnType<OnFalse> | ReturnType<OnTrue>;\n\nexport function when(...args: readonly unknown[]): unknown {\n return args.length === 2\n ? (data: unknown, ...extraArgs: readonly unknown[]) =>\n // @ts-expect-error [ts2556] -- This is OK, we trust our typing of the overloaded functions\n whenImplementation(data, ...args, ...extraArgs)\n : // @ts-expect-error [ts2556] -- This is OK, we trust our typing of the overloaded functions\n whenImplementation(...args);\n}\n\nconst whenImplementation = <T, ExtraArgs extends any[], WhenTrue, WhenFalse>(\n data: T,\n predicate: (data: T, ...extraArgs: ExtraArgs) => boolean,\n onTrueOrBranches:\n | ((data: T, ...extraArgs: ExtraArgs) => WhenTrue)\n | {\n readonly onTrue: (data: T, ...extraArgs: ExtraArgs) => WhenTrue;\n readonly onFalse: (data: T, ...extraArgs: ExtraArgs) => WhenFalse;\n },\n ...extraArgs: ExtraArgs\n): T | WhenFalse | WhenTrue =>\n predicate(data, ...extraArgs)\n ? typeof onTrueOrBranches === \"function\"\n ? onTrueOrBranches(data, ...extraArgs)\n : onTrueOrBranches.onTrue(data, ...extraArgs)\n : typeof onTrueOrBranches === \"function\"\n ? data\n : onTrueOrBranches.onFalse(data, ...extraArgs);\n"],"mappings":"mEA6IA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAO,EAAK,SAAW,GAClB,EAAe,GAAG,IAEjB,EAAmB,EAAM,GAAG,EAAM,GAAG,EAAU,CAEjD,EAAmB,GAAG,EAAK,CAGjC,MAAM,GACJ,EACA,EACA,EAMA,GAAG,IAEH,EAAU,EAAM,GAAG,EAAU,CACzB,OAAO,GAAqB,WAC1B,EAAiB,EAAM,GAAG,EAAU,CACpC,EAAiB,OAAO,EAAM,GAAG,EAAU,CAC7C,OAAO,GAAqB,WAC1B,EACA,EAAiB,QAAQ,EAAM,GAAG,EAAU"}
|
package/dist/when.js
ADDED
package/dist/when.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when.js","names":[],"sources":["../src/when.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any --\n * function inference is stricter and doesn't work well when the arguments\n * aren't typed as `any` in the generic type declaration.\n */\n\nimport type { GuardType } from \"./internal/types/GuardType\";\n\n/**\n * Conditionally run a function based on a predicate, returning its result (similar to\n * the [`?:` (ternary) operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_operator).)\n * If the optional `onFalse` function is not provided, the data will be passed\n * through in those cases.\n *\n * Supports type predicates to refine the types for both branches and the return\n * value.\n *\n * Additional arguments are passed to all functions. In data-first calls, they\n * are taken as variadic arguments; but in data-last calls, they are when the\n * curried function itself is called.\n *\n * For more complex cases check out `conditional`.\n *\n * @param predicate - Decides if the `onTrue` mapper should run or not. If it's\n * a type predicate it also narrows types for the mappers and the return value.\n * @param onTrue - Function to run when the predicate returns `true`.\n * @signature\n * when(predicate, onTrue)(data, ...extraArgs)\n * when(predicate, { onTrue, onFalse })(data, ...extraArgs)\n * @example\n * pipe(data, when(isNullish, constant(42)));\n * pipe(data, when((x) => x > 3, { onTrue: add(1), onFalse: multiply(2) }));\n * map(data, when(isNullish, (x, index) => x + index));\n * @dataLast\n * @category Function\n */\nexport function when<\n T,\n ExtraArgs extends any[],\n Predicate extends (data: T, ...extraArgs: ExtraArgs) => boolean,\n OnTrue extends (\n data: GuardType<Predicate, T>,\n ...extraArgs: ExtraArgs\n ) => unknown,\n>(\n predicate: Predicate,\n onTrue: OnTrue,\n): (\n data: T,\n ...extraArgs: ExtraArgs\n) => Exclude<T, GuardType<Predicate>> | ReturnType<OnTrue>;\nexport function when<\n T,\n ExtraArgs extends any[],\n Predicate extends (data: T, ...extraArgs: ExtraArgs) => boolean,\n OnTrue extends (\n data: GuardType<Predicate, T>,\n ...extraArgs: ExtraArgs\n ) => unknown,\n OnFalse extends (\n data: Exclude<T, GuardType<Predicate>>,\n ...extraArgs: ExtraArgs\n ) => unknown,\n>(\n predicate: Predicate,\n branches: {\n readonly onTrue: OnTrue;\n readonly onFalse: OnFalse;\n },\n): (\n data: T,\n ...extraArgs: ExtraArgs\n) => ReturnType<OnFalse> | ReturnType<OnTrue>;\n\n/**\n * Conditionally run a function based on a predicate, returning its result (similar to\n * the [`?:` (ternary) operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_operator).)\n * If the optional `onFalse` function is not provided, the data will be passed\n * through in those cases.\n *\n * Supports type predicates to refine the types for both branches and the return\n * value.\n *\n * Additional arguments are passed to all functions. In data-first calls, they\n * are taken as variadic arguments; but in data-last calls, they are when the\n * curried function itself is called.\n *\n * For more complex cases check out `conditional`.\n *\n * @param data - The data to be passed to all functions, as the first param.\n * @param predicate - Decides if the `onTrue` mapper should run or not. If it's\n * a type predicate it also narrows types for the mappers and the return value.\n * @param onTrue - The function that would run when the predicate returns\n * `true`.\n * @param extraArgs - Additional arguments. These would be passed as is to the\n * `predicate`, `onTrue`, and `onFalse` functions.\n * @signature\n * when(data, predicate, onTrue, ...extraArgs)\n * when(data, predicate, { onTrue, onFalse }, ...extraArgs)\n * @example\n * when(data, isNullish, constant(42));\n * when(data, (x) => x > 3, { onTrue: add(1), onFalse: multiply(2) });\n * when(data, isString, (x, radix) => parseInt(x, radix), 10);\n * @dataFirst\n * @category Function\n */\nexport function when<\n T,\n ExtraArgs extends any[],\n Predicate extends (data: T, ...extraArgs: ExtraArgs) => boolean,\n OnTrue extends (\n data: GuardType<Predicate, T>,\n ...extraArgs: ExtraArgs\n ) => unknown,\n>(\n data: T,\n predicate: Predicate,\n onTrue: OnTrue,\n ...extraArgs: ExtraArgs\n): Exclude<T, GuardType<Predicate>> | ReturnType<OnTrue>;\nexport function when<\n T,\n ExtraArgs extends any[],\n Predicate extends (data: T, ...extraArgs: ExtraArgs) => boolean,\n OnTrue extends (\n data: GuardType<Predicate, T>,\n ...extraArgs: ExtraArgs\n ) => unknown,\n OnFalse extends (\n data: Exclude<T, GuardType<Predicate>>,\n ...extraArgs: ExtraArgs\n ) => unknown,\n>(\n data: T,\n predicate: Predicate,\n branches: {\n readonly onTrue: OnTrue;\n readonly onFalse: OnFalse;\n },\n ...extraArgs: ExtraArgs\n): ReturnType<OnFalse> | ReturnType<OnTrue>;\n\nexport function when(...args: readonly unknown[]): unknown {\n return args.length === 2\n ? (data: unknown, ...extraArgs: readonly unknown[]) =>\n // @ts-expect-error [ts2556] -- This is OK, we trust our typing of the overloaded functions\n whenImplementation(data, ...args, ...extraArgs)\n : // @ts-expect-error [ts2556] -- This is OK, we trust our typing of the overloaded functions\n whenImplementation(...args);\n}\n\nconst whenImplementation = <T, ExtraArgs extends any[], WhenTrue, WhenFalse>(\n data: T,\n predicate: (data: T, ...extraArgs: ExtraArgs) => boolean,\n onTrueOrBranches:\n | ((data: T, ...extraArgs: ExtraArgs) => WhenTrue)\n | {\n readonly onTrue: (data: T, ...extraArgs: ExtraArgs) => WhenTrue;\n readonly onFalse: (data: T, ...extraArgs: ExtraArgs) => WhenFalse;\n },\n ...extraArgs: ExtraArgs\n): T | WhenFalse | WhenTrue =>\n predicate(data, ...extraArgs)\n ? typeof onTrueOrBranches === \"function\"\n ? onTrueOrBranches(data, ...extraArgs)\n : onTrueOrBranches.onTrue(data, ...extraArgs)\n : typeof onTrueOrBranches === \"function\"\n ? data\n : onTrueOrBranches.onFalse(data, ...extraArgs);\n"],"mappings":"AA6IA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAO,EAAK,SAAW,GAClB,EAAe,GAAG,IAEjB,EAAmB,EAAM,GAAG,EAAM,GAAG,EAAU,CAEjD,EAAmB,GAAG,EAAK,CAGjC,MAAM,GACJ,EACA,EACA,EAMA,GAAG,IAEH,EAAU,EAAM,GAAG,EAAU,CACzB,OAAO,GAAqB,WAC1B,EAAiB,EAAM,GAAG,EAAU,CACpC,EAAiB,OAAO,EAAM,GAAG,EAAU,CAC7C,OAAO,GAAqB,WAC1B,EACA,EAAiB,QAAQ,EAAM,GAAG,EAAU"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=e=>(n,r)=>{if(r===0)return e(n);if(!Number.isInteger(r))throw TypeError(`precision must be an integer: ${r.toString()}`);if(r>15||r<-15)throw RangeError(`precision must be between -15 and 15`);return Number.isNaN(n)||!Number.isFinite(n)?e(n):t(e(t(n,r)),-r)};function t(e,t){let[n,r]=e.toString().split(`e`),i=`${n}e${((r===void 0?0:Number.parseInt(r,10))+t).toString()}`;return Number.parseFloat(i)}export{e as t};
|
|
2
|
+
//# sourceMappingURL=withPrecision-CDZ-Oor7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withPrecision-CDZ-Oor7.js","names":[],"sources":["../src/internal/withPrecision.ts"],"sourcesContent":["// ECMAScript doesn't support more decimal places than 15 anyways,\n// so supporting higher values doesn't make a lot of sense,\n// Considering Number.MAX_SAFE_INTEGER < 10**16, we can use -15\n// for the negative precision limit, too.\nconst MAX_PRECISION = 15;\n\nconst RADIX = 10;\n\nexport const withPrecision =\n (roundingFn: (value: number) => number) =>\n (value: number, precision: number): number => {\n if (precision === 0) {\n return roundingFn(value);\n }\n\n if (!Number.isInteger(precision)) {\n throw new TypeError(\n `precision must be an integer: ${precision.toString()}`,\n );\n }\n\n if (precision > MAX_PRECISION || precision < -MAX_PRECISION) {\n throw new RangeError(\"precision must be between -15 and 15\");\n }\n\n if (Number.isNaN(value) || !Number.isFinite(value)) {\n return roundingFn(value);\n }\n\n const shiftedValue = shiftDecimalPoint(value, precision);\n const rounded = roundingFn(shiftedValue);\n return shiftDecimalPoint(rounded, -precision);\n };\n\n/**\n * Shift a number's decimal point via scientific notation.\n *\n * This takes advantage of the fact that `Number` methods support scientific\n * (e-notation) string natively and avoids working with double-precision\n * floating-point numbers directly, working around their limitations\n * with representing decimal numbers.\n */\nfunction shiftDecimalPoint(value: number, shift: number): number {\n const asString = value.toString();\n const [n, exponent] = asString.split(\"e\");\n\n const shiftedExponent =\n (exponent === undefined ? 0 : Number.parseInt(exponent, RADIX)) + shift;\n\n const shiftedValueAsString = `${n!}e${shiftedExponent.toString()}`;\n\n return Number.parseFloat(shiftedValueAsString);\n}\n"],"mappings":"AAIA,MAIa,EACV,IACA,EAAe,IAA8B,CAC5C,GAAI,IAAc,EAChB,OAAO,EAAW,EAAM,CAG1B,GAAI,CAAC,OAAO,UAAU,EAAU,CAC9B,MAAU,UACR,iCAAiC,EAAU,UAAU,GACtD,CAGH,GAAI,EAAY,IAAiB,EAAY,IAC3C,MAAU,WAAW,uCAAuC,CAS9D,OANI,OAAO,MAAM,EAAM,EAAI,CAAC,OAAO,SAAS,EAAM,CACzC,EAAW,EAAM,CAKnB,EADS,EADK,EAAkB,EAAO,EAAU,CAChB,CACN,CAAC,EAAU,EAWjD,SAAS,EAAkB,EAAe,EAAuB,CAE/D,GAAM,CAAC,EAAG,GADO,EAAM,UAAU,CACF,MAAM,IAAI,CAKnC,EAAuB,GAAG,EAAG,KAFhC,IAAa,IAAA,GAAY,EAAI,OAAO,SAAS,EAAU,GAAM,EAAI,GAEd,UAAU,GAEhE,OAAO,OAAO,WAAW,EAAqB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=e=>(n,r)=>{if(r===0)return e(n);if(!Number.isInteger(r))throw TypeError(`precision must be an integer: ${r.toString()}`);if(r>15||r<-15)throw RangeError(`precision must be between -15 and 15`);return Number.isNaN(n)||!Number.isFinite(n)?e(n):t(e(t(n,r)),-r)};function t(e,t){let[n,r]=e.toString().split(`e`),i=`${n}e${((r===void 0?0:Number.parseInt(r,10))+t).toString()}`;return Number.parseFloat(i)}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
|
2
|
+
//# sourceMappingURL=withPrecision-DED4FjDo.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withPrecision-DED4FjDo.cjs","names":[],"sources":["../src/internal/withPrecision.ts"],"sourcesContent":["// ECMAScript doesn't support more decimal places than 15 anyways,\n// so supporting higher values doesn't make a lot of sense,\n// Considering Number.MAX_SAFE_INTEGER < 10**16, we can use -15\n// for the negative precision limit, too.\nconst MAX_PRECISION = 15;\n\nconst RADIX = 10;\n\nexport const withPrecision =\n (roundingFn: (value: number) => number) =>\n (value: number, precision: number): number => {\n if (precision === 0) {\n return roundingFn(value);\n }\n\n if (!Number.isInteger(precision)) {\n throw new TypeError(\n `precision must be an integer: ${precision.toString()}`,\n );\n }\n\n if (precision > MAX_PRECISION || precision < -MAX_PRECISION) {\n throw new RangeError(\"precision must be between -15 and 15\");\n }\n\n if (Number.isNaN(value) || !Number.isFinite(value)) {\n return roundingFn(value);\n }\n\n const shiftedValue = shiftDecimalPoint(value, precision);\n const rounded = roundingFn(shiftedValue);\n return shiftDecimalPoint(rounded, -precision);\n };\n\n/**\n * Shift a number's decimal point via scientific notation.\n *\n * This takes advantage of the fact that `Number` methods support scientific\n * (e-notation) string natively and avoids working with double-precision\n * floating-point numbers directly, working around their limitations\n * with representing decimal numbers.\n */\nfunction shiftDecimalPoint(value: number, shift: number): number {\n const asString = value.toString();\n const [n, exponent] = asString.split(\"e\");\n\n const shiftedExponent =\n (exponent === undefined ? 0 : Number.parseInt(exponent, RADIX)) + shift;\n\n const shiftedValueAsString = `${n!}e${shiftedExponent.toString()}`;\n\n return Number.parseFloat(shiftedValueAsString);\n}\n"],"mappings":"AAIA,MAIa,EACV,IACA,EAAe,IAA8B,CAC5C,GAAI,IAAc,EAChB,OAAO,EAAW,EAAM,CAG1B,GAAI,CAAC,OAAO,UAAU,EAAU,CAC9B,MAAU,UACR,iCAAiC,EAAU,UAAU,GACtD,CAGH,GAAI,EAAY,IAAiB,EAAY,IAC3C,MAAU,WAAW,uCAAuC,CAS9D,OANI,OAAO,MAAM,EAAM,EAAI,CAAC,OAAO,SAAS,EAAM,CACzC,EAAW,EAAM,CAKnB,EADS,EADK,EAAkB,EAAO,EAAU,CAChB,CACN,CAAC,EAAU,EAWjD,SAAS,EAAkB,EAAe,EAAuB,CAE/D,GAAM,CAAC,EAAG,GADO,EAAM,UAAU,CACF,MAAM,IAAI,CAKnC,EAAuB,GAAG,EAAG,KAFhC,IAAa,IAAA,GAAY,EAAI,OAAO,SAAS,EAAU,GAAM,EAAI,GAEd,UAAU,GAEhE,OAAO,OAAO,WAAW,EAAqB"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const e=new Set([`-`,`_`,...` .
|
|
2
|
+
.\v.\f.\r. .
.\xA0. . . . . . . . . . . . .\u2028.\u2029. . . .`.split(`.`)]),t=t=>{let n=[],r=``,i=()=>{r.length>0&&(n.push(r),r=``)};for(let n of t){if(e.has(n)){i();continue}if(/[a-z]$/u.test(r)&&/[A-Z]/u.test(n))i();else if(/[A-Z][A-Z]$/u.test(r)&&/[a-z]/u.test(n)){let e=r.slice(-1);r=r.slice(0,-1),i(),r=e}else /\d$/u.test(r)!==/\d/u.test(n)&&i();r+=n}return i(),n};Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|
|
3
|
+
//# sourceMappingURL=words-CDCUnuNz.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"words-CDCUnuNz.cjs","names":[],"sources":["../src/internal/words.ts"],"sourcesContent":["import type { Words } from \"type-fest\";\n\n// @see https://github.com/sindresorhus/type-fest/blob/main/source/internal/characters.d.ts#L5-L31\nconst WHITESPACE = [\n \"\\u{9}\", // '\\t'\n \"\\u{A}\", // '\\n'\n \"\\u{B}\", // '\\v'\n \"\\u{C}\", // '\\f'\n \"\\u{D}\", // '\\r'\n \"\\u{20}\", // ' '\n \"\\u{85}\",\n \"\\u{A0}\",\n \"\\u{1680}\",\n \"\\u{2000}\",\n \"\\u{2001}\",\n \"\\u{2002}\",\n \"\\u{2003}\",\n \"\\u{2004}\",\n \"\\u{2005}\",\n \"\\u{2006}\",\n \"\\u{2007}\",\n \"\\u{2008}\",\n \"\\u{2009}\",\n \"\\u{200A}\",\n \"\\u{2028}\",\n \"\\u{2029}\",\n \"\\u{202F}\",\n \"\\u{205F}\",\n \"\\u{3000}\",\n \"\\u{FEFF}\",\n] as const;\n\n// @see https://github.com/sindresorhus/type-fest/blob/main/source/internal/characters.d.ts#L33\nconst WORD_SEPARATORS = new Set([\"-\", \"_\", ...WHITESPACE]);\n\nexport const words = <S extends string>(\n data: S,\n): string extends S ? string[] : Words<S> => {\n const results: string[] = [];\n let word = \"\";\n\n const flush = (): void => {\n if (word.length > 0) {\n results.push(word);\n word = \"\";\n }\n };\n\n for (const character of data) {\n if (WORD_SEPARATORS.has(character)) {\n // Separator encountered; flush the current word & exclude the separator.\n flush();\n continue;\n }\n\n // Detect transitions:\n // 1. Lowercase to uppercase (e.g., \"helloWorld\")\n if (/[a-z]$/u.test(word) && /[A-Z]/u.test(character)) {\n flush();\n }\n // 2. Uppercase to lowercase following multiple uppercase letters (e.g., \"HELLOWorld\")\n // When the text transitions from 2 upper case letters to a lower case\n // letter. (one upper case letter is considered part of the word, e.g.\n // \"Dog\").\n else if (/[A-Z][A-Z]$/u.test(word) && /[a-z]/u.test(character)) {\n const lastCharacter = word.slice(-1);\n word = word.slice(0, -1);\n flush();\n word = lastCharacter;\n }\n // 3. Digit to non-digit or non-digit to digit (e.g., \"123abc\" or \"abc123\")\n else if (/\\d$/u.test(word) !== /\\d/u.test(character)) {\n flush();\n }\n\n // Add the current character to the current word.\n word += character;\n }\n\n // Flush any remaining word.\n flush();\n\n // @ts-expect-error [ts2322] -- TypeScript can't infer this type...\n return results;\n};\n"],"mappings":"AAiCA,MAAM,EAAkB,IAAI,IAAI,CAAC,IAAK,IAAK,GA9BxB;4EA2BlB,CAGwD,CAAC,CAE7C,EACX,GAC2C,CAC3C,IAAM,EAAoB,EAAE,CACxB,EAAO,GAEL,MAAoB,CACpB,EAAK,OAAS,IAChB,EAAQ,KAAK,EAAK,CAClB,EAAO,KAIX,IAAK,IAAM,KAAa,EAAM,CAC5B,GAAI,EAAgB,IAAI,EAAU,CAAE,CAElC,GAAO,CACP,SAKF,GAAI,UAAU,KAAK,EAAK,EAAI,SAAS,KAAK,EAAU,CAClD,GAAO,SAMA,eAAe,KAAK,EAAK,EAAI,SAAS,KAAK,EAAU,CAAE,CAC9D,IAAM,EAAgB,EAAK,MAAM,GAAG,CACpC,EAAO,EAAK,MAAM,EAAG,GAAG,CACxB,GAAO,CACP,EAAO,OAGA,OAAO,KAAK,EAAK,GAAK,MAAM,KAAK,EAAU,EAClD,GAAO,CAIT,GAAQ,EAOV,OAHA,GAAO,CAGA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const e=new Set([`-`,`_`,...` .
|
|
2
|
+
.\v.\f.\r. .
.\xA0. . . . . . . . . . . . .\u2028.\u2029. . . .`.split(`.`)]),t=t=>{let n=[],r=``,i=()=>{r.length>0&&(n.push(r),r=``)};for(let n of t){if(e.has(n)){i();continue}if(/[a-z]$/u.test(r)&&/[A-Z]/u.test(n))i();else if(/[A-Z][A-Z]$/u.test(r)&&/[a-z]/u.test(n)){let e=r.slice(-1);r=r.slice(0,-1),i(),r=e}else /\d$/u.test(r)!==/\d/u.test(n)&&i();r+=n}return i(),n};export{t};
|
|
3
|
+
//# sourceMappingURL=words-Dv8LmnKC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"words-Dv8LmnKC.js","names":[],"sources":["../src/internal/words.ts"],"sourcesContent":["import type { Words } from \"type-fest\";\n\n// @see https://github.com/sindresorhus/type-fest/blob/main/source/internal/characters.d.ts#L5-L31\nconst WHITESPACE = [\n \"\\u{9}\", // '\\t'\n \"\\u{A}\", // '\\n'\n \"\\u{B}\", // '\\v'\n \"\\u{C}\", // '\\f'\n \"\\u{D}\", // '\\r'\n \"\\u{20}\", // ' '\n \"\\u{85}\",\n \"\\u{A0}\",\n \"\\u{1680}\",\n \"\\u{2000}\",\n \"\\u{2001}\",\n \"\\u{2002}\",\n \"\\u{2003}\",\n \"\\u{2004}\",\n \"\\u{2005}\",\n \"\\u{2006}\",\n \"\\u{2007}\",\n \"\\u{2008}\",\n \"\\u{2009}\",\n \"\\u{200A}\",\n \"\\u{2028}\",\n \"\\u{2029}\",\n \"\\u{202F}\",\n \"\\u{205F}\",\n \"\\u{3000}\",\n \"\\u{FEFF}\",\n] as const;\n\n// @see https://github.com/sindresorhus/type-fest/blob/main/source/internal/characters.d.ts#L33\nconst WORD_SEPARATORS = new Set([\"-\", \"_\", ...WHITESPACE]);\n\nexport const words = <S extends string>(\n data: S,\n): string extends S ? string[] : Words<S> => {\n const results: string[] = [];\n let word = \"\";\n\n const flush = (): void => {\n if (word.length > 0) {\n results.push(word);\n word = \"\";\n }\n };\n\n for (const character of data) {\n if (WORD_SEPARATORS.has(character)) {\n // Separator encountered; flush the current word & exclude the separator.\n flush();\n continue;\n }\n\n // Detect transitions:\n // 1. Lowercase to uppercase (e.g., \"helloWorld\")\n if (/[a-z]$/u.test(word) && /[A-Z]/u.test(character)) {\n flush();\n }\n // 2. Uppercase to lowercase following multiple uppercase letters (e.g., \"HELLOWorld\")\n // When the text transitions from 2 upper case letters to a lower case\n // letter. (one upper case letter is considered part of the word, e.g.\n // \"Dog\").\n else if (/[A-Z][A-Z]$/u.test(word) && /[a-z]/u.test(character)) {\n const lastCharacter = word.slice(-1);\n word = word.slice(0, -1);\n flush();\n word = lastCharacter;\n }\n // 3. Digit to non-digit or non-digit to digit (e.g., \"123abc\" or \"abc123\")\n else if (/\\d$/u.test(word) !== /\\d/u.test(character)) {\n flush();\n }\n\n // Add the current character to the current word.\n word += character;\n }\n\n // Flush any remaining word.\n flush();\n\n // @ts-expect-error [ts2322] -- TypeScript can't infer this type...\n return results;\n};\n"],"mappings":"AAiCA,MAAM,EAAkB,IAAI,IAAI,CAAC,IAAK,IAAK,GA9BxB;4EA2BlB,CAGwD,CAAC,CAE7C,EACX,GAC2C,CAC3C,IAAM,EAAoB,EAAE,CACxB,EAAO,GAEL,MAAoB,CACpB,EAAK,OAAS,IAChB,EAAQ,KAAK,EAAK,CAClB,EAAO,KAIX,IAAK,IAAM,KAAa,EAAM,CAC5B,GAAI,EAAgB,IAAI,EAAU,CAAE,CAElC,GAAO,CACP,SAKF,GAAI,UAAU,KAAK,EAAK,EAAI,SAAS,KAAK,EAAU,CAClD,GAAO,SAMA,eAAe,KAAK,EAAK,EAAI,SAAS,KAAK,EAAU,CAAE,CAC9D,IAAM,EAAgB,EAAK,MAAM,GAAG,CACpC,EAAO,EAAK,MAAM,EAAG,GAAG,CACxB,GAAO,CACP,EAAO,OAGA,OAAO,KAAK,EAAK,GAAK,MAAM,KAAK,EAAU,EAClD,GAAO,CAIT,GAAQ,EAOV,OAHA,GAAO,CAGA"}
|
package/dist/zip.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,r)}const n=(e,t)=>e.length<t.length?e.map((e,n)=>[e,t[n]]):t.map((t,n)=>[e[n],t]),r=e=>(t,n)=>({hasNext:!0,next:[t,e[n]],done:n>=e.length-1});exports.zip=t;
|
|
2
|
+
//# sourceMappingURL=zip.cjs.map
|
package/dist/zip.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip.cjs","names":["purry"],"sources":["../src/zip.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport { purry } from \"./purry\";\n\ntype Zipped<Left extends IterableContainer, Right extends IterableContainer> =\n // If the array is empty the output is empty, no surprises\n Left extends readonly []\n ? []\n : Right extends readonly []\n ? []\n : // Are the two inputs both tuples with a non-rest first item?\n Left extends readonly [infer LeftHead, ...infer LeftRest]\n ? Right extends readonly [infer RightHead, ...infer RightRest]\n ? // ...Then take that first item from both and recurse\n [[LeftHead, RightHead], ...Zipped<LeftRest, RightRest>]\n : // Is only one of the inputs a tuple (with a non-rest first item)?\n // Then take that item, and match it with whatever the type of the other *array's* items are.\n [[LeftHead, Right[number]], ...Zipped<LeftRest, Right>]\n : Right extends readonly [infer RightHead, ...infer RightRest]\n ? [[Left[number], RightHead], ...Zipped<Left, RightRest>]\n : // Both inputs are not tuples (with a non-rest first item, they might be tuples with non-rest last item(s))\n // So the output is just the \"trivial\" zip result.\n [Left[number], Right[number]][];\n\n/**\n * Creates a new list from two supplied lists by pairing up equally-positioned\n * items. The length of the returned list will match the shortest of the two\n * inputs.\n *\n * @param first - The first input list.\n * @param second - The second input list.\n * @signature\n * zip(first, second)\n * @example\n * zip([1, 2], ['a', 'b']) // => [[1, 'a'], [2, 'b']]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function zip<F extends IterableContainer, S extends IterableContainer>(\n first: F,\n second: S,\n): Zipped<F, S>;\n\n/**\n * Creates a new list from two supplied lists by pairing up equally-positioned\n * items. The length of the returned list will match the shortest of the two\n * inputs.\n *\n * @param second - The second input list.\n * @signature\n * zip(second)(first)\n * @example\n * zip(['a', 'b'])([1, 2]) // => [[1, 'a'], [2, 'b']]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function zip<S extends IterableContainer>(\n second: S,\n): <F extends IterableContainer>(first: F) => Zipped<F, S>;\n\nexport function zip(...args: readonly unknown[]): unknown {\n return purry(zipImplementation, args, lazyImplementation);\n}\n\nconst zipImplementation = <\n F extends IterableContainer,\n S extends IterableContainer,\n>(\n first: F,\n second: S,\n): Zipped<F, S> =>\n (first.length < second.length\n ? first.map((item, index) => [item, second[index]])\n : second.map((item, index) => [first[index], item])) as Zipped<F, S>;\n\nconst lazyImplementation =\n <F extends IterableContainer, S extends IterableContainer>(\n second: S,\n ): LazyEvaluator<F[number], [F[number], S[number]]> =>\n (value, index) => ({\n hasNext: true,\n next: [value, second[index]],\n done: index >= second.length - 1,\n });\n"],"mappings":"kGA8DA,SAAgB,EAAI,GAAG,EAAmC,CACxD,OAAOA,EAAAA,MAAM,EAAmB,EAAM,EAAmB,CAG3D,MAAM,GAIJ,EACA,IAEC,EAAM,OAAS,EAAO,OACnB,EAAM,KAAK,EAAM,IAAU,CAAC,EAAM,EAAO,GAAO,CAAC,CACjD,EAAO,KAAK,EAAM,IAAU,CAAC,EAAM,GAAQ,EAAK,CAAC,CAEjD,EAEF,IAED,EAAO,KAAW,CACjB,QAAS,GACT,KAAM,CAAC,EAAO,EAAO,GAAO,CAC5B,KAAM,GAAS,EAAO,OAAS,EAChC"}
|
package/dist/zip.js
ADDED
package/dist/zip.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zip.js","names":[],"sources":["../src/zip.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport { purry } from \"./purry\";\n\ntype Zipped<Left extends IterableContainer, Right extends IterableContainer> =\n // If the array is empty the output is empty, no surprises\n Left extends readonly []\n ? []\n : Right extends readonly []\n ? []\n : // Are the two inputs both tuples with a non-rest first item?\n Left extends readonly [infer LeftHead, ...infer LeftRest]\n ? Right extends readonly [infer RightHead, ...infer RightRest]\n ? // ...Then take that first item from both and recurse\n [[LeftHead, RightHead], ...Zipped<LeftRest, RightRest>]\n : // Is only one of the inputs a tuple (with a non-rest first item)?\n // Then take that item, and match it with whatever the type of the other *array's* items are.\n [[LeftHead, Right[number]], ...Zipped<LeftRest, Right>]\n : Right extends readonly [infer RightHead, ...infer RightRest]\n ? [[Left[number], RightHead], ...Zipped<Left, RightRest>]\n : // Both inputs are not tuples (with a non-rest first item, they might be tuples with non-rest last item(s))\n // So the output is just the \"trivial\" zip result.\n [Left[number], Right[number]][];\n\n/**\n * Creates a new list from two supplied lists by pairing up equally-positioned\n * items. The length of the returned list will match the shortest of the two\n * inputs.\n *\n * @param first - The first input list.\n * @param second - The second input list.\n * @signature\n * zip(first, second)\n * @example\n * zip([1, 2], ['a', 'b']) // => [[1, 'a'], [2, 'b']]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function zip<F extends IterableContainer, S extends IterableContainer>(\n first: F,\n second: S,\n): Zipped<F, S>;\n\n/**\n * Creates a new list from two supplied lists by pairing up equally-positioned\n * items. The length of the returned list will match the shortest of the two\n * inputs.\n *\n * @param second - The second input list.\n * @signature\n * zip(second)(first)\n * @example\n * zip(['a', 'b'])([1, 2]) // => [[1, 'a'], [2, 'b']]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function zip<S extends IterableContainer>(\n second: S,\n): <F extends IterableContainer>(first: F) => Zipped<F, S>;\n\nexport function zip(...args: readonly unknown[]): unknown {\n return purry(zipImplementation, args, lazyImplementation);\n}\n\nconst zipImplementation = <\n F extends IterableContainer,\n S extends IterableContainer,\n>(\n first: F,\n second: S,\n): Zipped<F, S> =>\n (first.length < second.length\n ? first.map((item, index) => [item, second[index]])\n : second.map((item, index) => [first[index], item])) as Zipped<F, S>;\n\nconst lazyImplementation =\n <F extends IterableContainer, S extends IterableContainer>(\n second: S,\n ): LazyEvaluator<F[number], [F[number], S[number]]> =>\n (value, index) => ({\n hasNext: true,\n next: [value, second[index]],\n done: index >= second.length - 1,\n });\n"],"mappings":"mCA8DA,SAAgB,EAAI,GAAG,EAAmC,CACxD,OAAO,EAAM,EAAmB,EAAM,EAAmB,CAG3D,MAAM,GAIJ,EACA,IAEC,EAAM,OAAS,EAAO,OACnB,EAAM,KAAK,EAAM,IAAU,CAAC,EAAM,EAAO,GAAO,CAAC,CACjD,EAAO,KAAK,EAAM,IAAU,CAAC,EAAM,GAAQ,EAAK,CAAC,CAEjD,EAEF,IAED,EAAO,KAAW,CACjB,QAAS,GACT,KAAM,CAAC,EAAO,EAAO,GAAO,CAC5B,KAAM,GAAS,EAAO,OAAS,EAChC"}
|
package/dist/zipWith.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./lazyDataLastImpl-DdpJofHC.cjs`);function t(t,i,a){return typeof t==`function`?(e,r)=>n(e,r,t):typeof i==`function`?e.t(n,[t,i],r):n(t,i,a)}function n(e,t,n){let r=[e,t];return e.length<t.length?e.map((e,i)=>n(e,t[i],i,r)):t.map((t,i)=>n(e[i],t,i,r))}const r=(e,t)=>(n,r,i)=>({next:t(n,e[r],r,[i,e]),hasNext:!0,done:r>=e.length-1});exports.zipWith=t;
|
|
2
|
+
//# sourceMappingURL=zipWith.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zipWith.cjs","names":["lazyDataLastImpl"],"sources":["../src/zipWith.ts"],"sourcesContent":["import { lazyDataLastImpl } from \"./internal/lazyDataLastImpl\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\n\ntype ZippingFunction<\n T1 extends IterableContainer = IterableContainer,\n T2 extends IterableContainer = IterableContainer,\n Value = unknown,\n> = (\n first: T1[number],\n second: T2[number],\n index: number,\n data: readonly [first: T1, second: T2],\n) => Value;\n\n/**\n * Creates a new list from two supplied lists by calling the supplied function\n * with the same-positioned element from each list.\n *\n * @param fn - The function applied to each position of the list.\n * @signature\n * zipWith(fn)(first, second)\n * @example\n * zipWith((a: string, b: string) => a + b)(['1', '2', '3'], ['a', 'b', 'c']) // => ['1a', '2b', '3c']\n * @category Array\n */\nexport function zipWith<TItem1, TItem2, Value>(\n fn: ZippingFunction<readonly TItem1[], readonly TItem2[], Value>,\n): (first: readonly TItem1[], second: readonly TItem2[]) => Value[];\n\n/**\n * Creates a new list from two supplied lists by calling the supplied function\n * with the same-positioned element from each list.\n *\n * @param second - The second input list.\n * @param fn - The function applied to each position of the list.\n * @signature\n * zipWith(second, fn)(first)\n * @example\n * pipe(['1', '2', '3'], zipWith(['a', 'b', 'c'], (a, b) => a + b)) // => ['1a', '2b', '3c']\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function zipWith<\n T1 extends IterableContainer,\n T2 extends IterableContainer,\n Value,\n>(second: T2, fn: ZippingFunction<T1, T2, Value>): (first: T1) => Value[];\n\n/**\n * Creates a new list from two supplied lists by calling the supplied function\n * with the same-positioned element from each list.\n *\n * @param first - The first input list.\n * @param second - The second input list.\n * @param fn - The function applied to each position of the list.\n * @signature\n * zipWith(first, second, fn)\n * @example\n * zipWith(['1', '2', '3'], ['a', 'b', 'c'], (a, b) => a + b) // => ['1a', '2b', '3c']\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function zipWith<\n T1 extends IterableContainer,\n T2 extends IterableContainer,\n Value,\n>(first: T1, second: T2, fn: ZippingFunction<T1, T2, Value>): Value[];\n\nexport function zipWith(\n arg0: IterableContainer | ZippingFunction,\n arg1?: IterableContainer | ZippingFunction,\n arg2?: ZippingFunction,\n): unknown {\n if (typeof arg0 === \"function\") {\n // Both datum's last\n return (data1: IterableContainer, data2: IterableContainer) =>\n zipWithImplementation(data1, data2, arg0);\n }\n\n if (typeof arg1 === \"function\") {\n // dataLast\n return lazyDataLastImpl(\n zipWithImplementation,\n [arg0, arg1],\n lazyImplementation,\n );\n }\n\n // dataFirst. Notice that we assert that the arguments are defined to reduce\n // the number of runtime checks that would otherwise be needed to make\n // TypeScript happy here. Because this is an internal implementation and we\n // are protected by the function typing itself this is fine!\n return zipWithImplementation(arg0, arg1!, arg2!);\n}\n\nfunction zipWithImplementation<\n T1 extends IterableContainer,\n T2 extends IterableContainer,\n Value,\n>(first: T1, second: T2, fn: ZippingFunction<T1, T2, Value>): Value[] {\n const datum = [first, second] as const;\n return first.length < second.length\n ? first.map((item, index) => fn(item, second[index], index, datum))\n : second.map((item, index) => fn(first[index], item, index, datum));\n}\n\nconst lazyImplementation =\n <T1, T2 extends IterableContainer, Value>(\n second: T2,\n fn: ZippingFunction<readonly T1[], T2, Value>,\n ): LazyEvaluator<T1, Value> =>\n (value, index, data) => ({\n next: fn(value, second[index], index, [data, second]),\n hasNext: true,\n done: index >= second.length - 1,\n });\n"],"mappings":"sHAuEA,SAAgB,EACd,EACA,EACA,EACS,CAoBT,OAnBI,OAAO,GAAS,YAEV,EAA0B,IAChC,EAAsB,EAAO,EAAO,EAAK,CAGzC,OAAO,GAAS,WAEXA,EAAAA,EACL,EACA,CAAC,EAAM,EAAK,CACZ,EACD,CAOI,EAAsB,EAAM,EAAO,EAAM,CAGlD,SAAS,EAIP,EAAW,EAAY,EAA6C,CACpE,IAAM,EAAQ,CAAC,EAAO,EAAO,CAC7B,OAAO,EAAM,OAAS,EAAO,OACzB,EAAM,KAAK,EAAM,IAAU,EAAG,EAAM,EAAO,GAAQ,EAAO,EAAM,CAAC,CACjE,EAAO,KAAK,EAAM,IAAU,EAAG,EAAM,GAAQ,EAAM,EAAO,EAAM,CAAC,CAGvE,MAAM,GAEF,EACA,KAED,EAAO,EAAO,KAAU,CACvB,KAAM,EAAG,EAAO,EAAO,GAAQ,EAAO,CAAC,EAAM,EAAO,CAAC,CACrD,QAAS,GACT,KAAM,GAAS,EAAO,OAAS,EAChC"}
|
package/dist/zipWith.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./lazyDataLastImpl-DtF3cihj.js";function t(t,i,a){return typeof t==`function`?(e,r)=>n(e,r,t):typeof i==`function`?e(n,[t,i],r):n(t,i,a)}function n(e,t,n){let r=[e,t];return e.length<t.length?e.map((e,i)=>n(e,t[i],i,r)):t.map((t,i)=>n(e[i],t,i,r))}const r=(e,t)=>(n,r,i)=>({next:t(n,e[r],r,[i,e]),hasNext:!0,done:r>=e.length-1});export{t as zipWith};
|
|
2
|
+
//# sourceMappingURL=zipWith.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zipWith.js","names":[],"sources":["../src/zipWith.ts"],"sourcesContent":["import { lazyDataLastImpl } from \"./internal/lazyDataLastImpl\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\n\ntype ZippingFunction<\n T1 extends IterableContainer = IterableContainer,\n T2 extends IterableContainer = IterableContainer,\n Value = unknown,\n> = (\n first: T1[number],\n second: T2[number],\n index: number,\n data: readonly [first: T1, second: T2],\n) => Value;\n\n/**\n * Creates a new list from two supplied lists by calling the supplied function\n * with the same-positioned element from each list.\n *\n * @param fn - The function applied to each position of the list.\n * @signature\n * zipWith(fn)(first, second)\n * @example\n * zipWith((a: string, b: string) => a + b)(['1', '2', '3'], ['a', 'b', 'c']) // => ['1a', '2b', '3c']\n * @category Array\n */\nexport function zipWith<TItem1, TItem2, Value>(\n fn: ZippingFunction<readonly TItem1[], readonly TItem2[], Value>,\n): (first: readonly TItem1[], second: readonly TItem2[]) => Value[];\n\n/**\n * Creates a new list from two supplied lists by calling the supplied function\n * with the same-positioned element from each list.\n *\n * @param second - The second input list.\n * @param fn - The function applied to each position of the list.\n * @signature\n * zipWith(second, fn)(first)\n * @example\n * pipe(['1', '2', '3'], zipWith(['a', 'b', 'c'], (a, b) => a + b)) // => ['1a', '2b', '3c']\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function zipWith<\n T1 extends IterableContainer,\n T2 extends IterableContainer,\n Value,\n>(second: T2, fn: ZippingFunction<T1, T2, Value>): (first: T1) => Value[];\n\n/**\n * Creates a new list from two supplied lists by calling the supplied function\n * with the same-positioned element from each list.\n *\n * @param first - The first input list.\n * @param second - The second input list.\n * @param fn - The function applied to each position of the list.\n * @signature\n * zipWith(first, second, fn)\n * @example\n * zipWith(['1', '2', '3'], ['a', 'b', 'c'], (a, b) => a + b) // => ['1a', '2b', '3c']\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function zipWith<\n T1 extends IterableContainer,\n T2 extends IterableContainer,\n Value,\n>(first: T1, second: T2, fn: ZippingFunction<T1, T2, Value>): Value[];\n\nexport function zipWith(\n arg0: IterableContainer | ZippingFunction,\n arg1?: IterableContainer | ZippingFunction,\n arg2?: ZippingFunction,\n): unknown {\n if (typeof arg0 === \"function\") {\n // Both datum's last\n return (data1: IterableContainer, data2: IterableContainer) =>\n zipWithImplementation(data1, data2, arg0);\n }\n\n if (typeof arg1 === \"function\") {\n // dataLast\n return lazyDataLastImpl(\n zipWithImplementation,\n [arg0, arg1],\n lazyImplementation,\n );\n }\n\n // dataFirst. Notice that we assert that the arguments are defined to reduce\n // the number of runtime checks that would otherwise be needed to make\n // TypeScript happy here. Because this is an internal implementation and we\n // are protected by the function typing itself this is fine!\n return zipWithImplementation(arg0, arg1!, arg2!);\n}\n\nfunction zipWithImplementation<\n T1 extends IterableContainer,\n T2 extends IterableContainer,\n Value,\n>(first: T1, second: T2, fn: ZippingFunction<T1, T2, Value>): Value[] {\n const datum = [first, second] as const;\n return first.length < second.length\n ? first.map((item, index) => fn(item, second[index], index, datum))\n : second.map((item, index) => fn(first[index], item, index, datum));\n}\n\nconst lazyImplementation =\n <T1, T2 extends IterableContainer, Value>(\n second: T2,\n fn: ZippingFunction<readonly T1[], T2, Value>,\n ): LazyEvaluator<T1, Value> =>\n (value, index, data) => ({\n next: fn(value, second[index], index, [data, second]),\n hasNext: true,\n done: index >= second.length - 1,\n });\n"],"mappings":"mDAuEA,SAAgB,EACd,EACA,EACA,EACS,CAoBT,OAnBI,OAAO,GAAS,YAEV,EAA0B,IAChC,EAAsB,EAAO,EAAO,EAAK,CAGzC,OAAO,GAAS,WAEX,EACL,EACA,CAAC,EAAM,EAAK,CACZ,EACD,CAOI,EAAsB,EAAM,EAAO,EAAM,CAGlD,SAAS,EAIP,EAAW,EAAY,EAA6C,CACpE,IAAM,EAAQ,CAAC,EAAO,EAAO,CAC7B,OAAO,EAAM,OAAS,EAAO,OACzB,EAAM,KAAK,EAAM,IAAU,EAAG,EAAM,EAAO,GAAQ,EAAO,EAAM,CAAC,CACjE,EAAO,KAAK,EAAM,IAAU,EAAG,EAAM,GAAQ,EAAM,EAAO,EAAM,CAAC,CAGvE,MAAM,GAEF,EACA,KAED,EAAO,EAAO,KAAU,CACvB,KAAM,EAAG,EAAO,EAAO,GAAQ,EAAO,CAAC,EAAM,EAAO,CAAC,CACrD,QAAS,GACT,KAAM,GAAS,EAAO,OAAS,EAChC"}
|