@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":"isSymbol.cjs","names":[],"sources":["../src/isSymbol.ts"],"sourcesContent":["import type { NarrowedTo } from \"./internal/types/NarrowedTo\";\n\n/**\n * A function that checks if the passed parameter is a symbol and narrows its type accordingly.\n *\n * @param data - The variable to check.\n * @returns True if the passed input is a symbol, false otherwise.\n * @signature\n * isSymbol(data)\n * @example\n * isSymbol(Symbol('foo')) //=> true\n * isSymbol(1) //=> false\n * @category Guard\n */\nexport function isSymbol<T>(data: T | symbol): data is NarrowedTo<T, symbol> {\n return typeof data === \"symbol\";\n}\n"],"mappings":"mEAcA,SAAgB,EAAY,EAAiD,CAC3E,OAAO,OAAO,GAAS"}
|
package/dist/isSymbol.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isSymbol.js","names":[],"sources":["../src/isSymbol.ts"],"sourcesContent":["import type { NarrowedTo } from \"./internal/types/NarrowedTo\";\n\n/**\n * A function that checks if the passed parameter is a symbol and narrows its type accordingly.\n *\n * @param data - The variable to check.\n * @returns True if the passed input is a symbol, false otherwise.\n * @signature\n * isSymbol(data)\n * @example\n * isSymbol(Symbol('foo')) //=> true\n * isSymbol(1) //=> false\n * @category Guard\n */\nexport function isSymbol<T>(data: T | symbol): data is NarrowedTo<T, symbol> {\n return typeof data === \"symbol\";\n}\n"],"mappings":"AAcA,SAAgB,EAAY,EAAiD,CAC3E,OAAO,OAAO,GAAS"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isTruthy.cjs","names":[],"sources":["../src/isTruthy.ts"],"sourcesContent":["/**\n * A function that checks if the passed parameter is truthy and narrows its type accordingly.\n *\n * @param data - The variable to check.\n * @returns True if the passed input is truthy, false otherwise.\n * @signature\n * isTruthy(data)\n * @example\n * isTruthy('somethingElse') //=> true\n * isTruthy(null) //=> false\n * isTruthy(undefined) //=> false\n * isTruthy(false) //=> false\n * isTruthy(0) //=> false\n * isTruthy('') //=> false\n * @category Guard\n */\n// eslint-disable-next-line unicorn/prefer-native-coercion-functions -- This is not entirely correct, our isTruthy also coerces the type.\nexport function isTruthy<T>(\n data: T,\n): data is Exclude<T, \"\" | 0 | false | null | undefined> {\n return Boolean(data);\n}\n"],"mappings":"mEAiBA,SAAgB,EACd,EACuD,CACvD,MAAO,EAAQ"}
|
package/dist/isTruthy.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isTruthy.js","names":[],"sources":["../src/isTruthy.ts"],"sourcesContent":["/**\n * A function that checks if the passed parameter is truthy and narrows its type accordingly.\n *\n * @param data - The variable to check.\n * @returns True if the passed input is truthy, false otherwise.\n * @signature\n * isTruthy(data)\n * @example\n * isTruthy('somethingElse') //=> true\n * isTruthy(null) //=> false\n * isTruthy(undefined) //=> false\n * isTruthy(false) //=> false\n * isTruthy(0) //=> false\n * isTruthy('') //=> false\n * @category Guard\n */\n// eslint-disable-next-line unicorn/prefer-native-coercion-functions -- This is not entirely correct, our isTruthy also coerces the type.\nexport function isTruthy<T>(\n data: T,\n): data is Exclude<T, \"\" | 0 | false | null | undefined> {\n return Boolean(data);\n}\n"],"mappings":"AAiBA,SAAgB,EACd,EACuD,CACvD,MAAO,EAAQ"}
|
package/dist/join.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"join.cjs","names":["purry"],"sources":["../src/join.ts"],"sourcesContent":["import type { Join } from \"type-fest\";\nimport { purry } from \"./purry\";\n\n// Copied from type-fest, from the Join type.\ntype JoinableItem = bigint | boolean | number | string | null | undefined;\n\n/**\n * Joins the elements of the array by: casting them to a string and\n * concatenating them one to the other, with the provided glue string in between\n * every two elements.\n *\n * When called on a tuple and with stricter item types (union of literal values,\n * the result is strictly typed to the tuples shape and it's item types).\n *\n * @param data - The array to join.\n * @param glue - The string to put in between every two elements.\n * @signature\n * join(data, glue)\n * @example\n * join([1,2,3], \",\") // => \"1,2,3\" (typed `string`)\n * join(['a','b','c'], \"\") // => \"abc\" (typed `string`)\n * join(['hello', 'world'] as const, \" \") // => \"hello world\" (typed `hello world`)\n * @dataFirst\n * @category Array\n */\nexport function join<\n T extends readonly JoinableItem[] | [],\n Glue extends string,\n>(data: T, glue: Glue): Join<T, Glue>;\n\n/**\n * Joins the elements of the array by: casting them to a string and\n * concatenating them one to the other, with the provided glue string in between\n * every two elements.\n *\n * When called on a tuple and with stricter item types (union of literal values,\n * the result is strictly typed to the tuples shape and it's item types).\n *\n * @param glue - The string to put in between every two elements.\n * @signature\n * join(glue)(data)\n * @example\n * pipe([1,2,3], join(\",\")) // => \"1,2,3\" (typed `string`)\n * pipe(['a','b','c'], join(\"\")) // => \"abc\" (typed `string`)\n * pipe(['hello', 'world'] as const, join(\" \")) // => \"hello world\" (typed `hello world`)\n * @dataLast\n * @category Array\n */\nexport function join<\n T extends readonly JoinableItem[] | [],\n Glue extends string,\n>(glue: Glue): (data: T) => Join<T, Glue>;\n\nexport function join(...args: readonly unknown[]): unknown {\n return purry(joinImplementation, args);\n}\n\nconst joinImplementation = (data: readonly unknown[], glue: string): string =>\n data.join(glue);\n"],"mappings":"kGAqDA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAOA,EAAAA,MAAM,EAAoB,EAAK,CAGxC,MAAM,GAAsB,EAA0B,IACpD,EAAK,KAAK,EAAK"}
|
package/dist/join.js
ADDED
package/dist/join.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"join.js","names":[],"sources":["../src/join.ts"],"sourcesContent":["import type { Join } from \"type-fest\";\nimport { purry } from \"./purry\";\n\n// Copied from type-fest, from the Join type.\ntype JoinableItem = bigint | boolean | number | string | null | undefined;\n\n/**\n * Joins the elements of the array by: casting them to a string and\n * concatenating them one to the other, with the provided glue string in between\n * every two elements.\n *\n * When called on a tuple and with stricter item types (union of literal values,\n * the result is strictly typed to the tuples shape and it's item types).\n *\n * @param data - The array to join.\n * @param glue - The string to put in between every two elements.\n * @signature\n * join(data, glue)\n * @example\n * join([1,2,3], \",\") // => \"1,2,3\" (typed `string`)\n * join(['a','b','c'], \"\") // => \"abc\" (typed `string`)\n * join(['hello', 'world'] as const, \" \") // => \"hello world\" (typed `hello world`)\n * @dataFirst\n * @category Array\n */\nexport function join<\n T extends readonly JoinableItem[] | [],\n Glue extends string,\n>(data: T, glue: Glue): Join<T, Glue>;\n\n/**\n * Joins the elements of the array by: casting them to a string and\n * concatenating them one to the other, with the provided glue string in between\n * every two elements.\n *\n * When called on a tuple and with stricter item types (union of literal values,\n * the result is strictly typed to the tuples shape and it's item types).\n *\n * @param glue - The string to put in between every two elements.\n * @signature\n * join(glue)(data)\n * @example\n * pipe([1,2,3], join(\",\")) // => \"1,2,3\" (typed `string`)\n * pipe(['a','b','c'], join(\"\")) // => \"abc\" (typed `string`)\n * pipe(['hello', 'world'] as const, join(\" \")) // => \"hello world\" (typed `hello world`)\n * @dataLast\n * @category Array\n */\nexport function join<\n T extends readonly JoinableItem[] | [],\n Glue extends string,\n>(glue: Glue): (data: T) => Join<T, Glue>;\n\nexport function join(...args: readonly unknown[]): unknown {\n return purry(joinImplementation, args);\n}\n\nconst joinImplementation = (data: readonly unknown[], glue: string): string =>\n data.join(glue);\n"],"mappings":"mCAqDA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAO,EAAM,EAAoB,EAAK,CAGxC,MAAM,GAAsB,EAA0B,IACpD,EAAK,KAAK,EAAK"}
|
package/dist/keys.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.cjs","names":["purry"],"sources":["../src/keys.ts"],"sourcesContent":["import type { EnumerableStringKeyOf } from \"./internal/types/EnumerableStringKeyOf\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { ToString } from \"./internal/types/ToString\";\nimport { purry } from \"./purry\";\n\ntype Keys<T> = T extends IterableContainer ? ArrayKeys<T> : ObjectKeys<T>;\n\n// The keys output can mirror the input when it is an array/tuple. We do this by\n// \"mapping\" each item \"key\" (which is actually an index) as its own value. This\n// would maintain the shape, even including labels.\ntype ArrayKeys<T extends IterableContainer> = {\n -readonly [Index in keyof T]: Index extends number | string\n ? // Notice that we coalesce the values as strings, this is because in JS,\n // Object.keys always returns strings, even for arrays.\n ToString<IsIndexAfterSpread<T, Index> extends true ? number : Index>\n : // Index is typed as a symbol, this can't happen, but we need to guard\n // against it for typescript.\n never;\n};\n\ntype IsIndexAfterSpread<\n T extends IterableContainer,\n Index extends number | string,\n> =\n IndicesAfterSpread<T> extends never\n ? false\n : Index extends `${IndicesAfterSpread<T>}`\n ? true\n : false;\n\n// Find the index of the tuple where a spread item is located, and return all\n// indices in the tuple which are located after it. The tuple could be prefixed\n// by any number of literal items. If the input is a simple array it would\n// return 0 (as expected), and if the tuple doesn't contain a spread element it\n// would return never.\ntype IndicesAfterSpread<\n T extends readonly unknown[] | [],\n // We use this type to count how many items we consumed, it's just a pseudo-\n // element that is used for its length.\n Iterations extends readonly unknown[] = [],\n> = T[number] extends never\n ? never\n : T extends readonly [unknown, ...infer Tail]\n ? IndicesAfterSpread<Tail, [unknown, ...Iterations]>\n : T extends readonly [...infer Head, unknown]\n ?\n | IndicesAfterSpread<Head, [unknown, ...Iterations]>\n | Iterations[\"length\"]\n : Iterations[\"length\"];\n\ntype ObjectKeys<T> =\n T extends Record<PropertyKey, never> ? [] : EnumerableStringKeyOf<T>[];\n\n/**\n * Returns a new array containing the keys of the array or object.\n *\n * @param data - Either an array or an object.\n * @signature\n * keys(source)\n * @example\n * keys(['x', 'y', 'z']); // => ['0', '1', '2']\n * keys({ a: 'x', b: 'y', 5: 'z' }); // => ['a', 'b', '5']\n * @dataFirst\n * @category Object\n */\nexport function keys<T extends object>(data: T): Keys<T>;\n\n/**\n * Returns a new array containing the keys of the array or object.\n *\n * @signature\n * keys()(source)\n * @example\n * pipe(['x', 'y', 'z'], keys()); // => ['0', '1', '2']\n * pipe({ a: 'x', b: 'y', 5: 'z' } as const, keys()) // => ['a', 'b', '5']\n * @dataLast\n * @category Object\n */\nexport function keys(): <T extends object>(data: T) => Keys<T>;\n\nexport function keys(...args: readonly unknown[]): unknown {\n return purry(Object.keys, args);\n}\n"],"mappings":"kGAgFA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAOA,EAAAA,MAAM,OAAO,KAAM,EAAK"}
|
package/dist/keys.js
ADDED
package/dist/keys.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.js","names":[],"sources":["../src/keys.ts"],"sourcesContent":["import type { EnumerableStringKeyOf } from \"./internal/types/EnumerableStringKeyOf\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { ToString } from \"./internal/types/ToString\";\nimport { purry } from \"./purry\";\n\ntype Keys<T> = T extends IterableContainer ? ArrayKeys<T> : ObjectKeys<T>;\n\n// The keys output can mirror the input when it is an array/tuple. We do this by\n// \"mapping\" each item \"key\" (which is actually an index) as its own value. This\n// would maintain the shape, even including labels.\ntype ArrayKeys<T extends IterableContainer> = {\n -readonly [Index in keyof T]: Index extends number | string\n ? // Notice that we coalesce the values as strings, this is because in JS,\n // Object.keys always returns strings, even for arrays.\n ToString<IsIndexAfterSpread<T, Index> extends true ? number : Index>\n : // Index is typed as a symbol, this can't happen, but we need to guard\n // against it for typescript.\n never;\n};\n\ntype IsIndexAfterSpread<\n T extends IterableContainer,\n Index extends number | string,\n> =\n IndicesAfterSpread<T> extends never\n ? false\n : Index extends `${IndicesAfterSpread<T>}`\n ? true\n : false;\n\n// Find the index of the tuple where a spread item is located, and return all\n// indices in the tuple which are located after it. The tuple could be prefixed\n// by any number of literal items. If the input is a simple array it would\n// return 0 (as expected), and if the tuple doesn't contain a spread element it\n// would return never.\ntype IndicesAfterSpread<\n T extends readonly unknown[] | [],\n // We use this type to count how many items we consumed, it's just a pseudo-\n // element that is used for its length.\n Iterations extends readonly unknown[] = [],\n> = T[number] extends never\n ? never\n : T extends readonly [unknown, ...infer Tail]\n ? IndicesAfterSpread<Tail, [unknown, ...Iterations]>\n : T extends readonly [...infer Head, unknown]\n ?\n | IndicesAfterSpread<Head, [unknown, ...Iterations]>\n | Iterations[\"length\"]\n : Iterations[\"length\"];\n\ntype ObjectKeys<T> =\n T extends Record<PropertyKey, never> ? [] : EnumerableStringKeyOf<T>[];\n\n/**\n * Returns a new array containing the keys of the array or object.\n *\n * @param data - Either an array or an object.\n * @signature\n * keys(source)\n * @example\n * keys(['x', 'y', 'z']); // => ['0', '1', '2']\n * keys({ a: 'x', b: 'y', 5: 'z' }); // => ['a', 'b', '5']\n * @dataFirst\n * @category Object\n */\nexport function keys<T extends object>(data: T): Keys<T>;\n\n/**\n * Returns a new array containing the keys of the array or object.\n *\n * @signature\n * keys()(source)\n * @example\n * pipe(['x', 'y', 'z'], keys()); // => ['0', '1', '2']\n * pipe({ a: 'x', b: 'y', 5: 'z' } as const, keys()) // => ['a', 'b', '5']\n * @dataLast\n * @category Object\n */\nexport function keys(): <T extends object>(data: T) => Keys<T>;\n\nexport function keys(...args: readonly unknown[]): unknown {\n return purry(Object.keys, args);\n}\n"],"mappings":"mCAgFA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAO,EAAM,OAAO,KAAM,EAAK"}
|
package/dist/last.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"last.cjs","names":["purry"],"sources":["../src/last.ts"],"sourcesContent":["import type { LastArrayElement } from \"type-fest\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\ntype Last<T extends IterableContainer> = LastArrayElement<\n T,\n // Type-fest's LastArrayElement assumes a looser typescript configuration\n // where `noUncheckedIndexedAccess` is disabled. To support the stricter\n // configuration we assume we need to assign the \"LastArrayElement\" param to\n // `undefined`, but only if the array isn't empty.\n T extends readonly [] ? never : undefined\n>;\n\n/**\n * Gets the last element of `array`.\n *\n * @param data - The array.\n * @signature\n * last(array)\n * @example\n * last([1, 2, 3]) // => 3\n * last([]) // => undefined\n * @dataFirst\n * @category Array\n */\nexport function last<T extends IterableContainer>(data: T): Last<T>;\n\n/**\n * Gets the last element of `array`.\n *\n * @signature\n * last()(array)\n * @example\n * pipe(\n * [1, 2, 4, 8, 16],\n * filter(x => x > 3),\n * last(),\n * x => x + 1\n * ); // => 17\n * @dataLast\n * @category Array\n */\nexport function last(): <T extends IterableContainer>(data: T) => Last<T>;\n\nexport function last(...args: readonly unknown[]): unknown {\n return purry(lastImplementation, args);\n}\n\nconst lastImplementation = <T>(array: readonly T[]): T | undefined =>\n array.at(-1);\n"],"mappings":"kGA4CA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAOA,EAAAA,MAAM,EAAoB,EAAK,CAGxC,MAAM,EAAyB,GAC7B,EAAM,GAAG,GAAG"}
|
package/dist/last.js
ADDED
package/dist/last.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"last.js","names":[],"sources":["../src/last.ts"],"sourcesContent":["import type { LastArrayElement } from \"type-fest\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\ntype Last<T extends IterableContainer> = LastArrayElement<\n T,\n // Type-fest's LastArrayElement assumes a looser typescript configuration\n // where `noUncheckedIndexedAccess` is disabled. To support the stricter\n // configuration we assume we need to assign the \"LastArrayElement\" param to\n // `undefined`, but only if the array isn't empty.\n T extends readonly [] ? never : undefined\n>;\n\n/**\n * Gets the last element of `array`.\n *\n * @param data - The array.\n * @signature\n * last(array)\n * @example\n * last([1, 2, 3]) // => 3\n * last([]) // => undefined\n * @dataFirst\n * @category Array\n */\nexport function last<T extends IterableContainer>(data: T): Last<T>;\n\n/**\n * Gets the last element of `array`.\n *\n * @signature\n * last()(array)\n * @example\n * pipe(\n * [1, 2, 4, 8, 16],\n * filter(x => x > 3),\n * last(),\n * x => x + 1\n * ); // => 17\n * @dataLast\n * @category Array\n */\nexport function last(): <T extends IterableContainer>(data: T) => Last<T>;\n\nexport function last(...args: readonly unknown[]): unknown {\n return purry(lastImplementation, args);\n}\n\nconst lastImplementation = <T>(array: readonly T[]): T | undefined =>\n array.at(-1);\n"],"mappings":"mCA4CA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAO,EAAM,EAAoB,EAAK,CAGxC,MAAM,EAAyB,GAC7B,EAAM,GAAG,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazyDataLastImpl-DdpJofHC.cjs","names":[],"sources":["../src/internal/lazyDataLastImpl.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { LazyEvaluator } from \"./types/LazyEvaluator\";\nimport type { StrictFunction } from \"./types/StrictFunction\";\n\n/**\n * Use this helper function to build the data last implementation together with\n * a lazy implementation. Use this when you need to build your own purrying\n * logic when you want to decide between dataFirst and dataLast on something\n * that isn't the number of arguments provided. This is useful for implementing\n * functions with optional or variadic arguments.\n */\nexport function lazyDataLastImpl(\n fn: StrictFunction,\n args: readonly unknown[],\n lazy?: (...args: any) => LazyEvaluator,\n // TODO: We can probably provide better typing to the return type...\n): unknown {\n // @ts-expect-error [ts2345] -- This error is accurate because we don't know\n // anything about `fn` so can't ensure that we are passing the correct\n // arguments to it, we just have to trust that the caller knows what they are\n // doing.\n const dataLast = (data: unknown): unknown => fn(data, ...args);\n\n return lazy === undefined\n ? dataLast\n : Object.assign(dataLast, { lazy, lazyArgs: args });\n}\n"],"mappings":"AAYA,SAAgB,EACd,EACA,EACA,EAES,CAKT,IAAM,EAAY,GAA2B,EAAG,EAAM,GAAG,EAAK,CAE9D,OAAO,IAAS,IAAA,GACZ,EACA,OAAO,OAAO,EAAU,CAAE,OAAM,SAAU,EAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazyDataLastImpl-DtF3cihj.js","names":[],"sources":["../src/internal/lazyDataLastImpl.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { LazyEvaluator } from \"./types/LazyEvaluator\";\nimport type { StrictFunction } from \"./types/StrictFunction\";\n\n/**\n * Use this helper function to build the data last implementation together with\n * a lazy implementation. Use this when you need to build your own purrying\n * logic when you want to decide between dataFirst and dataLast on something\n * that isn't the number of arguments provided. This is useful for implementing\n * functions with optional or variadic arguments.\n */\nexport function lazyDataLastImpl(\n fn: StrictFunction,\n args: readonly unknown[],\n lazy?: (...args: any) => LazyEvaluator,\n // TODO: We can probably provide better typing to the return type...\n): unknown {\n // @ts-expect-error [ts2345] -- This error is accurate because we don't know\n // anything about `fn` so can't ensure that we are passing the correct\n // arguments to it, we just have to trust that the caller knows what they are\n // doing.\n const dataLast = (data: unknown): unknown => fn(data, ...args);\n\n return lazy === undefined\n ? dataLast\n : Object.assign(dataLast, { lazy, lazyArgs: args });\n}\n"],"mappings":"AAYA,SAAgB,EACd,EACA,EACA,EAES,CAKT,IAAM,EAAY,GAA2B,EAAG,EAAM,GAAG,EAAK,CAE9D,OAAO,IAAS,IAAA,GACZ,EACA,OAAO,OAAO,EAAU,CAAE,OAAM,SAAU,EAAM,CAAC"}
|
package/dist/length.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"length.cjs","names":["purry"],"sources":["../src/length.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\ntype Enumerable<T> = ArrayLike<T> | Iterable<T>;\n\n/**\n * Counts values of the collection or iterable.\n *\n * @param items - The input data.\n * @signature\n * length(array)\n * @example\n * length([1, 2, 3]) // => 3\n * @dataFirst\n * @category Array\n */\nexport function length<T>(items: Enumerable<T>): number;\n\n/**\n * Counts values of the collection or iterable.\n *\n * @signature\n * length()(array)\n * @example\n * pipe([1, 2, 3], length()) // => 3\n * @dataLast\n * @category Array\n */\nexport function length<T>(): (items: Enumerable<T>) => number;\n\nexport function length(...args: readonly unknown[]): unknown {\n return purry(lengthImplementation, args);\n}\n\nconst lengthImplementation = <T>(items: Enumerable<T>): number =>\n \"length\" in items ? items.length : [...items].length;\n"],"mappings":"kGA6BA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAOA,EAAAA,MAAM,EAAsB,EAAK,CAG1C,MAAM,EAA2B,GAC/B,WAAY,EAAQ,EAAM,OAAS,CAAC,GAAG,EAAM,CAAC"}
|
package/dist/length.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"length.js","names":[],"sources":["../src/length.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\ntype Enumerable<T> = ArrayLike<T> | Iterable<T>;\n\n/**\n * Counts values of the collection or iterable.\n *\n * @param items - The input data.\n * @signature\n * length(array)\n * @example\n * length([1, 2, 3]) // => 3\n * @dataFirst\n * @category Array\n */\nexport function length<T>(items: Enumerable<T>): number;\n\n/**\n * Counts values of the collection or iterable.\n *\n * @signature\n * length()(array)\n * @example\n * pipe([1, 2, 3], length()) // => 3\n * @dataLast\n * @category Array\n */\nexport function length<T>(): (items: Enumerable<T>) => number;\n\nexport function length(...args: readonly unknown[]): unknown {\n return purry(lengthImplementation, args);\n}\n\nconst lengthImplementation = <T>(items: Enumerable<T>): number =>\n \"length\" in items ? items.length : [...items].length;\n"],"mappings":"mCA6BA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAO,EAAM,EAAsB,EAAK,CAG1C,MAAM,EAA2B,GAC/B,WAAY,EAAQ,EAAM,OAAS,CAAC,GAAG,EAAM,CAAC"}
|
package/dist/map.cjs
ADDED
package/dist/map.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.cjs","names":["purry"],"sources":["../src/map.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport type { Mapped } from \"./internal/types/Mapped\";\nimport { purry } from \"./purry\";\n\n/**\n * Creates a new array populated with the results of calling a provided function\n * on every element in the calling array. Equivalent to `Array.prototype.map`.\n *\n * @param data - The array to map.\n * @param callbackfn - A function to execute for each element in the array. Its\n * return value is added as a single element in the new array.\n * @returns A new array with each element being the result of the callback\n * function.\n * @signature\n * map(data, callbackfn)\n * @example\n * map([1, 2, 3], multiply(2)); // => [2, 4, 6]\n * map([0, 0], add(1)); // => [1, 1]\n * map([0, 0], (value, index) => value + index); // => [0, 1]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function map<T extends IterableContainer, U>(\n data: T,\n callbackfn: (value: T[number], index: number, data: T) => U,\n): Mapped<T, U>;\n\n/**\n * Creates a new array populated with the results of calling a provided function\n * on every element in the calling array. Equivalent to `Array.prototype.map`.\n *\n * @param callbackfn - A function to execute for each element in the array. Its\n * return value is added as a single element in the new array.\n * @returns A new array with each element being the result of the callback\n * function.\n * @signature\n * map(callbackfn)(data)\n * @example\n * pipe([1, 2, 3], map(multiply(2))); // => [2, 4, 6]\n * pipe([0, 0], map(add(1))); // => [1, 1]\n * pipe([0, 0], map((value, index) => value + index)); // => [0, 1]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function map<T extends IterableContainer, U>(\n callbackfn: (value: T[number], index: number, data: T) => U,\n): (data: T) => Mapped<T, U>;\n\nexport function map(...args: readonly unknown[]): unknown {\n return purry(mapImplementation, args, lazyImplementation);\n}\n\nconst mapImplementation = <T, U>(\n data: readonly T[],\n callbackfn: (value: T, index: number, data: readonly T[]) => U,\n): U[] => data.map(callbackfn);\n\nconst lazyImplementation =\n <T, U>(\n callbackfn: (value: T, index: number, data: readonly T[]) => U,\n ): LazyEvaluator<T, U> =>\n (value, index, data) => ({\n done: false,\n hasNext: true,\n next: callbackfn(value, index, data),\n });\n"],"mappings":"kGAmDA,SAAgB,EAAI,GAAG,EAAmC,CACxD,OAAOA,EAAAA,MAAM,EAAmB,EAAM,EAAmB,CAG3D,MAAM,GACJ,EACA,IACQ,EAAK,IAAI,EAAW,CAExB,EAEF,IAED,EAAO,EAAO,KAAU,CACvB,KAAM,GACN,QAAS,GACT,KAAM,EAAW,EAAO,EAAO,EAAK,CACrC"}
|
package/dist/map.js
ADDED
package/dist/map.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.js","names":[],"sources":["../src/map.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport type { Mapped } from \"./internal/types/Mapped\";\nimport { purry } from \"./purry\";\n\n/**\n * Creates a new array populated with the results of calling a provided function\n * on every element in the calling array. Equivalent to `Array.prototype.map`.\n *\n * @param data - The array to map.\n * @param callbackfn - A function to execute for each element in the array. Its\n * return value is added as a single element in the new array.\n * @returns A new array with each element being the result of the callback\n * function.\n * @signature\n * map(data, callbackfn)\n * @example\n * map([1, 2, 3], multiply(2)); // => [2, 4, 6]\n * map([0, 0], add(1)); // => [1, 1]\n * map([0, 0], (value, index) => value + index); // => [0, 1]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function map<T extends IterableContainer, U>(\n data: T,\n callbackfn: (value: T[number], index: number, data: T) => U,\n): Mapped<T, U>;\n\n/**\n * Creates a new array populated with the results of calling a provided function\n * on every element in the calling array. Equivalent to `Array.prototype.map`.\n *\n * @param callbackfn - A function to execute for each element in the array. Its\n * return value is added as a single element in the new array.\n * @returns A new array with each element being the result of the callback\n * function.\n * @signature\n * map(callbackfn)(data)\n * @example\n * pipe([1, 2, 3], map(multiply(2))); // => [2, 4, 6]\n * pipe([0, 0], map(add(1))); // => [1, 1]\n * pipe([0, 0], map((value, index) => value + index)); // => [0, 1]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function map<T extends IterableContainer, U>(\n callbackfn: (value: T[number], index: number, data: T) => U,\n): (data: T) => Mapped<T, U>;\n\nexport function map(...args: readonly unknown[]): unknown {\n return purry(mapImplementation, args, lazyImplementation);\n}\n\nconst mapImplementation = <T, U>(\n data: readonly T[],\n callbackfn: (value: T, index: number, data: readonly T[]) => U,\n): U[] => data.map(callbackfn);\n\nconst lazyImplementation =\n <T, U>(\n callbackfn: (value: T, index: number, data: readonly T[]) => U,\n ): LazyEvaluator<T, U> =>\n (value, index, data) => ({\n done: false,\n hasNext: true,\n next: callbackfn(value, index, data),\n });\n"],"mappings":"mCAmDA,SAAgB,EAAI,GAAG,EAAmC,CACxD,OAAO,EAAM,EAAmB,EAAM,EAAmB,CAG3D,MAAM,GACJ,EACA,IACQ,EAAK,IAAI,EAAW,CAExB,EAEF,IAED,EAAO,EAAO,KAAU,CACvB,KAAM,GACN,QAAS,GACT,KAAM,EAAW,EAAO,EAAO,EAAK,CACrC"}
|
package/dist/mapKeys.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`);function t(...t){return e.purry(n,t)}function n(e,t){let n={};for(let[r,i]of Object.entries(e)){let a=t(r,i,e);n[a]=i}return n}exports.mapKeys=t;
|
|
2
|
+
//# sourceMappingURL=mapKeys.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapKeys.cjs","names":["purry"],"sources":["../src/mapKeys.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-object-type --\n * We want to match the typing of the built-in Object.entries as much as\n * possible!\n */\n\nimport type { And, IsUnion, Or } from \"type-fest\";\nimport type { EnumerableStringKeyedValueOf } from \"./internal/types/EnumerableStringKeyedValueOf\";\nimport type { EnumerableStringKeyOf } from \"./internal/types/EnumerableStringKeyOf\";\nimport type { IsBounded } from \"./internal/types/IsBounded\";\nimport { purry } from \"./purry\";\n\ntype MappedKeys<T, Key extends PropertyKey> = MaybePartial<\n T,\n Key,\n // We re-key `T` using `Key`, but because we can't infer at the type level\n // how the mapper would map each specific input key we assign all props the\n // same value, made of all possible values of `T`.\n Record<Key, EnumerableStringKeyedValueOf<T>>\n>;\n\n/**\n * This type is very similar to `BoundedPartial` simplified to the case where\n * we reconstruct the Record using a known `Key` type.\n *\n * @see BoundedPartial\n */\ntype MaybePartial<T, Key extends PropertyKey, Output> =\n And<IsBounded<Key>, Or<IsUnion<Key>, CouldBeEmpty<T>>> extends true\n ? // When keys are bounded we need to consider what assurances we can make\n // about the presence of keys in the output; mainly if there is more than\n // one possible result from the mapper (so we can't know what it would\n // return for a specific input, at the type level), or if object itself\n // might be empty and thus also the output object.\n Partial<Output>\n : // If keys are not bounded TypeScript treats the Record as implicitly\n // Partial so we don't need to do that here.\n Output;\n\n/**\n * Types that are extendable by `{}` are also satisfied by an empty object and\n * thus _could be empty_.\n */\ntype CouldBeEmpty<T> = {} extends T ? true : false;\n\n/**\n * Maps keys of `object` and keeps the same values.\n *\n * @param data - The object to map.\n * @param keyMapper - The mapping function.\n * @signature\n * mapKeys(object, fn)\n * @example\n * mapKeys({a: 1, b: 2}, (key, value) => key + value) // => { a1: 1, b2: 2 }\n * @dataFirst\n * @category Object\n */\nexport function mapKeys<T extends {}, Key extends PropertyKey>(\n data: T,\n keyMapper: (\n key: EnumerableStringKeyOf<T>,\n value: EnumerableStringKeyedValueOf<T>,\n data: T,\n ) => Key,\n): MappedKeys<T, Key>;\n\n/**\n * Maps keys of `object` and keeps the same values.\n *\n * @param keyMapper - The mapping function.\n * @signature\n * mapKeys(fn)(object)\n * @example\n * pipe({a: 1, b: 2}, mapKeys((key, value) => key + value)) // => { a1: 1, b2: 2 }\n * @dataLast\n * @category Object\n */\nexport function mapKeys<T extends {}, Key extends PropertyKey>(\n keyMapper: (\n key: EnumerableStringKeyOf<T>,\n value: EnumerableStringKeyedValueOf<T>,\n data: T,\n ) => Key,\n): (data: T) => MappedKeys<T, Key>;\n\nexport function mapKeys(...args: readonly unknown[]): unknown {\n return purry(mapKeysImplementation, args);\n}\n\nfunction mapKeysImplementation<T extends {}, Key extends PropertyKey>(\n data: T,\n keyMapper: (key: string, value: unknown, data: T) => Key,\n): Partial<Record<Key, unknown>> {\n const out: Partial<Record<Key, unknown>> = {};\n\n for (const [key, value] of Object.entries(data)) {\n const mappedKey = keyMapper(key, value, data);\n out[mappedKey] = value;\n }\n\n return out;\n}\n"],"mappings":"kGAoFA,SAAgB,EAAQ,GAAG,EAAmC,CAC5D,OAAOA,EAAAA,MAAM,EAAuB,EAAK,CAG3C,SAAS,EACP,EACA,EAC+B,CAC/B,IAAM,EAAqC,EAAE,CAE7C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAK,CAAE,CAC/C,IAAM,EAAY,EAAU,EAAK,EAAO,EAAK,CAC7C,EAAI,GAAa,EAGnB,OAAO"}
|
package/dist/mapKeys.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapKeys.js","names":[],"sources":["../src/mapKeys.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-object-type --\n * We want to match the typing of the built-in Object.entries as much as\n * possible!\n */\n\nimport type { And, IsUnion, Or } from \"type-fest\";\nimport type { EnumerableStringKeyedValueOf } from \"./internal/types/EnumerableStringKeyedValueOf\";\nimport type { EnumerableStringKeyOf } from \"./internal/types/EnumerableStringKeyOf\";\nimport type { IsBounded } from \"./internal/types/IsBounded\";\nimport { purry } from \"./purry\";\n\ntype MappedKeys<T, Key extends PropertyKey> = MaybePartial<\n T,\n Key,\n // We re-key `T` using `Key`, but because we can't infer at the type level\n // how the mapper would map each specific input key we assign all props the\n // same value, made of all possible values of `T`.\n Record<Key, EnumerableStringKeyedValueOf<T>>\n>;\n\n/**\n * This type is very similar to `BoundedPartial` simplified to the case where\n * we reconstruct the Record using a known `Key` type.\n *\n * @see BoundedPartial\n */\ntype MaybePartial<T, Key extends PropertyKey, Output> =\n And<IsBounded<Key>, Or<IsUnion<Key>, CouldBeEmpty<T>>> extends true\n ? // When keys are bounded we need to consider what assurances we can make\n // about the presence of keys in the output; mainly if there is more than\n // one possible result from the mapper (so we can't know what it would\n // return for a specific input, at the type level), or if object itself\n // might be empty and thus also the output object.\n Partial<Output>\n : // If keys are not bounded TypeScript treats the Record as implicitly\n // Partial so we don't need to do that here.\n Output;\n\n/**\n * Types that are extendable by `{}` are also satisfied by an empty object and\n * thus _could be empty_.\n */\ntype CouldBeEmpty<T> = {} extends T ? true : false;\n\n/**\n * Maps keys of `object` and keeps the same values.\n *\n * @param data - The object to map.\n * @param keyMapper - The mapping function.\n * @signature\n * mapKeys(object, fn)\n * @example\n * mapKeys({a: 1, b: 2}, (key, value) => key + value) // => { a1: 1, b2: 2 }\n * @dataFirst\n * @category Object\n */\nexport function mapKeys<T extends {}, Key extends PropertyKey>(\n data: T,\n keyMapper: (\n key: EnumerableStringKeyOf<T>,\n value: EnumerableStringKeyedValueOf<T>,\n data: T,\n ) => Key,\n): MappedKeys<T, Key>;\n\n/**\n * Maps keys of `object` and keeps the same values.\n *\n * @param keyMapper - The mapping function.\n * @signature\n * mapKeys(fn)(object)\n * @example\n * pipe({a: 1, b: 2}, mapKeys((key, value) => key + value)) // => { a1: 1, b2: 2 }\n * @dataLast\n * @category Object\n */\nexport function mapKeys<T extends {}, Key extends PropertyKey>(\n keyMapper: (\n key: EnumerableStringKeyOf<T>,\n value: EnumerableStringKeyedValueOf<T>,\n data: T,\n ) => Key,\n): (data: T) => MappedKeys<T, Key>;\n\nexport function mapKeys(...args: readonly unknown[]): unknown {\n return purry(mapKeysImplementation, args);\n}\n\nfunction mapKeysImplementation<T extends {}, Key extends PropertyKey>(\n data: T,\n keyMapper: (key: string, value: unknown, data: T) => Key,\n): Partial<Record<Key, unknown>> {\n const out: Partial<Record<Key, unknown>> = {};\n\n for (const [key, value] of Object.entries(data)) {\n const mappedKey = keyMapper(key, value, data);\n out[mappedKey] = value;\n }\n\n return out;\n}\n"],"mappings":"mCAoFA,SAAgB,EAAQ,GAAG,EAAmC,CAC5D,OAAO,EAAM,EAAuB,EAAK,CAG3C,SAAS,EACP,EACA,EAC+B,CAC/B,IAAM,EAAqC,EAAE,CAE7C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAK,CAAE,CAC/C,IAAM,EAAY,EAAU,EAAK,EAAO,EAAK,CAC7C,EAAI,GAAa,EAGnB,OAAO"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`);function t(...t){return e.purry(n,t)}function n(e,t){let n={};for(let[r,i]of e.entries()){let[a,o]=t(i,r,e);n[a]=o}return n}exports.mapToObj=t;
|
|
2
|
+
//# sourceMappingURL=mapToObj.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapToObj.cjs","names":["purry"],"sources":["../src/mapToObj.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n// TODO [>2]: Once we allow fromEntries to run lazily on iterables we need to remove this utility as it's completely replaceable by `fromEntries(map(...))`.\n/**\n * Map each element of an array into an object using a defined mapper that\n * converts each item into an object entry (a tuple of `[<key>, <value>]`).\n *\n * There are several other functions that could be used to build an object from\n * an array:\n * - `fromKeys` - Builds an object from an array of *keys* and a mapper for\n * values.\n * - `indexBy` - Builds an object from an array of *values* and a mapper for\n * keys.\n * - `pullObject` - Builds an object from an array of items with a mapper for\n * values and another mapper for keys.\n * - `fromEntries` - Builds an object from an array of key-value pairs.\n *\n * **Warning**: We strongly advise against using this function unless it is\n * used with a huge input array and your app has stringent memory/gc\n * constraints. We recommend that in most cases you should use `pullObject`,\n * or the composition `fromEntries(map(array, fn))`. This function will be\n * deprecated and **removed** in future versions of the library!\n *\n * @param array - The array to map.\n * @param fn - The mapping function, which should return a tuple of [key, value], similar to Object.fromEntries.\n * @returns The new mapped object.\n * @signature\n * mapToObj(array, fn)\n * @example\n * mapToObj([1, 2, 3], x => [String(x), x * 2]) // => {1: 2, 2: 4, 3: 6}\n * @dataFirst\n * @category Array\n */\nexport function mapToObj<T, K extends PropertyKey, V>(\n array: readonly T[],\n fn: (value: T, index: number, data: readonly T[]) => [K, V],\n): Record<K, V>;\n\n// TODO [>2]: Once we allow fromEntries to run lazily on iterables we need to remove this utility as it's completely replaceable by `fromEntries(map(...))`.\n/**\n * Map each element of an array into an object using a defined mapper that\n * converts each item into an object entry (a tuple of `[<key>, <value>]`).\n *\n * There are several other functions that could be used to build an object from\n * an array:\n * - `fromKeys` - Builds an object from an array of *keys* and a mapper for\n * values.\n * - `indexBy` - Builds an object from an array of *values* and a mapper for\n * keys.\n * - `pullObject` - Builds an object from an array of items with a mapper for\n * values and another mapper for keys.\n * - `fromEntries` - Builds an object from an array of key-value pairs.\n *\n * **Warning**: We strongly advise against using this function unless it is\n * used with a huge input array and your app has stringent memory/gc\n * constraints. We recommend that in most cases you should use `pullObject`,\n * or the composition `fromEntries(map(array, fn))`. This function will be\n * deprecated and **removed** in future versions of the library!\n *\n * @param fn - The mapping function, which should return a tuple of [key, value], similar to Object.fromEntries.\n * @returns The new mapped object.\n * @signature\n * mapToObj(fn)(array)\n * @example\n * pipe(\n * [1, 2, 3],\n * mapToObj(x => [String(x), x * 2])\n * ) // => {1: 2, 2: 4, 3: 6}\n * @dataLast\n * @category Array\n */\nexport function mapToObj<T, K extends PropertyKey, V>(\n fn: (value: T, index: number, data: readonly T[]) => [K, V],\n): (array: readonly T[]) => Record<K, V>;\n\nexport function mapToObj(...args: readonly unknown[]): unknown {\n return purry(mapToObjImplementation, args);\n}\n\nfunction mapToObjImplementation(\n array: readonly unknown[],\n fn: (\n value: unknown,\n index: number,\n data: readonly unknown[],\n ) => [PropertyKey, unknown],\n): Record<PropertyKey, unknown> {\n const out: Record<PropertyKey, unknown> = {};\n\n for (const [index, element] of array.entries()) {\n const [key, value] = fn(element, index, array);\n out[key] = value;\n }\n\n return out;\n}\n"],"mappings":"kGA2EA,SAAgB,EAAS,GAAG,EAAmC,CAC7D,OAAOA,EAAAA,MAAM,EAAwB,EAAK,CAG5C,SAAS,EACP,EACA,EAK8B,CAC9B,IAAM,EAAoC,EAAE,CAE5C,IAAK,GAAM,CAAC,EAAO,KAAY,EAAM,SAAS,CAAE,CAC9C,GAAM,CAAC,EAAK,GAAS,EAAG,EAAS,EAAO,EAAM,CAC9C,EAAI,GAAO,EAGb,OAAO"}
|
package/dist/mapToObj.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapToObj.js","names":[],"sources":["../src/mapToObj.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n// TODO [>2]: Once we allow fromEntries to run lazily on iterables we need to remove this utility as it's completely replaceable by `fromEntries(map(...))`.\n/**\n * Map each element of an array into an object using a defined mapper that\n * converts each item into an object entry (a tuple of `[<key>, <value>]`).\n *\n * There are several other functions that could be used to build an object from\n * an array:\n * - `fromKeys` - Builds an object from an array of *keys* and a mapper for\n * values.\n * - `indexBy` - Builds an object from an array of *values* and a mapper for\n * keys.\n * - `pullObject` - Builds an object from an array of items with a mapper for\n * values and another mapper for keys.\n * - `fromEntries` - Builds an object from an array of key-value pairs.\n *\n * **Warning**: We strongly advise against using this function unless it is\n * used with a huge input array and your app has stringent memory/gc\n * constraints. We recommend that in most cases you should use `pullObject`,\n * or the composition `fromEntries(map(array, fn))`. This function will be\n * deprecated and **removed** in future versions of the library!\n *\n * @param array - The array to map.\n * @param fn - The mapping function, which should return a tuple of [key, value], similar to Object.fromEntries.\n * @returns The new mapped object.\n * @signature\n * mapToObj(array, fn)\n * @example\n * mapToObj([1, 2, 3], x => [String(x), x * 2]) // => {1: 2, 2: 4, 3: 6}\n * @dataFirst\n * @category Array\n */\nexport function mapToObj<T, K extends PropertyKey, V>(\n array: readonly T[],\n fn: (value: T, index: number, data: readonly T[]) => [K, V],\n): Record<K, V>;\n\n// TODO [>2]: Once we allow fromEntries to run lazily on iterables we need to remove this utility as it's completely replaceable by `fromEntries(map(...))`.\n/**\n * Map each element of an array into an object using a defined mapper that\n * converts each item into an object entry (a tuple of `[<key>, <value>]`).\n *\n * There are several other functions that could be used to build an object from\n * an array:\n * - `fromKeys` - Builds an object from an array of *keys* and a mapper for\n * values.\n * - `indexBy` - Builds an object from an array of *values* and a mapper for\n * keys.\n * - `pullObject` - Builds an object from an array of items with a mapper for\n * values and another mapper for keys.\n * - `fromEntries` - Builds an object from an array of key-value pairs.\n *\n * **Warning**: We strongly advise against using this function unless it is\n * used with a huge input array and your app has stringent memory/gc\n * constraints. We recommend that in most cases you should use `pullObject`,\n * or the composition `fromEntries(map(array, fn))`. This function will be\n * deprecated and **removed** in future versions of the library!\n *\n * @param fn - The mapping function, which should return a tuple of [key, value], similar to Object.fromEntries.\n * @returns The new mapped object.\n * @signature\n * mapToObj(fn)(array)\n * @example\n * pipe(\n * [1, 2, 3],\n * mapToObj(x => [String(x), x * 2])\n * ) // => {1: 2, 2: 4, 3: 6}\n * @dataLast\n * @category Array\n */\nexport function mapToObj<T, K extends PropertyKey, V>(\n fn: (value: T, index: number, data: readonly T[]) => [K, V],\n): (array: readonly T[]) => Record<K, V>;\n\nexport function mapToObj(...args: readonly unknown[]): unknown {\n return purry(mapToObjImplementation, args);\n}\n\nfunction mapToObjImplementation(\n array: readonly unknown[],\n fn: (\n value: unknown,\n index: number,\n data: readonly unknown[],\n ) => [PropertyKey, unknown],\n): Record<PropertyKey, unknown> {\n const out: Record<PropertyKey, unknown> = {};\n\n for (const [index, element] of array.entries()) {\n const [key, value] = fn(element, index, array);\n out[key] = value;\n }\n\n return out;\n}\n"],"mappings":"mCA2EA,SAAgB,EAAS,GAAG,EAAmC,CAC7D,OAAO,EAAM,EAAwB,EAAK,CAG5C,SAAS,EACP,EACA,EAK8B,CAC9B,IAAM,EAAoC,EAAE,CAE5C,IAAK,GAAM,CAAC,EAAO,KAAY,EAAM,SAAS,CAAE,CAC9C,GAAM,CAAC,EAAK,GAAS,EAAG,EAAS,EAAO,EAAM,CAC9C,EAAI,GAAO,EAGb,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapValues.cjs","names":["purry"],"sources":["../src/mapValues.ts"],"sourcesContent":["import type { Simplify } from \"type-fest\";\nimport type { EnumerableStringKeyOf } from \"./internal/types/EnumerableStringKeyOf\";\nimport type { EnumerableStringKeyedValueOf } from \"./internal/types/EnumerableStringKeyedValueOf\";\nimport { purry } from \"./purry\";\n\ntype MappedValues<T extends object, Value> = Simplify<{\n -readonly [P in keyof T as P extends number | string ? P : never]: Value;\n}>;\n\n/**\n * Maps values of `object` and keeps the same keys. Symbol keys are not passed\n * to the mapper and will be removed from the output object.\n *\n * To also copy the symbol keys to the output use merge:\n * `merge(data, mapValues(data, mapper))`).\n *\n * @param data - The object to map.\n * @param valueMapper - The mapping function.\n * @signature\n * mapValues(data, mapper)\n * @example\n * mapValues({a: 1, b: 2}, (value, key) => value + key) // => {a: '1a', b: '2b'}\n * @dataFirst\n * @category Object\n */\nexport function mapValues<T extends object, Value>(\n data: T,\n valueMapper: (\n value: EnumerableStringKeyedValueOf<T>,\n key: EnumerableStringKeyOf<T>,\n data: T,\n ) => Value,\n): MappedValues<T, Value>;\n\n/**\n * Maps values of `object` and keeps the same keys. Symbol keys are not passed\n * to the mapper and will be removed from the output object.\n *\n * To also copy the symbol keys to the output use merge:\n * `merge(data, mapValues(data, mapper))`).\n *\n * @param valueMapper - The mapping function.\n * @signature\n * mapValues(mapper)(data)\n * @example\n * pipe({a: 1, b: 2}, mapValues((value, key) => value + key)) // => {a: '1a', b: '2b'}\n * @dataLast\n * @category Object\n */\nexport function mapValues<T extends object, Value>(\n valueMapper: (\n value: EnumerableStringKeyedValueOf<T>,\n key: EnumerableStringKeyOf<T>,\n data: T,\n ) => Value,\n): (data: T) => MappedValues<T, Value>;\n\nexport function mapValues(...args: readonly unknown[]): unknown {\n return purry(mapValuesImplementation, args);\n}\n\nfunction mapValuesImplementation<T extends object, Value>(\n data: T,\n valueMapper: (value: unknown, key: string, data: T) => Value,\n): Record<string, Value> {\n const out: Record<string, Value> = {};\n\n for (const [key, value] of Object.entries(data)) {\n const mappedValue = valueMapper(value, key, data);\n out[key] = mappedValue;\n }\n\n return out;\n}\n"],"mappings":"kGAyDA,SAAgB,EAAU,GAAG,EAAmC,CAC9D,OAAOA,EAAAA,MAAM,EAAyB,EAAK,CAG7C,SAAS,EACP,EACA,EACuB,CACvB,IAAM,EAA6B,EAAE,CAErC,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAK,CAE7C,EAAI,GADgB,EAAY,EAAO,EAAK,EAAK,CAInD,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapValues.js","names":[],"sources":["../src/mapValues.ts"],"sourcesContent":["import type { Simplify } from \"type-fest\";\nimport type { EnumerableStringKeyOf } from \"./internal/types/EnumerableStringKeyOf\";\nimport type { EnumerableStringKeyedValueOf } from \"./internal/types/EnumerableStringKeyedValueOf\";\nimport { purry } from \"./purry\";\n\ntype MappedValues<T extends object, Value> = Simplify<{\n -readonly [P in keyof T as P extends number | string ? P : never]: Value;\n}>;\n\n/**\n * Maps values of `object` and keeps the same keys. Symbol keys are not passed\n * to the mapper and will be removed from the output object.\n *\n * To also copy the symbol keys to the output use merge:\n * `merge(data, mapValues(data, mapper))`).\n *\n * @param data - The object to map.\n * @param valueMapper - The mapping function.\n * @signature\n * mapValues(data, mapper)\n * @example\n * mapValues({a: 1, b: 2}, (value, key) => value + key) // => {a: '1a', b: '2b'}\n * @dataFirst\n * @category Object\n */\nexport function mapValues<T extends object, Value>(\n data: T,\n valueMapper: (\n value: EnumerableStringKeyedValueOf<T>,\n key: EnumerableStringKeyOf<T>,\n data: T,\n ) => Value,\n): MappedValues<T, Value>;\n\n/**\n * Maps values of `object` and keeps the same keys. Symbol keys are not passed\n * to the mapper and will be removed from the output object.\n *\n * To also copy the symbol keys to the output use merge:\n * `merge(data, mapValues(data, mapper))`).\n *\n * @param valueMapper - The mapping function.\n * @signature\n * mapValues(mapper)(data)\n * @example\n * pipe({a: 1, b: 2}, mapValues((value, key) => value + key)) // => {a: '1a', b: '2b'}\n * @dataLast\n * @category Object\n */\nexport function mapValues<T extends object, Value>(\n valueMapper: (\n value: EnumerableStringKeyedValueOf<T>,\n key: EnumerableStringKeyOf<T>,\n data: T,\n ) => Value,\n): (data: T) => MappedValues<T, Value>;\n\nexport function mapValues(...args: readonly unknown[]): unknown {\n return purry(mapValuesImplementation, args);\n}\n\nfunction mapValuesImplementation<T extends object, Value>(\n data: T,\n valueMapper: (value: unknown, key: string, data: T) => Value,\n): Record<string, Value> {\n const out: Record<string, Value> = {};\n\n for (const [key, value] of Object.entries(data)) {\n const mappedValue = valueMapper(value, key, data);\n out[key] = mappedValue;\n }\n\n return out;\n}\n"],"mappings":"mCAyDA,SAAgB,EAAU,GAAG,EAAmC,CAC9D,OAAO,EAAM,EAAyB,EAAK,CAG7C,SAAS,EACP,EACA,EACuB,CACvB,IAAM,EAA6B,EAAE,CAErC,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAK,CAE7C,EAAI,GADgB,EAAY,EAAO,EAAK,EAAK,CAInD,OAAO"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purryFromLazy-CwB5T8yd.cjs`);function t(...t){return e.t(n,t)}const n=(e,t)=>{let n=t;return(t,r,i)=>(n=e(n,t,r,i),{done:!1,hasNext:!0,next:n})};exports.mapWithFeedback=t;
|
|
2
|
+
//# sourceMappingURL=mapWithFeedback.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapWithFeedback.cjs","names":["purryFromLazy"],"sources":["../src/mapWithFeedback.ts"],"sourcesContent":["import { purryFromLazy } from \"./internal/purryFromLazy\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport type { Mapped } from \"./internal/types/Mapped\";\n\n/**\n * Applies a function on each element of the array, using the result of the\n * previous application, and returns an array of the successively computed\n * values.\n *\n * @param data - The array to map over.\n * @param callbackfn - The callback function that receives the previous value,\n * the current element.\n * @param initialValue - The initial value to start the computation with.\n * @returns An array of successively computed values from the left side of the\n * array.\n * @signature\n * mapWithFeedback(data, callbackfn, initialValue);\n * @example\n * mapWithFeedback(\n * [1, 2, 3, 4, 5],\n * (prev, x) => prev + x,\n * 100,\n * ); // => [101, 103, 106, 110, 115]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function mapWithFeedback<T extends IterableContainer, U>(\n data: T,\n callbackfn: (\n previousValue: U,\n currentValue: T[number],\n currentIndex: number,\n data: T,\n ) => U,\n initialValue: U,\n): Mapped<T, U>;\n\n/**\n * Applies a function on each element of the array, using the result of the\n * previous application, and returns an array of the successively computed\n * values.\n *\n * @param callbackfn - The callback function that receives the previous value,\n * the current element.\n * @param initialValue - The initial value to start the computation with.\n * @returns An array of successively computed values from the left side of the\n * array.\n * @signature\n * mapWithFeedback(callbackfn, initialValue)(data);\n * @example\n * pipe(\n * [1, 2, 3, 4, 5],\n * mapWithFeedback((prev, x) => prev + x, 100),\n * ); // => [101, 103, 106, 110, 115]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function mapWithFeedback<T extends IterableContainer, U>(\n callbackfn: (\n previousValue: U,\n currentValue: T[number],\n currentIndex: number,\n data: T,\n ) => U,\n initialValue: U,\n): (data: T) => Mapped<T, U>;\n\nexport function mapWithFeedback(...args: readonly unknown[]): unknown {\n return purryFromLazy(lazyImplementation, args);\n}\n\nconst lazyImplementation = <T, U>(\n reducer: (\n previousValue: U,\n currentValue: T,\n index: number,\n data: readonly T[],\n ) => U,\n initialValue: U,\n): LazyEvaluator<T, U> => {\n let previousValue = initialValue;\n return (currentValue, index, data) => {\n previousValue = reducer(previousValue, currentValue, index, data);\n return { done: false, hasNext: true, next: previousValue };\n };\n};\n"],"mappings":"mHAsEA,SAAgB,EAAgB,GAAG,EAAmC,CACpE,OAAOA,EAAAA,EAAc,EAAoB,EAAK,CAGhD,MAAM,GACJ,EAMA,IACwB,CACxB,IAAI,EAAgB,EACpB,OAAQ,EAAc,EAAO,KAC3B,EAAgB,EAAQ,EAAe,EAAc,EAAO,EAAK,CAC1D,CAAE,KAAM,GAAO,QAAS,GAAM,KAAM,EAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapWithFeedback.js","names":[],"sources":["../src/mapWithFeedback.ts"],"sourcesContent":["import { purryFromLazy } from \"./internal/purryFromLazy\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { LazyEvaluator } from \"./internal/types/LazyEvaluator\";\nimport type { Mapped } from \"./internal/types/Mapped\";\n\n/**\n * Applies a function on each element of the array, using the result of the\n * previous application, and returns an array of the successively computed\n * values.\n *\n * @param data - The array to map over.\n * @param callbackfn - The callback function that receives the previous value,\n * the current element.\n * @param initialValue - The initial value to start the computation with.\n * @returns An array of successively computed values from the left side of the\n * array.\n * @signature\n * mapWithFeedback(data, callbackfn, initialValue);\n * @example\n * mapWithFeedback(\n * [1, 2, 3, 4, 5],\n * (prev, x) => prev + x,\n * 100,\n * ); // => [101, 103, 106, 110, 115]\n * @dataFirst\n * @lazy\n * @category Array\n */\nexport function mapWithFeedback<T extends IterableContainer, U>(\n data: T,\n callbackfn: (\n previousValue: U,\n currentValue: T[number],\n currentIndex: number,\n data: T,\n ) => U,\n initialValue: U,\n): Mapped<T, U>;\n\n/**\n * Applies a function on each element of the array, using the result of the\n * previous application, and returns an array of the successively computed\n * values.\n *\n * @param callbackfn - The callback function that receives the previous value,\n * the current element.\n * @param initialValue - The initial value to start the computation with.\n * @returns An array of successively computed values from the left side of the\n * array.\n * @signature\n * mapWithFeedback(callbackfn, initialValue)(data);\n * @example\n * pipe(\n * [1, 2, 3, 4, 5],\n * mapWithFeedback((prev, x) => prev + x, 100),\n * ); // => [101, 103, 106, 110, 115]\n * @dataLast\n * @lazy\n * @category Array\n */\nexport function mapWithFeedback<T extends IterableContainer, U>(\n callbackfn: (\n previousValue: U,\n currentValue: T[number],\n currentIndex: number,\n data: T,\n ) => U,\n initialValue: U,\n): (data: T) => Mapped<T, U>;\n\nexport function mapWithFeedback(...args: readonly unknown[]): unknown {\n return purryFromLazy(lazyImplementation, args);\n}\n\nconst lazyImplementation = <T, U>(\n reducer: (\n previousValue: U,\n currentValue: T,\n index: number,\n data: readonly T[],\n ) => U,\n initialValue: U,\n): LazyEvaluator<T, U> => {\n let previousValue = initialValue;\n return (currentValue, index, data) => {\n previousValue = reducer(previousValue, currentValue, index, data);\n return { done: false, hasNext: true, next: previousValue };\n };\n};\n"],"mappings":"gDAsEA,SAAgB,EAAgB,GAAG,EAAmC,CACpE,OAAO,EAAc,EAAoB,EAAK,CAGhD,MAAM,GACJ,EAMA,IACwB,CACxB,IAAI,EAAgB,EACpB,OAAQ,EAAc,EAAO,KAC3B,EAAgB,EAAQ,EAAe,EAAc,EAAO,EAAK,CAC1D,CAAE,KAAM,GAAO,QAAS,GAAM,KAAM,EAAe"}
|
package/dist/mean.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mean.cjs","names":["purry","sum"],"sources":["../src/mean.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\nimport { sum } from \"./sum\";\n\ntype Mean<T extends IterableContainer<number>> =\n | (T extends readonly [] ? never : number)\n | (T extends readonly [unknown, ...unknown[]] ? never : undefined);\n\n/**\n * Returns the mean of the elements of an array.\n *\n * Only `number` arrays are supported, as `bigint` is unable to represent fractional values.\n *\n * IMPORTANT: The result for empty arrays would be `undefined`, regardless of\n * the type of the array. This approach improves type-checking and ensures that\n * cases where `NaN` might occur are handled properly. To avoid adding this to\n * the return type for cases where the array is known to be non-empty you can use\n * `hasAtLeast` or `isEmpty` to guard against this case.\n *\n * @param data - The array of numbers.\n * @signature\n * mean(data);\n * @example\n * mean([1, 2, 3]); // => 2\n * mean([]); // => undefined\n * @dataFirst\n * @category Number\n */\nexport function mean<T extends IterableContainer<number>>(data: T): Mean<T>;\n\n/**\n * Returns the mean of the elements of an array.\n *\n * Only `number` arrays are supported, as `bigint` is unable to represent fractional values.\n *\n * IMPORTANT: The result for empty arrays would be `undefined`, regardless of\n * the type of the array. This approach improves type-checking and ensures that\n * cases where `NaN` might occur are handled properly. To avoid adding this to\n * the return type for cases where the array is known to be non-empty you can use\n * `hasAtLeast` or `isEmpty` to guard against this case.\n *\n * @signature\n * mean()(data);\n * @example\n * pipe([1, 2, 3], mean()); // => 2\n * pipe([], mean()); // => undefined\n * @dataLast\n * @category Number\n */\nexport function mean(): <T extends IterableContainer<number>>(\n data: T,\n) => Mean<T>;\n\nexport function mean(...args: readonly unknown[]): unknown {\n return purry(meanImplementation, args);\n}\n\nfunction meanImplementation<T extends IterableContainer<number>>(\n data: T,\n): T[number] | undefined {\n if (data.length === 0) {\n return undefined;\n }\n\n return sum(data) / data.length;\n}\n"],"mappings":"yHAqDA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAOA,EAAAA,MAAM,EAAoB,EAAK,CAGxC,SAAS,EACP,EACuB,CACnB,KAAK,SAAW,EAIpB,OAAOC,EAAAA,IAAI,EAAK,CAAG,EAAK"}
|
package/dist/mean.js
ADDED
package/dist/mean.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mean.js","names":[],"sources":["../src/mean.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\nimport { sum } from \"./sum\";\n\ntype Mean<T extends IterableContainer<number>> =\n | (T extends readonly [] ? never : number)\n | (T extends readonly [unknown, ...unknown[]] ? never : undefined);\n\n/**\n * Returns the mean of the elements of an array.\n *\n * Only `number` arrays are supported, as `bigint` is unable to represent fractional values.\n *\n * IMPORTANT: The result for empty arrays would be `undefined`, regardless of\n * the type of the array. This approach improves type-checking and ensures that\n * cases where `NaN` might occur are handled properly. To avoid adding this to\n * the return type for cases where the array is known to be non-empty you can use\n * `hasAtLeast` or `isEmpty` to guard against this case.\n *\n * @param data - The array of numbers.\n * @signature\n * mean(data);\n * @example\n * mean([1, 2, 3]); // => 2\n * mean([]); // => undefined\n * @dataFirst\n * @category Number\n */\nexport function mean<T extends IterableContainer<number>>(data: T): Mean<T>;\n\n/**\n * Returns the mean of the elements of an array.\n *\n * Only `number` arrays are supported, as `bigint` is unable to represent fractional values.\n *\n * IMPORTANT: The result for empty arrays would be `undefined`, regardless of\n * the type of the array. This approach improves type-checking and ensures that\n * cases where `NaN` might occur are handled properly. To avoid adding this to\n * the return type for cases where the array is known to be non-empty you can use\n * `hasAtLeast` or `isEmpty` to guard against this case.\n *\n * @signature\n * mean()(data);\n * @example\n * pipe([1, 2, 3], mean()); // => 2\n * pipe([], mean()); // => undefined\n * @dataLast\n * @category Number\n */\nexport function mean(): <T extends IterableContainer<number>>(\n data: T,\n) => Mean<T>;\n\nexport function mean(...args: readonly unknown[]): unknown {\n return purry(meanImplementation, args);\n}\n\nfunction meanImplementation<T extends IterableContainer<number>>(\n data: T,\n): T[number] | undefined {\n if (data.length === 0) {\n return undefined;\n }\n\n return sum(data) / data.length;\n}\n"],"mappings":"kEAqDA,SAAgB,EAAK,GAAG,EAAmC,CACzD,OAAO,EAAM,EAAoB,EAAK,CAGxC,SAAS,EACP,EACuB,CACnB,KAAK,SAAW,EAIpB,OAAO,EAAI,EAAK,CAAG,EAAK"}
|
package/dist/meanBy.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`);function t(...t){return e.purry(n,t)}const n=(e,t)=>{if(e.length===0)return NaN;let n=0;for(let[r,i]of e.entries())n+=t(i,r,e);return n/e.length};exports.meanBy=t;
|
|
2
|
+
//# sourceMappingURL=meanBy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meanBy.cjs","names":["purry"],"sources":["../src/meanBy.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Returns the mean of the elements of an array using the provided predicate.\n *\n * @param fn - Predicate function.\n * @signature\n * meanBy(fn)(array)\n * @example\n * pipe(\n * [{a: 5}, {a: 1}, {a: 3}],\n * meanBy(x => x.a)\n * ) // 3\n * @dataLast\n * @category Array\n */\n\nexport function meanBy<T>(\n fn: (value: T, index: number, data: readonly T[]) => number,\n): (items: readonly T[]) => number;\n\n/**\n * Returns the mean of the elements of an array using the provided predicate.\n *\n * @param items - The array.\n * @param fn - Predicate function.\n * @signature\n * meanBy(array, fn)\n * @example\n * meanBy(\n * [{a: 5}, {a: 1}, {a: 3}],\n * x => x.a\n * ) // 3\n * @dataFirst\n * @category Array\n */\n\nexport function meanBy<T>(\n items: readonly T[],\n fn: (value: T, index: number, data: readonly T[]) => number,\n): number;\n\nexport function meanBy(...args: readonly unknown[]): unknown {\n return purry(meanByImplementation, args);\n}\n\nconst meanByImplementation = <T>(\n array: readonly T[],\n fn: (value: T, index: number, data: readonly T[]) => number,\n): number => {\n if (array.length === 0) {\n return Number.NaN;\n }\n\n let sum = 0;\n\n for (const [index, item] of array.entries()) {\n sum += fn(item, index, array);\n }\n\n return sum / array.length;\n};\n"],"mappings":"kGA0CA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAOA,EAAAA,MAAM,EAAsB,EAAK,CAG1C,MAAM,GACJ,EACA,IACW,CACX,GAAI,EAAM,SAAW,EACnB,MAAO,KAGT,IAAI,EAAM,EAEV,IAAK,GAAM,CAAC,EAAO,KAAS,EAAM,SAAS,CACzC,GAAO,EAAG,EAAM,EAAO,EAAM,CAG/B,OAAO,EAAM,EAAM"}
|
package/dist/meanBy.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meanBy.js","names":[],"sources":["../src/meanBy.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Returns the mean of the elements of an array using the provided predicate.\n *\n * @param fn - Predicate function.\n * @signature\n * meanBy(fn)(array)\n * @example\n * pipe(\n * [{a: 5}, {a: 1}, {a: 3}],\n * meanBy(x => x.a)\n * ) // 3\n * @dataLast\n * @category Array\n */\n\nexport function meanBy<T>(\n fn: (value: T, index: number, data: readonly T[]) => number,\n): (items: readonly T[]) => number;\n\n/**\n * Returns the mean of the elements of an array using the provided predicate.\n *\n * @param items - The array.\n * @param fn - Predicate function.\n * @signature\n * meanBy(array, fn)\n * @example\n * meanBy(\n * [{a: 5}, {a: 1}, {a: 3}],\n * x => x.a\n * ) // 3\n * @dataFirst\n * @category Array\n */\n\nexport function meanBy<T>(\n items: readonly T[],\n fn: (value: T, index: number, data: readonly T[]) => number,\n): number;\n\nexport function meanBy(...args: readonly unknown[]): unknown {\n return purry(meanByImplementation, args);\n}\n\nconst meanByImplementation = <T>(\n array: readonly T[],\n fn: (value: T, index: number, data: readonly T[]) => number,\n): number => {\n if (array.length === 0) {\n return Number.NaN;\n }\n\n let sum = 0;\n\n for (const [index, item] of array.entries()) {\n sum += fn(item, index, array);\n }\n\n return sum / array.length;\n};\n"],"mappings":"mCA0CA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAO,EAAM,EAAsB,EAAK,CAG1C,MAAM,GACJ,EACA,IACW,CACX,GAAI,EAAM,SAAW,EACnB,MAAO,KAGT,IAAI,EAAM,EAEV,IAAK,GAAM,CAAC,EAAO,KAAS,EAAM,SAAS,CACzC,GAAO,EAAG,EAAM,EAAO,EAAM,CAG/B,OAAO,EAAM,EAAM"}
|
package/dist/median.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(r,t)}const n=(e,t)=>e-t;function r(e){if(e.length===0)return;let t=[...e].sort(n);if(t.length%2!=0)return t[(t.length-1)/2];let r=t.length/2;return(t[r]+t[r-1])/2}exports.median=t;
|
|
2
|
+
//# sourceMappingURL=median.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"median.cjs","names":["purry"],"sources":["../src/median.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\ntype Median<T extends IterableContainer<number>> =\n | (T extends readonly [] ? never : number)\n | (T extends readonly [unknown, ...unknown[]] ? never : undefined);\n\n/**\n * Returns the median of the elements of an array.\n *\n * Only `number` arrays are supported, as `bigint` is unable to represent fractional values.\n *\n * IMPORTANT: The result for empty arrays would be `undefined`, regardless of\n * the type of the array. This approach improves type-checking and ensures that\n * cases where `NaN` might occur are handled properly. To avoid adding this to\n * the return type for cases where the array is known to be non-empty you can use\n * `hasAtLeast` or `isEmpty` to guard against this case.\n *\n * @param data - The array of numbers.\n * @signature\n * median(data);\n * @example\n * pipe([6, 10, 11], median()); // => 10\n * median([]); // => undefined\n * @dataFirst\n * @category Number\n */\nexport function median<T extends IterableContainer<number>>(data: T): Median<T>;\n\n/**\n * Returns the median of the elements of an array.\n *\n * Only `number` arrays are supported, as `bigint` is unable to represent fractional values.\n *\n * IMPORTANT: The result for empty arrays would be `undefined`, regardless of\n * the type of the array. This approach improves type-checking and ensures that\n * cases where `NaN` might occur are handled properly. To avoid adding this to\n * the return type for cases where the array is known to be non-empty you can use\n * `hasAtLeast` or `isEmpty` to guard against this case.\n *\n * @signature\n * median()(data);\n * @example\n * pipe([6, 10, 11], median()); // => 10\n * pipe([], median()); // => undefined\n * @dataLast\n * @category Number\n */\nexport function median(): <T extends IterableContainer<number>>(\n data: T,\n) => Median<T>;\n\nexport function median(...args: readonly unknown[]): unknown {\n return purry(medianImplementation, args);\n}\n\nconst numberComparator = (a: number, b: number): number => a - b;\n\nfunction medianImplementation<T extends IterableContainer<number>>(\n data: T,\n): T[number] | undefined {\n if (data.length === 0) {\n return undefined;\n }\n\n // TODO [>2]: When node 18 reaches end-of-life bump target lib to ES2023+ and use `Array.prototype.toSorted` here.\n const sortedData = [...data].sort(numberComparator);\n\n // For odd length, return the middle element\n if (sortedData.length % 2 !== 0) {\n return sortedData[(sortedData.length - 1) / 2];\n }\n\n // For even length, return the mean of the two middle elements\n const middleIndex = sortedData.length / 2;\n\n return (sortedData[middleIndex]! + sortedData[middleIndex - 1]!) / 2;\n}\n"],"mappings":"kGAoDA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAOA,EAAAA,MAAM,EAAsB,EAAK,CAG1C,MAAM,GAAoB,EAAW,IAAsB,EAAI,EAE/D,SAAS,EACP,EACuB,CACvB,GAAI,EAAK,SAAW,EAClB,OAIF,IAAM,EAAa,CAAC,GAAG,EAAK,CAAC,KAAK,EAAiB,CAGnD,GAAI,EAAW,OAAS,GAAM,EAC5B,OAAO,GAAY,EAAW,OAAS,GAAK,GAI9C,IAAM,EAAc,EAAW,OAAS,EAExC,OAAQ,EAAW,GAAgB,EAAW,EAAc,IAAO"}
|
package/dist/median.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{purry as e}from"./purry.js";function t(...t){return e(r,t)}const n=(e,t)=>e-t;function r(e){if(e.length===0)return;let t=[...e].sort(n);if(t.length%2!=0)return t[(t.length-1)/2];let r=t.length/2;return(t[r]+t[r-1])/2}export{t as median};
|
|
2
|
+
//# sourceMappingURL=median.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"median.js","names":[],"sources":["../src/median.ts"],"sourcesContent":["import type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\n\ntype Median<T extends IterableContainer<number>> =\n | (T extends readonly [] ? never : number)\n | (T extends readonly [unknown, ...unknown[]] ? never : undefined);\n\n/**\n * Returns the median of the elements of an array.\n *\n * Only `number` arrays are supported, as `bigint` is unable to represent fractional values.\n *\n * IMPORTANT: The result for empty arrays would be `undefined`, regardless of\n * the type of the array. This approach improves type-checking and ensures that\n * cases where `NaN` might occur are handled properly. To avoid adding this to\n * the return type for cases where the array is known to be non-empty you can use\n * `hasAtLeast` or `isEmpty` to guard against this case.\n *\n * @param data - The array of numbers.\n * @signature\n * median(data);\n * @example\n * pipe([6, 10, 11], median()); // => 10\n * median([]); // => undefined\n * @dataFirst\n * @category Number\n */\nexport function median<T extends IterableContainer<number>>(data: T): Median<T>;\n\n/**\n * Returns the median of the elements of an array.\n *\n * Only `number` arrays are supported, as `bigint` is unable to represent fractional values.\n *\n * IMPORTANT: The result for empty arrays would be `undefined`, regardless of\n * the type of the array. This approach improves type-checking and ensures that\n * cases where `NaN` might occur are handled properly. To avoid adding this to\n * the return type for cases where the array is known to be non-empty you can use\n * `hasAtLeast` or `isEmpty` to guard against this case.\n *\n * @signature\n * median()(data);\n * @example\n * pipe([6, 10, 11], median()); // => 10\n * pipe([], median()); // => undefined\n * @dataLast\n * @category Number\n */\nexport function median(): <T extends IterableContainer<number>>(\n data: T,\n) => Median<T>;\n\nexport function median(...args: readonly unknown[]): unknown {\n return purry(medianImplementation, args);\n}\n\nconst numberComparator = (a: number, b: number): number => a - b;\n\nfunction medianImplementation<T extends IterableContainer<number>>(\n data: T,\n): T[number] | undefined {\n if (data.length === 0) {\n return undefined;\n }\n\n // TODO [>2]: When node 18 reaches end-of-life bump target lib to ES2023+ and use `Array.prototype.toSorted` here.\n const sortedData = [...data].sort(numberComparator);\n\n // For odd length, return the middle element\n if (sortedData.length % 2 !== 0) {\n return sortedData[(sortedData.length - 1) / 2];\n }\n\n // For even length, return the mean of the two middle elements\n const middleIndex = sortedData.length / 2;\n\n return (sortedData[middleIndex]! + sortedData[middleIndex - 1]!) / 2;\n}\n"],"mappings":"mCAoDA,SAAgB,EAAO,GAAG,EAAmC,CAC3D,OAAO,EAAM,EAAsB,EAAK,CAG1C,MAAM,GAAoB,EAAW,IAAsB,EAAI,EAE/D,SAAS,EACP,EACuB,CACvB,GAAI,EAAK,SAAW,EAClB,OAIF,IAAM,EAAa,CAAC,GAAG,EAAK,CAAC,KAAK,EAAiB,CAGnD,GAAI,EAAW,OAAS,GAAM,EAC5B,OAAO,GAAY,EAAW,OAAS,GAAK,GAI9C,IAAM,EAAc,EAAW,OAAS,EAExC,OAAQ,EAAW,GAAgB,EAAW,EAAc,IAAO"}
|
package/dist/merge.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.cjs","names":["purry"],"sources":["../src/merge.ts"],"sourcesContent":["import type { Merge } from \"type-fest\";\nimport { purry } from \"./purry\";\n\n/**\n * Merges two objects into one by combining their properties, effectively\n * creating a new object that incorporates elements from both. The merge\n * operation prioritizes the second object's properties, allowing them to\n * overwrite those from the first object with the same names.\n *\n * Equivalent to `{ ...data, ...source }`.\n *\n * @param data - The destination object, serving as the basis for the merge.\n * Properties from this object are included in the new object, but will be\n * overwritten by properties from the source object with matching keys.\n * @param source - The source object, whose properties will be included in the\n * new object. If properties in this object share keys with properties in the\n * destination object, the values from the source object will be used in the\n * new object.\n * @returns An object fully containing `source`, and any properties from `data`\n * that don't share a name with any property in `source`.\n * @signature\n * merge(data, source)\n * @example\n * merge({ x: 1, y: 2 }, { y: 10, z: 2 }) // => { x: 1, y: 10, z: 2 }\n * @dataFirst\n * @category Object\n */\nexport function merge<T, Source>(data: T, source: Source): Merge<T, Source>;\n\n/**\n * Merges two objects into one by combining their properties, effectively\n * creating a new object that incorporates elements from both. The merge\n * operation prioritizes the second object's properties, allowing them to\n * overwrite those from the first object with the same names.\n *\n * Equivalent to `{ ...data, ...source }`.\n *\n * @param source - The source object, whose properties will be included in the\n * new object. If properties in this object share keys with properties in the\n * destination object, the values from the source object will be used in the\n * new object.\n * @returns An object fully containing `source`, and any properties from `data`\n * that don't share a name with any property in `source`.\n * @signature\n * merge(source)(data)\n * @example\n * pipe(\n * { x: 1, y: 2 },\n * merge({ y: 10, z: 2 }),\n * ); // => { x: 1, y: 10, z: 2 }\n * @dataLast\n * @category Object\n */\nexport function merge<Source>(source: Source): <T>(data: T) => Merge<T, Source>;\n\nexport function merge(...args: readonly unknown[]): unknown {\n return purry(mergeImplementation, args);\n}\n\nconst mergeImplementation = <T, Source>(\n data: T,\n source: Source,\n // @ts-expect-error [ts2322] - TypeScript is failing to infer that the result of spreading the two objects satisfies the more complex Merge type.\n): Merge<T, Source> => ({ ...data, ...source });\n"],"mappings":"kGAuDA,SAAgB,EAAM,GAAG,EAAmC,CAC1D,OAAOA,EAAAA,MAAM,EAAqB,EAAK,CAGzC,MAAM,GACJ,EACA,KAEsB,CAAE,GAAG,EAAM,GAAG,EAAQ"}
|
package/dist/merge.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.js","names":[],"sources":["../src/merge.ts"],"sourcesContent":["import type { Merge } from \"type-fest\";\nimport { purry } from \"./purry\";\n\n/**\n * Merges two objects into one by combining their properties, effectively\n * creating a new object that incorporates elements from both. The merge\n * operation prioritizes the second object's properties, allowing them to\n * overwrite those from the first object with the same names.\n *\n * Equivalent to `{ ...data, ...source }`.\n *\n * @param data - The destination object, serving as the basis for the merge.\n * Properties from this object are included in the new object, but will be\n * overwritten by properties from the source object with matching keys.\n * @param source - The source object, whose properties will be included in the\n * new object. If properties in this object share keys with properties in the\n * destination object, the values from the source object will be used in the\n * new object.\n * @returns An object fully containing `source`, and any properties from `data`\n * that don't share a name with any property in `source`.\n * @signature\n * merge(data, source)\n * @example\n * merge({ x: 1, y: 2 }, { y: 10, z: 2 }) // => { x: 1, y: 10, z: 2 }\n * @dataFirst\n * @category Object\n */\nexport function merge<T, Source>(data: T, source: Source): Merge<T, Source>;\n\n/**\n * Merges two objects into one by combining their properties, effectively\n * creating a new object that incorporates elements from both. The merge\n * operation prioritizes the second object's properties, allowing them to\n * overwrite those from the first object with the same names.\n *\n * Equivalent to `{ ...data, ...source }`.\n *\n * @param source - The source object, whose properties will be included in the\n * new object. If properties in this object share keys with properties in the\n * destination object, the values from the source object will be used in the\n * new object.\n * @returns An object fully containing `source`, and any properties from `data`\n * that don't share a name with any property in `source`.\n * @signature\n * merge(source)(data)\n * @example\n * pipe(\n * { x: 1, y: 2 },\n * merge({ y: 10, z: 2 }),\n * ); // => { x: 1, y: 10, z: 2 }\n * @dataLast\n * @category Object\n */\nexport function merge<Source>(source: Source): <T>(data: T) => Merge<T, Source>;\n\nexport function merge(...args: readonly unknown[]): unknown {\n return purry(mergeImplementation, args);\n}\n\nconst mergeImplementation = <T, Source>(\n data: T,\n source: Source,\n // @ts-expect-error [ts2322] - TypeScript is failing to infer that the result of spreading the two objects satisfies the more complex Merge type.\n): Merge<T, Source> => ({ ...data, ...source });\n"],"mappings":"mCAuDA,SAAgB,EAAM,GAAG,EAAmC,CAC1D,OAAO,EAAM,EAAqB,EAAK,CAGzC,MAAM,GACJ,EACA,KAEsB,CAAE,GAAG,EAAM,GAAG,EAAQ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeAll.cjs","names":[],"sources":["../src/mergeAll.ts"],"sourcesContent":["import type {\n EmptyObject,\n Merge,\n SharedUnionFields,\n Simplify,\n} from \"type-fest\";\nimport type { DisjointUnionFields } from \"./internal/types/DisjointUnionFields\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { NonEmptyArray } from \"./internal/types/NonEmptyArray\";\nimport type { TupleParts } from \"./internal/types/TupleParts\";\n\n/**\n * Merge a tuple of object types, where props from later objects override earlier props.\n */\ntype MergeTuple<\n T extends IterableContainer,\n Result = object, // no-op for the first iteration in the successive merges, also infers object as type by default if an empty tuple is used\n> = T extends readonly [infer Head, ...infer Rest]\n ? MergeTuple<Rest, Merge<Result, Head>>\n : Result;\n\n// In the context of a heterogeneous array, the array may not have objects from every type of the union.\n// This means some fields may be missing in the final object, so we make them optional.\n// If there is a non-optional field shared among all members of the union, then we know that if the array is not empty, the field must be present and avoid becoming optional.\n// If the field is already optional, this doesn't really matter.\n// If the array is empty, we know that the loop won't run so we'll just get the empty object.\n// Since we don't know the order of the items in the array, when we merge common fields, we don't know what the final type for the field will be, but we do know that it is one of the many possible types that are available across the members of the union for that field.\n// We represent these possibilities by combining the field's different types across the union members into a union.\ntype MergeUnion<T extends object> = Simplify<\n SharedUnionFields<T> & Partial<DisjointUnionFields<T>>\n>;\n\ntype MergeAll<T extends IterableContainer<object>> =\n // determine if it's a tuple or array\n TupleParts<T> extends { item: never }\n ? T extends readonly []\n ? EmptyObject\n : MergeTuple<T>\n : MergeUnion<T[number]> | EmptyObject;\n\n/**\n * Merges a list of objects into a single object.\n *\n * @param objects - The array of objects.\n * @returns A new object merged with all of the objects in the list. If the list is empty, an empty object is returned.\n * @signature\n * mergeAll(objects)\n * @example\n * mergeAll([{ a: 1, b: 1 }, { b: 2, c: 3 }, { d: 10 }]) // => { a: 1, b: 2, c: 3, d: 10 }\n * mergeAll([]) // => {}\n * @dataFirst\n * @category Array\n */\nexport function mergeAll<T extends object>(\n objects: Readonly<NonEmptyArray<T>>,\n): MergeUnion<T>;\nexport function mergeAll<T extends IterableContainer<object>>(\n objects: T,\n): MergeAll<T>;\nexport function mergeAll(objects: readonly object[]): object {\n let out = {};\n\n for (const item of objects) {\n out = { ...out, ...item };\n }\n\n return out;\n}\n"],"mappings":"mEA2DA,SAAgB,EAAS,EAAoC,CAC3D,IAAI,EAAM,EAAE,CAEZ,IAAK,IAAM,KAAQ,EACjB,EAAM,CAAE,GAAG,EAAK,GAAG,EAAM,CAG3B,OAAO"}
|
package/dist/mergeAll.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeAll.js","names":[],"sources":["../src/mergeAll.ts"],"sourcesContent":["import type {\n EmptyObject,\n Merge,\n SharedUnionFields,\n Simplify,\n} from \"type-fest\";\nimport type { DisjointUnionFields } from \"./internal/types/DisjointUnionFields\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { NonEmptyArray } from \"./internal/types/NonEmptyArray\";\nimport type { TupleParts } from \"./internal/types/TupleParts\";\n\n/**\n * Merge a tuple of object types, where props from later objects override earlier props.\n */\ntype MergeTuple<\n T extends IterableContainer,\n Result = object, // no-op for the first iteration in the successive merges, also infers object as type by default if an empty tuple is used\n> = T extends readonly [infer Head, ...infer Rest]\n ? MergeTuple<Rest, Merge<Result, Head>>\n : Result;\n\n// In the context of a heterogeneous array, the array may not have objects from every type of the union.\n// This means some fields may be missing in the final object, so we make them optional.\n// If there is a non-optional field shared among all members of the union, then we know that if the array is not empty, the field must be present and avoid becoming optional.\n// If the field is already optional, this doesn't really matter.\n// If the array is empty, we know that the loop won't run so we'll just get the empty object.\n// Since we don't know the order of the items in the array, when we merge common fields, we don't know what the final type for the field will be, but we do know that it is one of the many possible types that are available across the members of the union for that field.\n// We represent these possibilities by combining the field's different types across the union members into a union.\ntype MergeUnion<T extends object> = Simplify<\n SharedUnionFields<T> & Partial<DisjointUnionFields<T>>\n>;\n\ntype MergeAll<T extends IterableContainer<object>> =\n // determine if it's a tuple or array\n TupleParts<T> extends { item: never }\n ? T extends readonly []\n ? EmptyObject\n : MergeTuple<T>\n : MergeUnion<T[number]> | EmptyObject;\n\n/**\n * Merges a list of objects into a single object.\n *\n * @param objects - The array of objects.\n * @returns A new object merged with all of the objects in the list. If the list is empty, an empty object is returned.\n * @signature\n * mergeAll(objects)\n * @example\n * mergeAll([{ a: 1, b: 1 }, { b: 2, c: 3 }, { d: 10 }]) // => { a: 1, b: 2, c: 3, d: 10 }\n * mergeAll([]) // => {}\n * @dataFirst\n * @category Array\n */\nexport function mergeAll<T extends object>(\n objects: Readonly<NonEmptyArray<T>>,\n): MergeUnion<T>;\nexport function mergeAll<T extends IterableContainer<object>>(\n objects: T,\n): MergeAll<T>;\nexport function mergeAll(objects: readonly object[]): object {\n let out = {};\n\n for (const item of objects) {\n out = { ...out, ...item };\n }\n\n return out;\n}\n"],"mappings":"AA2DA,SAAgB,EAAS,EAAoC,CAC3D,IAAI,EAAM,EAAE,CAEZ,IAAK,IAAM,KAAQ,EACjB,EAAM,CAAE,GAAG,EAAK,GAAG,EAAM,CAG3B,OAAO"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purry.cjs`),t=require(`./isPlainObject.cjs`);function n(...t){return e.purry(r,t)}function r(e,n){let i={...e,...n};for(let a in n){if(!(a in e))continue;let{[a]:o}=e;if(!t.isPlainObject(o))continue;let{[a]:s}=n;t.isPlainObject(s)&&(i[a]=r(o,s))}return i}exports.mergeDeep=n;
|
|
2
|
+
//# sourceMappingURL=mergeDeep.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeDeep.cjs","names":["purry","isPlainObject"],"sources":["../src/mergeDeep.ts"],"sourcesContent":["import type { MergeDeep } from \"type-fest\";\nimport { isPlainObject } from \"./isPlainObject\";\nimport { purry } from \"./purry\";\n\n/**\n * Merges the `source` object into the `destination` object. The merge is similar to performing `{ ...destination, ... source }` (where disjoint values from each object would be copied as-is, and for any overlapping props the value from `source` would be used); But for *each prop* (`p`), if **both** `destination` and `source` have a **plain-object** as a value, the value would be taken as the result of recursively deepMerging them (`result.p === deepMerge(destination.p, source.p)`).\n *\n * @param destination - The object to merge into. In general, this object would have it's values overridden.\n * @param source - The object to merge from. In general, shared keys would be taken from this object.\n * @returns The merged object.\n * @signature\n * mergeDeep(destination, source)\n * @example\n * mergeDeep({ foo: 'bar', x: 1 }, { foo: 'baz', y: 2 }) // => { foo: 'baz', x: 1, y: 2 }\n * @dataFirst\n * @category Object\n */\nexport function mergeDeep<Destination extends object, Source extends object>(\n destination: Destination,\n source: Source,\n): MergeDeep<Destination, Source>;\n\n/**\n * Merges the `source` object into the `destination` object. The merge is similar to performing `{ ...destination, ... source }` (where disjoint values from each object would be copied as-is, and for any overlapping props the value from `source` would be used); But for *each prop* (`p`), if **both** `destination` and `source` have a **plain-object** as a value, the value would be taken as the result of recursively deepMerging them (`result.p === deepMerge(destination.p, source.p)`).\n *\n * @param source - The object to merge from. In general, shared keys would be taken from this object.\n * @returns The merged object.\n * @signature\n * mergeDeep(source)(destination)\n * @example\n * pipe(\n * { foo: 'bar', x: 1 },\n * mergeDeep({ foo: 'baz', y: 2 }),\n * ); // => { foo: 'baz', x: 1, y: 2 }\n * @dataLast\n * @category Object\n */\nexport function mergeDeep<Source extends object>(\n source: Source,\n): <Destination extends object>(\n target: Destination,\n) => MergeDeep<Destination, Source>;\n\nexport function mergeDeep(...args: readonly unknown[]): unknown {\n return purry(mergeDeepImplementation, args);\n}\n\nfunction mergeDeepImplementation<\n Destination extends object,\n Source extends object,\n>(destination: Destination, source: Source): MergeDeep<Destination, Source> {\n // At this point the output is already merged, simply not deeply merged.\n const output = { ...destination, ...source } as Record<\n keyof Destination | keyof Source,\n unknown\n >;\n\n // now just scan the output and look for values that should have been deep-\n // merged\n for (const key in source) {\n if (!(key in destination)) {\n // They don't share this key.\n continue;\n }\n\n const { [key]: destinationValue } = destination;\n if (!isPlainObject(destinationValue)) {\n // The value in destination is not a mergeable object so the value from\n // source (which was already copied in the shallow merge) would be used\n // as-is.\n continue;\n }\n\n const { [key]: sourceValue } = source;\n if (!isPlainObject(sourceValue)) {\n // The value in source is not a mergeable object either, so it will\n // override the object in destination.\n continue;\n }\n\n // Both destination and source have a mergeable object for this key, so we\n // recursively merge them.\n // @ts-expect-error [ts2590] - We build the output object iteratively, I don't think it's possible to improve the types here so that typescript infers this correctly.\n output[key] = mergeDeepImplementation(destinationValue, sourceValue);\n }\n\n // @ts-expect-error [ts2322] - We build the output object iteratively, I don't think it's possible to improve the types here so that typescript infers this correctly.\n return output;\n}\n"],"mappings":"mIA2CA,SAAgB,EAAU,GAAG,EAAmC,CAC9D,OAAOA,EAAAA,MAAM,EAAyB,EAAK,CAG7C,SAAS,EAGP,EAA0B,EAAgD,CAE1E,IAAM,EAAS,CAAE,GAAG,EAAa,GAAG,EAAQ,CAO5C,IAAK,IAAM,KAAO,EAAQ,CACxB,GAAI,EAAE,KAAO,GAEX,SAGF,GAAM,EAAG,GAAM,GAAqB,EACpC,GAAI,CAACC,EAAAA,cAAc,EAAiB,CAIlC,SAGF,GAAM,EAAG,GAAM,GAAgB,EAC1BA,EAAAA,cAAc,EAAY,GAS/B,EAAO,GAAO,EAAwB,EAAkB,EAAY,EAItE,OAAO"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{purry as e}from"./purry.js";import{isPlainObject as t}from"./isPlainObject.js";function n(...t){return e(r,t)}function r(e,n){let i={...e,...n};for(let a in n){if(!(a in e))continue;let{[a]:o}=e;if(!t(o))continue;let{[a]:s}=n;t(s)&&(i[a]=r(o,s))}return i}export{n as mergeDeep};
|
|
2
|
+
//# sourceMappingURL=mergeDeep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeDeep.js","names":[],"sources":["../src/mergeDeep.ts"],"sourcesContent":["import type { MergeDeep } from \"type-fest\";\nimport { isPlainObject } from \"./isPlainObject\";\nimport { purry } from \"./purry\";\n\n/**\n * Merges the `source` object into the `destination` object. The merge is similar to performing `{ ...destination, ... source }` (where disjoint values from each object would be copied as-is, and for any overlapping props the value from `source` would be used); But for *each prop* (`p`), if **both** `destination` and `source` have a **plain-object** as a value, the value would be taken as the result of recursively deepMerging them (`result.p === deepMerge(destination.p, source.p)`).\n *\n * @param destination - The object to merge into. In general, this object would have it's values overridden.\n * @param source - The object to merge from. In general, shared keys would be taken from this object.\n * @returns The merged object.\n * @signature\n * mergeDeep(destination, source)\n * @example\n * mergeDeep({ foo: 'bar', x: 1 }, { foo: 'baz', y: 2 }) // => { foo: 'baz', x: 1, y: 2 }\n * @dataFirst\n * @category Object\n */\nexport function mergeDeep<Destination extends object, Source extends object>(\n destination: Destination,\n source: Source,\n): MergeDeep<Destination, Source>;\n\n/**\n * Merges the `source` object into the `destination` object. The merge is similar to performing `{ ...destination, ... source }` (where disjoint values from each object would be copied as-is, and for any overlapping props the value from `source` would be used); But for *each prop* (`p`), if **both** `destination` and `source` have a **plain-object** as a value, the value would be taken as the result of recursively deepMerging them (`result.p === deepMerge(destination.p, source.p)`).\n *\n * @param source - The object to merge from. In general, shared keys would be taken from this object.\n * @returns The merged object.\n * @signature\n * mergeDeep(source)(destination)\n * @example\n * pipe(\n * { foo: 'bar', x: 1 },\n * mergeDeep({ foo: 'baz', y: 2 }),\n * ); // => { foo: 'baz', x: 1, y: 2 }\n * @dataLast\n * @category Object\n */\nexport function mergeDeep<Source extends object>(\n source: Source,\n): <Destination extends object>(\n target: Destination,\n) => MergeDeep<Destination, Source>;\n\nexport function mergeDeep(...args: readonly unknown[]): unknown {\n return purry(mergeDeepImplementation, args);\n}\n\nfunction mergeDeepImplementation<\n Destination extends object,\n Source extends object,\n>(destination: Destination, source: Source): MergeDeep<Destination, Source> {\n // At this point the output is already merged, simply not deeply merged.\n const output = { ...destination, ...source } as Record<\n keyof Destination | keyof Source,\n unknown\n >;\n\n // now just scan the output and look for values that should have been deep-\n // merged\n for (const key in source) {\n if (!(key in destination)) {\n // They don't share this key.\n continue;\n }\n\n const { [key]: destinationValue } = destination;\n if (!isPlainObject(destinationValue)) {\n // The value in destination is not a mergeable object so the value from\n // source (which was already copied in the shallow merge) would be used\n // as-is.\n continue;\n }\n\n const { [key]: sourceValue } = source;\n if (!isPlainObject(sourceValue)) {\n // The value in source is not a mergeable object either, so it will\n // override the object in destination.\n continue;\n }\n\n // Both destination and source have a mergeable object for this key, so we\n // recursively merge them.\n // @ts-expect-error [ts2590] - We build the output object iteratively, I don't think it's possible to improve the types here so that typescript infers this correctly.\n output[key] = mergeDeepImplementation(destinationValue, sourceValue);\n }\n\n // @ts-expect-error [ts2322] - We build the output object iteratively, I don't think it's possible to improve the types here so that typescript infers this correctly.\n return output;\n}\n"],"mappings":"sFA2CA,SAAgB,EAAU,GAAG,EAAmC,CAC9D,OAAO,EAAM,EAAyB,EAAK,CAG7C,SAAS,EAGP,EAA0B,EAAgD,CAE1E,IAAM,EAAS,CAAE,GAAG,EAAa,GAAG,EAAQ,CAO5C,IAAK,IAAM,KAAO,EAAQ,CACxB,GAAI,EAAE,KAAO,GAEX,SAGF,GAAM,EAAG,GAAM,GAAqB,EACpC,GAAI,CAAC,EAAc,EAAiB,CAIlC,SAGF,GAAM,EAAG,GAAM,GAAgB,EAC1B,EAAc,EAAY,GAS/B,EAAO,GAAO,EAAwB,EAAkB,EAAY,EAItE,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiply.cjs","names":["purry"],"sources":["../src/multiply.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Multiplies two numbers.\n *\n * @param value - The number.\n * @param multiplicand - The number to multiply the value by.\n * @signature\n * multiply(value, multiplicand);\n * @example\n * multiply(3, 4) // => 12\n * reduce([1, 2, 3, 4], multiply, 1) // => 24\n * @dataFirst\n * @category Number\n */\nexport function multiply(value: bigint, multiplicand: bigint): bigint;\nexport function multiply(value: number, multiplicand: number): number;\n\n/**\n * Multiplies two numbers.\n *\n * @param multiplicand - The number to multiply the value by.\n * @signature\n * multiply(multiplicand)(value);\n * @example\n * multiply(4)(3) // => 12\n * map([1, 2, 3, 4], multiply(2)) // => [2, 4, 6, 8]\n * @dataLast\n * @category Number\n */\nexport function multiply(multiplicand: bigint): (value: bigint) => bigint;\nexport function multiply(multiplicand: number): (value: number) => number;\n\nexport function multiply(...args: readonly unknown[]): unknown {\n return purry(multiplyImplementation, args);\n}\n\n// The implementation only uses `number` types, but that's just because it's\n// hard to tell typescript that both value and multiplicand would be of the same\n// type.\nconst multiplyImplementation = (value: number, multiplicand: number): number =>\n value * multiplicand;\n"],"mappings":"kGAiCA,SAAgB,EAAS,GAAG,EAAmC,CAC7D,OAAOA,EAAAA,MAAM,EAAwB,EAAK,CAM5C,MAAM,GAA0B,EAAe,IAC7C,EAAQ"}
|
package/dist/multiply.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multiply.js","names":[],"sources":["../src/multiply.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Multiplies two numbers.\n *\n * @param value - The number.\n * @param multiplicand - The number to multiply the value by.\n * @signature\n * multiply(value, multiplicand);\n * @example\n * multiply(3, 4) // => 12\n * reduce([1, 2, 3, 4], multiply, 1) // => 24\n * @dataFirst\n * @category Number\n */\nexport function multiply(value: bigint, multiplicand: bigint): bigint;\nexport function multiply(value: number, multiplicand: number): number;\n\n/**\n * Multiplies two numbers.\n *\n * @param multiplicand - The number to multiply the value by.\n * @signature\n * multiply(multiplicand)(value);\n * @example\n * multiply(4)(3) // => 12\n * map([1, 2, 3, 4], multiply(2)) // => [2, 4, 6, 8]\n * @dataLast\n * @category Number\n */\nexport function multiply(multiplicand: bigint): (value: bigint) => bigint;\nexport function multiply(multiplicand: number): (value: number) => number;\n\nexport function multiply(...args: readonly unknown[]): unknown {\n return purry(multiplyImplementation, args);\n}\n\n// The implementation only uses `number` types, but that's just because it's\n// hard to tell typescript that both value and multiplicand would be of the same\n// type.\nconst multiplyImplementation = (value: number, multiplicand: number): number =>\n value * multiplicand;\n"],"mappings":"mCAiCA,SAAgB,EAAS,GAAG,EAAmC,CAC7D,OAAO,EAAM,EAAwB,EAAK,CAM5C,MAAM,GAA0B,EAAe,IAC7C,EAAQ"}
|
package/dist/nthBy.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./purryOrderRules-B8pzD03D.cjs`),t=require(`./quickSelect-BwH5h4uh.cjs`);function n(...t){return e.n(r,t)}const r=(e,n,r)=>t.t(e,r>=0?r:e.length+r,n);exports.nthBy=n;
|
|
2
|
+
//# sourceMappingURL=nthBy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nthBy.cjs","names":["purryOrderRulesWithArgument","quickSelect"],"sources":["../src/nthBy.ts"],"sourcesContent":["import {\n purryOrderRulesWithArgument,\n type OrderRule,\n} from \"./internal/purryOrderRules\";\nimport { quickSelect } from \"./internal/quickSelect\";\nimport type { CompareFunction } from \"./internal/types/CompareFunction\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { NonEmptyArray } from \"./internal/types/NonEmptyArray\";\n\n/**\n * Retrieves the element that would be at the given index if the array were sorted according to specified rules. This function uses the *QuickSelect* algorithm running at an average complexity of *O(n)*. Semantically it is equivalent to `sortBy(data, ...rules).at(index)` which would run at *O(nlogn)*.\n *\n * See also `firstBy` which provides an even more efficient algorithm and a stricter return type, but only for `index === 0`. See `takeFirstBy` to get all the elements up to and including `index`.\n *\n * @param data - The input array.\n * @param index - The zero-based index for selecting the element in the sorted order. Negative indices count backwards from the end.\n * @param rules - A variadic array of order rules defining the sorting criteria. Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, \"desc\"]` for descending order.\n * @returns The element at the specified index in the sorted order, or `undefined` if the index is out of bounds.\n * @signature\n * nthBy(data, index, ...rules);\n * @example\n * nthBy([2,1,4,5,3,], 2, identity()); // => 3\n * @dataFirst\n * @category Array\n */\nexport function nthBy<T extends IterableContainer>(\n data: T,\n index: number,\n ...rules: Readonly<NonEmptyArray<OrderRule<T[number]>>>\n): T[number] | undefined;\n\n/**\n * Retrieves the element that would be at the given index if the array were sorted according to specified rules. This function uses the *QuickSelect* algorithm running at an average complexity of *O(n)*. Semantically it is equivalent to `sortBy(data, ...rules)[index]` which would run at *O(nlogn)*.\n *\n * See also `firstBy` which provides an even more efficient algorithm and a stricter return type, but only for `index === 0`. See `takeFirstBy` to get all the elements up to and including `index`.\n *\n * @param index - The zero-based index for selecting the element in the sorted order. Negative indices count backwards from the end.\n * @param rules - A variadic array of order rules defining the sorting criteria. Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, \"desc\"]` for descending order.\n * @returns The element at the specified index in the sorted order, or `undefined` if the index is out of bounds.\n * @signature\n * nthBy(index, ...rules)(data);\n * @example\n * pipe([2,1,4,5,3,], nthBy(2, identity())); // => 3\n * @dataLast\n * @category Array\n */\nexport function nthBy<T extends IterableContainer>(\n index: number,\n ...rules: Readonly<NonEmptyArray<OrderRule<T[number]>>>\n): (data: T) => T[number] | undefined;\n\nexport function nthBy(...args: readonly unknown[]): unknown {\n return purryOrderRulesWithArgument(nthByImplementation, args);\n}\n\nconst nthByImplementation = <T>(\n data: readonly T[],\n compareFn: CompareFunction<T>,\n index: number,\n): T | undefined =>\n quickSelect(\n data,\n // Allow negative indices gracefully\n index >= 0 ? index : data.length + index,\n compareFn,\n );\n"],"mappings":"6JAmDA,SAAgB,EAAM,GAAG,EAAmC,CAC1D,OAAOA,EAAAA,EAA4B,EAAqB,EAAK,CAG/D,MAAM,GACJ,EACA,EACA,IAEAC,EAAAA,EACE,EAEA,GAAS,EAAI,EAAQ,EAAK,OAAS,EACnC,EACD"}
|
package/dist/nthBy.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nthBy.js","names":[],"sources":["../src/nthBy.ts"],"sourcesContent":["import {\n purryOrderRulesWithArgument,\n type OrderRule,\n} from \"./internal/purryOrderRules\";\nimport { quickSelect } from \"./internal/quickSelect\";\nimport type { CompareFunction } from \"./internal/types/CompareFunction\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport type { NonEmptyArray } from \"./internal/types/NonEmptyArray\";\n\n/**\n * Retrieves the element that would be at the given index if the array were sorted according to specified rules. This function uses the *QuickSelect* algorithm running at an average complexity of *O(n)*. Semantically it is equivalent to `sortBy(data, ...rules).at(index)` which would run at *O(nlogn)*.\n *\n * See also `firstBy` which provides an even more efficient algorithm and a stricter return type, but only for `index === 0`. See `takeFirstBy` to get all the elements up to and including `index`.\n *\n * @param data - The input array.\n * @param index - The zero-based index for selecting the element in the sorted order. Negative indices count backwards from the end.\n * @param rules - A variadic array of order rules defining the sorting criteria. Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, \"desc\"]` for descending order.\n * @returns The element at the specified index in the sorted order, or `undefined` if the index is out of bounds.\n * @signature\n * nthBy(data, index, ...rules);\n * @example\n * nthBy([2,1,4,5,3,], 2, identity()); // => 3\n * @dataFirst\n * @category Array\n */\nexport function nthBy<T extends IterableContainer>(\n data: T,\n index: number,\n ...rules: Readonly<NonEmptyArray<OrderRule<T[number]>>>\n): T[number] | undefined;\n\n/**\n * Retrieves the element that would be at the given index if the array were sorted according to specified rules. This function uses the *QuickSelect* algorithm running at an average complexity of *O(n)*. Semantically it is equivalent to `sortBy(data, ...rules)[index]` which would run at *O(nlogn)*.\n *\n * See also `firstBy` which provides an even more efficient algorithm and a stricter return type, but only for `index === 0`. See `takeFirstBy` to get all the elements up to and including `index`.\n *\n * @param index - The zero-based index for selecting the element in the sorted order. Negative indices count backwards from the end.\n * @param rules - A variadic array of order rules defining the sorting criteria. Each order rule is a projection function that extracts a comparable value from the data. Sorting is based on these extracted values using the native `<` and `>` operators. Earlier rules take precedence over later ones. Use the syntax `[projection, \"desc\"]` for descending order.\n * @returns The element at the specified index in the sorted order, or `undefined` if the index is out of bounds.\n * @signature\n * nthBy(index, ...rules)(data);\n * @example\n * pipe([2,1,4,5,3,], nthBy(2, identity())); // => 3\n * @dataLast\n * @category Array\n */\nexport function nthBy<T extends IterableContainer>(\n index: number,\n ...rules: Readonly<NonEmptyArray<OrderRule<T[number]>>>\n): (data: T) => T[number] | undefined;\n\nexport function nthBy(...args: readonly unknown[]): unknown {\n return purryOrderRulesWithArgument(nthByImplementation, args);\n}\n\nconst nthByImplementation = <T>(\n data: readonly T[],\n compareFn: CompareFunction<T>,\n index: number,\n): T | undefined =>\n quickSelect(\n data,\n // Allow negative indices gracefully\n index >= 0 ? index : data.length + index,\n compareFn,\n );\n"],"mappings":"2FAmDA,SAAgB,EAAM,GAAG,EAAmC,CAC1D,OAAO,EAA4B,EAAqB,EAAK,CAG/D,MAAM,GACJ,EACA,EACA,IAEA,EACE,EAEA,GAAS,EAAI,EAAQ,EAAK,OAAS,EACnC,EACD"}
|
package/dist/objOf.cjs
ADDED