es-toolkit 1.13.1-dev.329 → 1.13.1-dev.333
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/dist/_chunk/index-CwRt_M.js +47 -0
- package/dist/_chunk/index-CwRt_M.js.map +1 -0
- package/dist/_chunk/isPlainObject-bK22pA.js +24 -0
- package/dist/_chunk/isPlainObject-bK22pA.js.map +1 -0
- package/dist/_chunk/randomInt-CF7bZK.js +20 -0
- package/dist/_chunk/randomInt-CF7bZK.js.map +1 -0
- package/dist/_chunk/union-CdQeDK.js +13 -0
- package/dist/_chunk/union-CdQeDK.js.map +1 -0
- package/dist/array/chunk.mjs +16 -8
- package/dist/array/chunk.mjs.map +1 -1
- package/dist/array/compact.mjs +12 -8
- package/dist/array/compact.mjs.map +1 -1
- package/dist/array/countBy.mjs +11 -8
- package/dist/array/countBy.mjs.map +1 -1
- package/dist/array/difference.mjs +7 -8
- package/dist/array/difference.mjs.map +1 -1
- package/dist/array/differenceBy.mjs +9 -8
- package/dist/array/differenceBy.mjs.map +1 -1
- package/dist/array/differenceWith.mjs +10 -8
- package/dist/array/differenceWith.mjs.map +1 -1
- package/dist/array/drop.mjs +7 -8
- package/dist/array/drop.mjs.map +1 -1
- package/dist/array/dropRight.mjs +10 -8
- package/dist/array/dropRight.mjs.map +1 -1
- package/dist/array/dropRightWhile.mjs +11 -8
- package/dist/array/dropRightWhile.mjs.map +1 -1
- package/dist/array/dropWhile.mjs +10 -8
- package/dist/array/dropWhile.mjs.map +1 -1
- package/dist/array/fill.mjs +12 -8
- package/dist/array/fill.mjs.map +1 -1
- package/dist/array/flatMap.mjs +8 -9
- package/dist/array/flatMap.mjs.map +1 -1
- package/dist/array/flatten.mjs +19 -8
- package/dist/array/flatten.mjs.map +1 -1
- package/dist/array/flattenDeep.mjs +8 -9
- package/dist/array/flattenDeep.mjs.map +1 -1
- package/dist/array/forEachRight.mjs +9 -8
- package/dist/array/forEachRight.mjs.map +1 -1
- package/dist/array/groupBy.mjs +14 -8
- package/dist/array/groupBy.mjs.map +1 -1
- package/dist/array/head.mjs +6 -8
- package/dist/array/head.mjs.map +1 -1
- package/dist/array/index.js +353 -498
- package/dist/array/index.js.map +1 -1
- package/dist/array/index.mjs +52 -211
- package/dist/array/index.mjs.map +1 -1
- package/dist/array/initial.mjs +9 -8
- package/dist/array/initial.mjs.map +1 -1
- package/dist/array/intersection.mjs +9 -8
- package/dist/array/intersection.mjs.map +1 -1
- package/dist/array/intersectionBy.mjs +7 -8
- package/dist/array/intersectionBy.mjs.map +1 -1
- package/dist/array/intersectionWith.mjs +10 -8
- package/dist/array/intersectionWith.mjs.map +1 -1
- package/dist/array/keyBy.mjs +11 -8
- package/dist/array/keyBy.mjs.map +1 -1
- package/dist/array/last.mjs +6 -8
- package/dist/array/last.mjs.map +1 -1
- package/dist/array/maxBy.mjs +15 -8
- package/dist/array/maxBy.mjs.map +1 -1
- package/dist/array/minBy.mjs +15 -8
- package/dist/array/minBy.mjs.map +1 -1
- package/dist/array/orderBy.mjs +26 -8
- package/dist/array/orderBy.mjs.map +1 -1
- package/dist/array/partition.mjs +16 -8
- package/dist/array/partition.mjs.map +1 -1
- package/dist/array/sample.mjs +7 -8
- package/dist/array/sample.mjs.map +1 -1
- package/dist/array/sampleSize.mjs +21 -10
- package/dist/array/sampleSize.mjs.map +1 -1
- package/dist/array/shuffle.mjs +11 -8
- package/dist/array/shuffle.mjs.map +1 -1
- package/dist/array/tail.mjs +14 -8
- package/dist/array/tail.mjs.map +1 -1
- package/dist/array/take.mjs +6 -8
- package/dist/array/take.mjs.map +1 -1
- package/dist/array/takeRight.mjs +9 -8
- package/dist/array/takeRight.mjs.map +1 -1
- package/dist/array/takeRightWhile.mjs +11 -8
- package/dist/array/takeRightWhile.mjs.map +1 -1
- package/dist/array/takeWhile.mjs +13 -8
- package/dist/array/takeWhile.mjs.map +1 -1
- package/dist/array/toFilled.mjs +13 -8
- package/dist/array/toFilled.mjs.map +1 -1
- package/dist/array/union.mjs +8 -9
- package/dist/array/union.mjs.map +1 -1
- package/dist/array/unionBy.mjs +13 -8
- package/dist/array/unionBy.mjs.map +1 -1
- package/dist/array/unionWith.mjs +8 -9
- package/dist/array/unionWith.mjs.map +1 -1
- package/dist/array/uniq.mjs +6 -8
- package/dist/array/uniq.mjs.map +1 -1
- package/dist/array/uniqBy.mjs +13 -8
- package/dist/array/uniqBy.mjs.map +1 -1
- package/dist/array/uniqWith.mjs +13 -8
- package/dist/array/uniqWith.mjs.map +1 -1
- package/dist/array/unzip.mjs +19 -8
- package/dist/array/unzip.mjs.map +1 -1
- package/dist/array/unzipWith.mjs +15 -8
- package/dist/array/unzipWith.mjs.map +1 -1
- package/dist/array/without.mjs +7 -8
- package/dist/array/without.mjs.map +1 -1
- package/dist/array/xor.mjs +10 -12
- package/dist/array/xor.mjs.map +1 -1
- package/dist/array/xorBy.mjs +12 -11
- package/dist/array/xorBy.mjs.map +1 -1
- package/dist/array/xorWith.mjs +12 -12
- package/dist/array/xorWith.mjs.map +1 -1
- package/dist/array/zip.mjs +15 -8
- package/dist/array/zip.mjs.map +1 -1
- package/dist/array/zipObject.mjs +10 -8
- package/dist/array/zipObject.mjs.map +1 -1
- package/dist/array/zipWith.mjs +14 -8
- package/dist/array/zipWith.mjs.map +1 -1
- package/dist/compat/_internal/isDeepKey.mjs +16 -0
- package/dist/compat/_internal/isDeepKey.mjs.map +1 -0
- package/dist/compat/_internal/isIndex.mjs +17 -0
- package/dist/compat/_internal/isIndex.mjs.map +1 -0
- package/dist/compat/_internal/toPath.mjs +41 -0
- package/dist/compat/_internal/toPath.mjs.map +1 -0
- package/dist/compat/array/chunk.d.mts +26 -0
- package/dist/compat/array/chunk.d.ts +26 -0
- package/dist/compat/array/chunk.mjs +12 -0
- package/dist/compat/array/chunk.mjs.map +1 -0
- package/dist/compat/array/concat.d.mts +30 -0
- package/dist/compat/array/concat.d.ts +30 -0
- package/dist/compat/array/concat.mjs +8 -0
- package/dist/compat/array/concat.mjs.map +1 -0
- package/dist/compat/array/difference.d.mts +3 -0
- package/dist/compat/array/difference.d.ts +3 -0
- package/dist/compat/array/difference.mjs +11 -0
- package/dist/compat/array/difference.mjs.map +1 -0
- package/dist/compat/array/fill.d.mts +33 -0
- package/dist/compat/array/fill.d.ts +33 -0
- package/dist/compat/array/fill.mjs +16 -0
- package/dist/compat/array/fill.mjs.map +1 -0
- package/dist/compat/array/zipObjectDeep.d.mts +37 -0
- package/dist/compat/array/zipObjectDeep.d.ts +37 -0
- package/dist/compat/array/zipObjectDeep.mjs +17 -0
- package/dist/compat/array/zipObjectDeep.mjs.map +1 -0
- package/dist/compat/index.d.mts +14 -546
- package/dist/compat/index.d.ts +14 -546
- package/dist/compat/index.js +287 -1498
- package/dist/compat/index.js.map +1 -1
- package/dist/compat/index.mjs +106 -415
- package/dist/compat/index.mjs.map +1 -1
- package/dist/compat/math/max.d.mts +19 -0
- package/dist/compat/math/max.d.ts +19 -0
- package/dist/compat/math/max.mjs +14 -0
- package/dist/compat/math/max.mjs.map +1 -0
- package/dist/compat/math/min.d.mts +19 -0
- package/dist/compat/math/min.d.ts +19 -0
- package/dist/compat/math/min.mjs +14 -0
- package/dist/compat/math/min.mjs.map +1 -0
- package/dist/compat/object/get.d.mts +247 -0
- package/dist/compat/object/get.d.ts +247 -0
- package/dist/compat/object/get.mjs +34 -0
- package/dist/compat/object/get.mjs.map +1 -0
- package/dist/compat/object/get.types.d.mts +9 -0
- package/dist/compat/object/get.types.d.ts +9 -0
- package/dist/compat/object/set.d.mts +30 -0
- package/dist/compat/object/set.d.ts +30 -0
- package/dist/compat/object/set.mjs +25 -0
- package/dist/compat/object/set.mjs.map +1 -0
- package/dist/compat/predicate/isArray.d.mts +24 -0
- package/dist/compat/predicate/isArray.d.ts +24 -0
- package/dist/compat/predicate/isArray.mjs +6 -0
- package/dist/compat/predicate/isArray.mjs.map +1 -0
- package/dist/compat/predicate/isPlainObject.d.mts +25 -0
- package/dist/compat/predicate/isPlainObject.d.ts +25 -0
- package/dist/compat/predicate/isPlainObject.mjs +30 -0
- package/dist/compat/predicate/isPlainObject.mjs.map +1 -0
- package/dist/compat/predicate/isTypedArray.d.mts +19 -0
- package/dist/compat/predicate/isTypedArray.d.ts +19 -0
- package/dist/compat/predicate/isTypedArray.mjs +8 -0
- package/dist/compat/predicate/isTypedArray.mjs.map +1 -0
- package/dist/compat/string/endsWith.d.mts +20 -0
- package/dist/compat/string/endsWith.d.ts +20 -0
- package/dist/compat/string/endsWith.mjs +6 -0
- package/dist/compat/string/endsWith.mjs.map +1 -0
- package/dist/compat/string/startsWith.d.mts +20 -0
- package/dist/compat/string/startsWith.d.ts +20 -0
- package/dist/compat/string/startsWith.mjs +6 -0
- package/dist/compat/string/startsWith.mjs.map +1 -0
- package/dist/error/AbortError.mjs +9 -8
- package/dist/error/AbortError.mjs.map +1 -1
- package/dist/error/TimeoutError.mjs +9 -8
- package/dist/error/TimeoutError.mjs.map +1 -1
- package/dist/function/after.mjs +14 -7
- package/dist/function/after.mjs.map +1 -1
- package/dist/function/debounce.mjs +29 -8
- package/dist/function/debounce.mjs.map +1 -1
- package/dist/function/index.js +66 -102
- package/dist/function/index.js.map +1 -1
- package/dist/function/index.mjs +7 -29
- package/dist/function/index.mjs.map +1 -1
- package/dist/function/negate.mjs +6 -8
- package/dist/function/negate.mjs.map +1 -1
- package/dist/function/noop.mjs +4 -8
- package/dist/function/noop.mjs.map +1 -1
- package/dist/function/once.mjs +16 -8
- package/dist/function/once.mjs.map +1 -1
- package/dist/function/throttle.mjs +14 -8
- package/dist/function/throttle.mjs.map +1 -1
- package/dist/index.js +114 -1307
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -399
- package/dist/index.mjs.map +1 -1
- package/dist/math/clamp.mjs +9 -8
- package/dist/math/clamp.mjs.map +1 -1
- package/dist/math/inRange.mjs +13 -8
- package/dist/math/inRange.mjs.map +1 -1
- package/dist/math/index.js +59 -115
- package/dist/math/index.js.map +1 -1
- package/dist/math/index.mjs +11 -45
- package/dist/math/index.mjs.map +1 -1
- package/dist/math/mean.mjs +8 -9
- package/dist/math/mean.mjs.map +1 -1
- package/dist/math/meanBy.mjs +9 -10
- package/dist/math/meanBy.mjs.map +1 -1
- package/dist/math/random.mjs +13 -8
- package/dist/math/random.mjs.map +1 -1
- package/dist/math/randomInt.mjs +8 -9
- package/dist/math/randomInt.mjs.map +1 -1
- package/dist/math/range.mjs +21 -8
- package/dist/math/range.mjs.map +1 -1
- package/dist/math/round.mjs +10 -8
- package/dist/math/round.mjs.map +1 -1
- package/dist/math/sum.mjs +10 -8
- package/dist/math/sum.mjs.map +1 -1
- package/dist/math/sumBy.mjs +9 -9
- package/dist/math/sumBy.mjs.map +1 -1
- package/dist/object/clone.mjs +40 -8
- package/dist/object/clone.mjs.map +1 -1
- package/dist/object/cloneDeep.mjs +100 -8
- package/dist/object/cloneDeep.mjs.map +1 -1
- package/dist/object/flattenObject.mjs +29 -9
- package/dist/object/flattenObject.mjs.map +1 -1
- package/dist/object/index.js +184 -232
- package/dist/object/index.js.map +1 -1
- package/dist/object/index.mjs +9 -38
- package/dist/object/index.mjs.map +1 -1
- package/dist/object/invert.mjs +13 -8
- package/dist/object/invert.mjs.map +1 -1
- package/dist/object/omit.mjs +10 -8
- package/dist/object/omit.mjs.map +1 -1
- package/dist/object/omitBy.mjs +13 -8
- package/dist/object/omitBy.mjs.map +1 -1
- package/dist/object/pick.mjs +10 -8
- package/dist/object/pick.mjs.map +1 -1
- package/dist/object/pickBy.mjs +13 -8
- package/dist/object/pickBy.mjs.map +1 -1
- package/dist/predicate/index.js +65 -126
- package/dist/predicate/index.js.map +1 -1
- package/dist/predicate/index.mjs +12 -51
- package/dist/predicate/index.mjs.map +1 -1
- package/dist/predicate/isArrayLike.mjs +9 -9
- package/dist/predicate/isArrayLike.mjs.map +1 -1
- package/dist/predicate/isEqual.mjs +36 -10
- package/dist/predicate/isEqual.mjs.map +1 -1
- package/dist/predicate/isFunction.mjs +6 -8
- package/dist/predicate/isFunction.mjs.map +1 -1
- package/dist/predicate/isLength.mjs +6 -8
- package/dist/predicate/isLength.mjs.map +1 -1
- package/dist/predicate/isNil.mjs +6 -8
- package/dist/predicate/isNil.mjs.map +1 -1
- package/dist/predicate/isNotNil.mjs +6 -8
- package/dist/predicate/isNotNil.mjs.map +1 -1
- package/dist/predicate/isNull.mjs +6 -8
- package/dist/predicate/isNull.mjs.map +1 -1
- package/dist/predicate/isPlainObject.mjs +22 -8
- package/dist/predicate/isPlainObject.mjs.map +1 -1
- package/dist/predicate/isPrimitive.mjs +6 -8
- package/dist/predicate/isPrimitive.mjs.map +1 -1
- package/dist/predicate/isTypedArray.mjs +16 -8
- package/dist/predicate/isTypedArray.mjs.map +1 -1
- package/dist/predicate/isUndefined.mjs +6 -8
- package/dist/predicate/isUndefined.mjs.map +1 -1
- package/dist/promise/delay.mjs +21 -9
- package/dist/promise/delay.mjs.map +1 -1
- package/dist/promise/index.js +6 -72
- package/dist/promise/index.js.map +1 -1
- package/dist/promise/index.mjs +3 -16
- package/dist/promise/index.mjs.map +1 -1
- package/dist/promise/timeout.mjs +10 -11
- package/dist/promise/timeout.mjs.map +1 -1
- package/dist/promise/withTimeout.mjs +8 -12
- package/dist/promise/withTimeout.mjs.map +1 -1
- package/dist/string/_internal/getWords.mjs +7 -0
- package/dist/string/_internal/getWords.mjs.map +1 -0
- package/dist/string/camelCase.mjs +14 -10
- package/dist/string/camelCase.mjs.map +1 -1
- package/dist/string/capitalize.mjs +5 -7
- package/dist/string/capitalize.mjs.map +1 -1
- package/dist/string/index.js +42 -77
- package/dist/string/index.js.map +1 -1
- package/dist/string/index.mjs +7 -30
- package/dist/string/index.mjs.map +1 -1
- package/dist/string/kebabCase.mjs +8 -8
- package/dist/string/kebabCase.mjs.map +1 -1
- package/dist/string/lowerCase.mjs +8 -8
- package/dist/string/lowerCase.mjs.map +1 -1
- package/dist/string/snakeCase.mjs +8 -8
- package/dist/string/snakeCase.mjs.map +1 -1
- package/dist/string/startCase.mjs +21 -9
- package/dist/string/startCase.mjs.map +1 -1
- package/package.json +8 -2
- package/umd/browser.global.js +2 -2
- package/umd/browser.global.js.map +1 -0
- package/dist/array/chunk.js +0 -43
- package/dist/array/chunk.js.map +0 -1
- package/dist/array/compact.js +0 -39
- package/dist/array/compact.js.map +0 -1
- package/dist/array/countBy.js +0 -38
- package/dist/array/countBy.js.map +0 -1
- package/dist/array/difference.js +0 -34
- package/dist/array/difference.js.map +0 -1
- package/dist/array/differenceBy.js +0 -36
- package/dist/array/differenceBy.js.map +0 -1
- package/dist/array/differenceWith.js +0 -37
- package/dist/array/differenceWith.js.map +0 -1
- package/dist/array/drop.js +0 -34
- package/dist/array/drop.js.map +0 -1
- package/dist/array/dropRight.js +0 -37
- package/dist/array/dropRight.js.map +0 -1
- package/dist/array/dropRightWhile.js +0 -38
- package/dist/array/dropRightWhile.js.map +0 -1
- package/dist/array/dropWhile.js +0 -37
- package/dist/array/dropWhile.js.map +0 -1
- package/dist/array/fill.js +0 -39
- package/dist/array/fill.js.map +0 -1
- package/dist/array/flatMap.js +0 -52
- package/dist/array/flatMap.js.map +0 -1
- package/dist/array/flatten.js +0 -45
- package/dist/array/flatten.js.map +0 -1
- package/dist/array/flattenDeep.js +0 -52
- package/dist/array/flattenDeep.js.map +0 -1
- package/dist/array/forEachRight.js +0 -36
- package/dist/array/forEachRight.js.map +0 -1
- package/dist/array/groupBy.js +0 -41
- package/dist/array/groupBy.js.map +0 -1
- package/dist/array/head.js +0 -33
- package/dist/array/head.js.map +0 -1
- package/dist/array/initial.js +0 -36
- package/dist/array/initial.js.map +0 -1
- package/dist/array/intersection.js +0 -36
- package/dist/array/intersection.js.map +0 -1
- package/dist/array/intersectionBy.js +0 -34
- package/dist/array/intersectionBy.js.map +0 -1
- package/dist/array/intersectionWith.js +0 -37
- package/dist/array/intersectionWith.js.map +0 -1
- package/dist/array/keyBy.js +0 -38
- package/dist/array/keyBy.js.map +0 -1
- package/dist/array/last.js +0 -33
- package/dist/array/last.js.map +0 -1
- package/dist/array/maxBy.js +0 -42
- package/dist/array/maxBy.js.map +0 -1
- package/dist/array/minBy.js +0 -42
- package/dist/array/minBy.js.map +0 -1
- package/dist/array/orderBy.js +0 -53
- package/dist/array/orderBy.js.map +0 -1
- package/dist/array/partition.js +0 -42
- package/dist/array/partition.js.map +0 -1
- package/dist/array/sample.js +0 -34
- package/dist/array/sample.js.map +0 -1
- package/dist/array/sampleSize.js +0 -65
- package/dist/array/sampleSize.js.map +0 -1
- package/dist/array/shuffle.js +0 -38
- package/dist/array/shuffle.js.map +0 -1
- package/dist/array/tail.js +0 -41
- package/dist/array/tail.js.map +0 -1
- package/dist/array/take.js +0 -33
- package/dist/array/take.js.map +0 -1
- package/dist/array/takeRight.js +0 -36
- package/dist/array/takeRight.js.map +0 -1
- package/dist/array/takeRightWhile.js +0 -38
- package/dist/array/takeRightWhile.js.map +0 -1
- package/dist/array/takeWhile.js +0 -40
- package/dist/array/takeWhile.js.map +0 -1
- package/dist/array/toFilled.js +0 -40
- package/dist/array/toFilled.js.map +0 -1
- package/dist/array/union.js +0 -40
- package/dist/array/union.js.map +0 -1
- package/dist/array/unionBy.js +0 -40
- package/dist/array/unionBy.js.map +0 -1
- package/dist/array/unionWith.js +0 -47
- package/dist/array/unionWith.js.map +0 -1
- package/dist/array/uniq.js +0 -33
- package/dist/array/uniq.js.map +0 -1
- package/dist/array/uniqBy.js +0 -40
- package/dist/array/uniqBy.js.map +0 -1
- package/dist/array/uniqWith.js +0 -40
- package/dist/array/uniqWith.js.map +0 -1
- package/dist/array/unzip.js +0 -46
- package/dist/array/unzip.js.map +0 -1
- package/dist/array/unzipWith.js +0 -42
- package/dist/array/unzipWith.js.map +0 -1
- package/dist/array/without.js +0 -34
- package/dist/array/without.js.map +0 -1
- package/dist/array/xor.js +0 -59
- package/dist/array/xor.js.map +0 -1
- package/dist/array/xorBy.js +0 -63
- package/dist/array/xorBy.js.map +0 -1
- package/dist/array/xorWith.js +0 -72
- package/dist/array/xorWith.js.map +0 -1
- package/dist/array/zip.js +0 -42
- package/dist/array/zip.js.map +0 -1
- package/dist/array/zipObject.js +0 -37
- package/dist/array/zipObject.js.map +0 -1
- package/dist/array/zipWith.js +0 -41
- package/dist/array/zipWith.js.map +0 -1
- package/dist/browser.d.mts +0 -2
- package/dist/browser.d.ts +0 -2
- package/dist/browser.js +0 -1440
- package/dist/browser.js.map +0 -1
- package/dist/browser.mjs +0 -115
- package/dist/browser.mjs.map +0 -1
- package/dist/chunk-237HGSZS.mjs +0 -16
- package/dist/chunk-237HGSZS.mjs.map +0 -1
- package/dist/chunk-27QMXBLJ.mjs +0 -9
- package/dist/chunk-27QMXBLJ.mjs.map +0 -1
- package/dist/chunk-2IXFGSUA.mjs +0 -16
- package/dist/chunk-2IXFGSUA.mjs.map +0 -1
- package/dist/chunk-2KNLZB7V.mjs +0 -10
- package/dist/chunk-2KNLZB7V.mjs.map +0 -1
- package/dist/chunk-2SLTL4KL.mjs +0 -13
- package/dist/chunk-2SLTL4KL.mjs.map +0 -1
- package/dist/chunk-2ZCITDMK.mjs +0 -13
- package/dist/chunk-2ZCITDMK.mjs.map +0 -1
- package/dist/chunk-33MSBDC6.mjs +0 -21
- package/dist/chunk-33MSBDC6.mjs.map +0 -1
- package/dist/chunk-3EZAFZG3.mjs +0 -10
- package/dist/chunk-3EZAFZG3.mjs.map +0 -1
- package/dist/chunk-3SBT6WDU.mjs +0 -25
- package/dist/chunk-3SBT6WDU.mjs.map +0 -1
- package/dist/chunk-4DFAGGIM.mjs +0 -26
- package/dist/chunk-4DFAGGIM.mjs.map +0 -1
- package/dist/chunk-4OIZM4HS.mjs +0 -1
- package/dist/chunk-4OIZM4HS.mjs.map +0 -1
- package/dist/chunk-4ZES5T6V.mjs +0 -21
- package/dist/chunk-4ZES5T6V.mjs.map +0 -1
- package/dist/chunk-5ASRKEB4.mjs +0 -13
- package/dist/chunk-5ASRKEB4.mjs.map +0 -1
- package/dist/chunk-5F26PFZL.mjs +0 -32
- package/dist/chunk-5F26PFZL.mjs.map +0 -1
- package/dist/chunk-5L4VWRFX.mjs +0 -14
- package/dist/chunk-5L4VWRFX.mjs.map +0 -1
- package/dist/chunk-5PMKOZ2F.mjs +0 -13
- package/dist/chunk-5PMKOZ2F.mjs.map +0 -1
- package/dist/chunk-6CLH5YZ2.mjs +0 -16
- package/dist/chunk-6CLH5YZ2.mjs.map +0 -1
- package/dist/chunk-6NVQAHXP.mjs +0 -13
- package/dist/chunk-6NVQAHXP.mjs.map +0 -1
- package/dist/chunk-74CREQXW.mjs +0 -9
- package/dist/chunk-74CREQXW.mjs.map +0 -1
- package/dist/chunk-7B7W36UP.mjs +0 -29
- package/dist/chunk-7B7W36UP.mjs.map +0 -1
- package/dist/chunk-7GXKT3VW.mjs +0 -41
- package/dist/chunk-7GXKT3VW.mjs.map +0 -1
- package/dist/chunk-AIRSKN47.mjs +0 -9
- package/dist/chunk-AIRSKN47.mjs.map +0 -1
- package/dist/chunk-AJKZMN2V.mjs +0 -14
- package/dist/chunk-AJKZMN2V.mjs.map +0 -1
- package/dist/chunk-B4COTK4K.mjs +0 -16
- package/dist/chunk-B4COTK4K.mjs.map +0 -1
- package/dist/chunk-BCTYOXT7.mjs +0 -16
- package/dist/chunk-BCTYOXT7.mjs.map +0 -1
- package/dist/chunk-BGWHVWY4.mjs +0 -13
- package/dist/chunk-BGWHVWY4.mjs.map +0 -1
- package/dist/chunk-BH6HLGBA.mjs +0 -16
- package/dist/chunk-BH6HLGBA.mjs.map +0 -1
- package/dist/chunk-BMRTZMRE.mjs +0 -9
- package/dist/chunk-BMRTZMRE.mjs.map +0 -1
- package/dist/chunk-BOOQBJN2.mjs +0 -9
- package/dist/chunk-BOOQBJN2.mjs.map +0 -1
- package/dist/chunk-CMBC4MXG.mjs +0 -19
- package/dist/chunk-CMBC4MXG.mjs.map +0 -1
- package/dist/chunk-DDH7K4QM.mjs +0 -1
- package/dist/chunk-DDH7K4QM.mjs.map +0 -1
- package/dist/chunk-DLS7UJKJ.mjs +0 -17
- package/dist/chunk-DLS7UJKJ.mjs.map +0 -1
- package/dist/chunk-DN3NOZ3H.mjs +0 -18
- package/dist/chunk-DN3NOZ3H.mjs.map +0 -1
- package/dist/chunk-DPH2KE6O.mjs +0 -24
- package/dist/chunk-DPH2KE6O.mjs.map +0 -1
- package/dist/chunk-DTTKJ3VC.mjs +0 -9
- package/dist/chunk-DTTKJ3VC.mjs.map +0 -1
- package/dist/chunk-DVK2N4KC.mjs +0 -9
- package/dist/chunk-DVK2N4KC.mjs.map +0 -1
- package/dist/chunk-DXB7EZUQ.mjs +0 -12
- package/dist/chunk-DXB7EZUQ.mjs.map +0 -1
- package/dist/chunk-E6C5EZQA.mjs +0 -19
- package/dist/chunk-E6C5EZQA.mjs.map +0 -1
- package/dist/chunk-E6E4RZLN.mjs +0 -17
- package/dist/chunk-E6E4RZLN.mjs.map +0 -1
- package/dist/chunk-EHSKB6DF.mjs +0 -26
- package/dist/chunk-EHSKB6DF.mjs.map +0 -1
- package/dist/chunk-ET33L3MQ.mjs +0 -14
- package/dist/chunk-ET33L3MQ.mjs.map +0 -1
- package/dist/chunk-EZYYB34V.mjs +0 -17
- package/dist/chunk-EZYYB34V.mjs.map +0 -1
- package/dist/chunk-F47GLYUU.mjs +0 -1
- package/dist/chunk-F47GLYUU.mjs.map +0 -1
- package/dist/chunk-FUS75PJ7.mjs +0 -1
- package/dist/chunk-FUS75PJ7.mjs.map +0 -1
- package/dist/chunk-FVVSE2F2.mjs +0 -12
- package/dist/chunk-FVVSE2F2.mjs.map +0 -1
- package/dist/chunk-FZZNWXDM.mjs +0 -9
- package/dist/chunk-FZZNWXDM.mjs.map +0 -1
- package/dist/chunk-G7UQ5PUR.mjs +0 -14
- package/dist/chunk-G7UQ5PUR.mjs.map +0 -1
- package/dist/chunk-GIWAOOFY.mjs +0 -13
- package/dist/chunk-GIWAOOFY.mjs.map +0 -1
- package/dist/chunk-GTFDDKZ2.mjs +0 -15
- package/dist/chunk-GTFDDKZ2.mjs.map +0 -1
- package/dist/chunk-GZGXXIF7.mjs +0 -650
- package/dist/chunk-GZGXXIF7.mjs.map +0 -1
- package/dist/chunk-HPFDYUGP.mjs +0 -13
- package/dist/chunk-HPFDYUGP.mjs.map +0 -1
- package/dist/chunk-IEA53J7P.mjs +0 -12
- package/dist/chunk-IEA53J7P.mjs.map +0 -1
- package/dist/chunk-IFNXROZR.mjs +0 -18
- package/dist/chunk-IFNXROZR.mjs.map +0 -1
- package/dist/chunk-IJD7FE2Z.mjs +0 -18
- package/dist/chunk-IJD7FE2Z.mjs.map +0 -1
- package/dist/chunk-IWXZI3QT.mjs +0 -14
- package/dist/chunk-IWXZI3QT.mjs.map +0 -1
- package/dist/chunk-J5LGTIGS.mjs +0 -10
- package/dist/chunk-J5LGTIGS.mjs.map +0 -1
- package/dist/chunk-JCRY7ZYS.mjs +0 -22
- package/dist/chunk-JCRY7ZYS.mjs.map +0 -1
- package/dist/chunk-JPUKH67K.mjs +0 -10
- package/dist/chunk-JPUKH67K.mjs.map +0 -1
- package/dist/chunk-K5WL54BY.mjs +0 -93
- package/dist/chunk-K5WL54BY.mjs.map +0 -1
- package/dist/chunk-KIOYQRMQ.mjs +0 -12
- package/dist/chunk-KIOYQRMQ.mjs.map +0 -1
- package/dist/chunk-L7FQX5MN.mjs +0 -19
- package/dist/chunk-L7FQX5MN.mjs.map +0 -1
- package/dist/chunk-LJ2C6MVP.mjs +0 -13
- package/dist/chunk-LJ2C6MVP.mjs.map +0 -1
- package/dist/chunk-LKXCOLNY.mjs +0 -8
- package/dist/chunk-LKXCOLNY.mjs.map +0 -1
- package/dist/chunk-LPZZIY5Z.mjs +0 -13
- package/dist/chunk-LPZZIY5Z.mjs.map +0 -1
- package/dist/chunk-LVWX5B43.mjs +0 -12
- package/dist/chunk-LVWX5B43.mjs.map +0 -1
- package/dist/chunk-M7SBBYV2.mjs +0 -14
- package/dist/chunk-M7SBBYV2.mjs.map +0 -1
- package/dist/chunk-ME352XO7.mjs +0 -9
- package/dist/chunk-ME352XO7.mjs.map +0 -1
- package/dist/chunk-MIGAC7F4.mjs +0 -25
- package/dist/chunk-MIGAC7F4.mjs.map +0 -1
- package/dist/chunk-MJ7LNBI6.mjs +0 -17
- package/dist/chunk-MJ7LNBI6.mjs.map +0 -1
- package/dist/chunk-ML727RRJ.mjs +0 -13
- package/dist/chunk-ML727RRJ.mjs.map +0 -1
- package/dist/chunk-MLCL773E.mjs +0 -12
- package/dist/chunk-MLCL773E.mjs.map +0 -1
- package/dist/chunk-MY4G7R3I.mjs +0 -14
- package/dist/chunk-MY4G7R3I.mjs.map +0 -1
- package/dist/chunk-N3QYJX4T.mjs +0 -12
- package/dist/chunk-N3QYJX4T.mjs.map +0 -1
- package/dist/chunk-NFS7RWWE.mjs +0 -16
- package/dist/chunk-NFS7RWWE.mjs.map +0 -1
- package/dist/chunk-NKLIE2OI.mjs +0 -1
- package/dist/chunk-NKLIE2OI.mjs.map +0 -1
- package/dist/chunk-NTLX2MPV.mjs +0 -14
- package/dist/chunk-NTLX2MPV.mjs.map +0 -1
- package/dist/chunk-O6UXZR3U.mjs +0 -10
- package/dist/chunk-O6UXZR3U.mjs.map +0 -1
- package/dist/chunk-OG2RLT5U.mjs +0 -10
- package/dist/chunk-OG2RLT5U.mjs.map +0 -1
- package/dist/chunk-OGZMEWPR.mjs +0 -18
- package/dist/chunk-OGZMEWPR.mjs.map +0 -1
- package/dist/chunk-OLORW442.mjs +0 -18
- package/dist/chunk-OLORW442.mjs.map +0 -1
- package/dist/chunk-OLX53VEF.mjs +0 -16
- package/dist/chunk-OLX53VEF.mjs.map +0 -1
- package/dist/chunk-OOKNBU4V.mjs +0 -18
- package/dist/chunk-OOKNBU4V.mjs.map +0 -1
- package/dist/chunk-OXZCMC5I.mjs +0 -13
- package/dist/chunk-OXZCMC5I.mjs.map +0 -1
- package/dist/chunk-PJPGJ2O6.mjs +0 -15
- package/dist/chunk-PJPGJ2O6.mjs.map +0 -1
- package/dist/chunk-PYEYV7BY.mjs +0 -10
- package/dist/chunk-PYEYV7BY.mjs.map +0 -1
- package/dist/chunk-Q47NGNXT.mjs +0 -21
- package/dist/chunk-Q47NGNXT.mjs.map +0 -1
- package/dist/chunk-QOJGMVVR.mjs +0 -17
- package/dist/chunk-QOJGMVVR.mjs.map +0 -1
- package/dist/chunk-QRSJBBFY.mjs +0 -21
- package/dist/chunk-QRSJBBFY.mjs.map +0 -1
- package/dist/chunk-R6GLTTAB.mjs +0 -9
- package/dist/chunk-R6GLTTAB.mjs.map +0 -1
- package/dist/chunk-R6QA7PLZ.mjs +0 -13
- package/dist/chunk-R6QA7PLZ.mjs.map +0 -1
- package/dist/chunk-RTFTLCF3.mjs +0 -14
- package/dist/chunk-RTFTLCF3.mjs.map +0 -1
- package/dist/chunk-SXFMQQ6F.mjs +0 -9
- package/dist/chunk-SXFMQQ6F.mjs.map +0 -1
- package/dist/chunk-SYWMYQYJ.mjs +0 -16
- package/dist/chunk-SYWMYQYJ.mjs.map +0 -1
- package/dist/chunk-U56ZOM7L.mjs +0 -9
- package/dist/chunk-U56ZOM7L.mjs.map +0 -1
- package/dist/chunk-UY76KTPE.mjs +0 -13
- package/dist/chunk-UY76KTPE.mjs.map +0 -1
- package/dist/chunk-VH2PV426.mjs +0 -9
- package/dist/chunk-VH2PV426.mjs.map +0 -1
- package/dist/chunk-VRUTBJYS.mjs +0 -43
- package/dist/chunk-VRUTBJYS.mjs.map +0 -1
- package/dist/chunk-WMM7TZLG.mjs +0 -9
- package/dist/chunk-WMM7TZLG.mjs.map +0 -1
- package/dist/chunk-XGQWTHW6.mjs +0 -34
- package/dist/chunk-XGQWTHW6.mjs.map +0 -1
- package/dist/chunk-XHSIT5DL.mjs +0 -16
- package/dist/chunk-XHSIT5DL.mjs.map +0 -1
- package/dist/chunk-XI7KRD2C.mjs +0 -13
- package/dist/chunk-XI7KRD2C.mjs.map +0 -1
- package/dist/chunk-XPSOKBRZ.mjs +0 -12
- package/dist/chunk-XPSOKBRZ.mjs.map +0 -1
- package/dist/chunk-XT74R35S.mjs +0 -1
- package/dist/chunk-XT74R35S.mjs.map +0 -1
- package/dist/chunk-YOPFSFTD.mjs +0 -13
- package/dist/chunk-YOPFSFTD.mjs.map +0 -1
- package/dist/chunk-YXAOYIRV.mjs +0 -1
- package/dist/chunk-YXAOYIRV.mjs.map +0 -1
- package/dist/chunk-YXD3AQAK.mjs +0 -1
- package/dist/chunk-YXD3AQAK.mjs.map +0 -1
- package/dist/chunk-Z7HWEOQX.mjs +0 -14
- package/dist/chunk-Z7HWEOQX.mjs.map +0 -1
- package/dist/chunk-ZA2XI3OV.mjs +0 -1
- package/dist/chunk-ZA2XI3OV.mjs.map +0 -1
- package/dist/chunk-ZPNX2QDE.mjs +0 -13
- package/dist/chunk-ZPNX2QDE.mjs.map +0 -1
- package/dist/error/AbortError.js +0 -36
- package/dist/error/AbortError.js.map +0 -1
- package/dist/error/TimeoutError.js +0 -36
- package/dist/error/TimeoutError.js.map +0 -1
- package/dist/error/index.d.mts +0 -2
- package/dist/error/index.d.ts +0 -2
- package/dist/error/index.js +0 -48
- package/dist/error/index.js.map +0 -1
- package/dist/error/index.mjs +0 -13
- package/dist/error/index.mjs.map +0 -1
- package/dist/function/after.js +0 -42
- package/dist/function/after.js.map +0 -1
- package/dist/function/debounce.js +0 -56
- package/dist/function/debounce.js.map +0 -1
- package/dist/function/negate.js +0 -33
- package/dist/function/negate.js.map +0 -1
- package/dist/function/noop.js +0 -32
- package/dist/function/noop.js.map +0 -1
- package/dist/function/once.js +0 -43
- package/dist/function/once.js.map +0 -1
- package/dist/function/throttle.js +0 -41
- package/dist/function/throttle.js.map +0 -1
- package/dist/math/clamp.js +0 -36
- package/dist/math/clamp.js.map +0 -1
- package/dist/math/inRange.js +0 -40
- package/dist/math/inRange.js.map +0 -1
- package/dist/math/mean.js +0 -44
- package/dist/math/mean.js.map +0 -1
- package/dist/math/meanBy.js +0 -50
- package/dist/math/meanBy.js.map +0 -1
- package/dist/math/random.js +0 -40
- package/dist/math/random.js.map +0 -1
- package/dist/math/randomInt.js +0 -47
- package/dist/math/randomInt.js.map +0 -1
- package/dist/math/range.js +0 -48
- package/dist/math/range.js.map +0 -1
- package/dist/math/round.js +0 -37
- package/dist/math/round.js.map +0 -1
- package/dist/math/sum.js +0 -37
- package/dist/math/sum.js.map +0 -1
- package/dist/math/sumBy.js +0 -45
- package/dist/math/sumBy.js.map +0 -1
- package/dist/object/clone.js +0 -67
- package/dist/object/clone.js.map +0 -1
- package/dist/object/cloneDeep.js +0 -117
- package/dist/object/cloneDeep.js.map +0 -1
- package/dist/object/flattenObject.js +0 -77
- package/dist/object/flattenObject.js.map +0 -1
- package/dist/object/invert.js +0 -40
- package/dist/object/invert.js.map +0 -1
- package/dist/object/omit.js +0 -37
- package/dist/object/omit.js.map +0 -1
- package/dist/object/omitBy.js +0 -40
- package/dist/object/omitBy.js.map +0 -1
- package/dist/object/pick.js +0 -37
- package/dist/object/pick.js.map +0 -1
- package/dist/object/pickBy.js +0 -40
- package/dist/object/pickBy.js.map +0 -1
- package/dist/predicate/isArrayLike.js +0 -40
- package/dist/predicate/isArrayLike.js.map +0 -1
- package/dist/predicate/isEqual.js +0 -73
- package/dist/predicate/isEqual.js.map +0 -1
- package/dist/predicate/isFunction.js +0 -33
- package/dist/predicate/isFunction.js.map +0 -1
- package/dist/predicate/isLength.js +0 -33
- package/dist/predicate/isLength.js.map +0 -1
- package/dist/predicate/isNil.js +0 -33
- package/dist/predicate/isNil.js.map +0 -1
- package/dist/predicate/isNotNil.js +0 -33
- package/dist/predicate/isNotNil.js.map +0 -1
- package/dist/predicate/isNull.js +0 -33
- package/dist/predicate/isNull.js.map +0 -1
- package/dist/predicate/isPlainObject.js +0 -49
- package/dist/predicate/isPlainObject.js.map +0 -1
- package/dist/predicate/isPrimitive.js +0 -33
- package/dist/predicate/isPrimitive.js.map +0 -1
- package/dist/predicate/isTypedArray.js +0 -33
- package/dist/predicate/isTypedArray.js.map +0 -1
- package/dist/predicate/isUndefined.js +0 -33
- package/dist/predicate/isUndefined.js.map +0 -1
- package/dist/promise/delay.js +0 -56
- package/dist/promise/delay.js.map +0 -1
- package/dist/promise/timeout.d.mts +0 -10
- package/dist/promise/timeout.d.ts +0 -10
- package/dist/promise/timeout.js +0 -70
- package/dist/promise/timeout.js.map +0 -1
- package/dist/promise/withTimeout.js +0 -75
- package/dist/promise/withTimeout.js.map +0 -1
- package/dist/string/camelCase.js +0 -51
- package/dist/string/camelCase.js.map +0 -1
- package/dist/string/capitalize.js +0 -33
- package/dist/string/capitalize.js.map +0 -1
- package/dist/string/kebabCase.js +0 -42
- package/dist/string/kebabCase.js.map +0 -1
- package/dist/string/lowerCase.js +0 -42
- package/dist/string/lowerCase.js.map +0 -1
- package/dist/string/snakeCase.js +0 -42
- package/dist/string/snakeCase.js.map +0 -1
- package/dist/string/startCase.js +0 -53
- package/dist/string/startCase.js.map +0 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
class AbortError extends Error {
|
|
4
|
+
constructor(message = 'The operation was aborted') {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = 'AbortError';
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
class TimeoutError extends Error {
|
|
11
|
+
constructor(message = 'The operation was timed out') {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = 'TimeoutError';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function delay(ms, { signal } = {}) {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
const abortError = () => {
|
|
20
|
+
reject(new AbortError());
|
|
21
|
+
};
|
|
22
|
+
const abortHandler = () => {
|
|
23
|
+
clearTimeout(timeoutId);
|
|
24
|
+
abortError();
|
|
25
|
+
};
|
|
26
|
+
if (signal?.aborted) {
|
|
27
|
+
return abortError();
|
|
28
|
+
}
|
|
29
|
+
const timeoutId = setTimeout(resolve, ms);
|
|
30
|
+
signal?.addEventListener('abort', abortHandler, { once: true });
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function timeout(ms) {
|
|
35
|
+
await delay(ms);
|
|
36
|
+
throw new TimeoutError();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function withTimeout(run, ms) {
|
|
40
|
+
return Promise.race([run(), timeout(ms)]);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
exports.AbortError = AbortError;
|
|
44
|
+
exports.TimeoutError = TimeoutError;
|
|
45
|
+
exports.delay = delay;
|
|
46
|
+
exports.withTimeout = withTimeout;
|
|
47
|
+
//# sourceMappingURL=index-CwRt_M.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CwRt_M.js","sources":["../../src/error/AbortError.ts","../../src/error/TimeoutError.ts","../../src/promise/delay.ts","../../src/promise/timeout.ts","../../src/promise/withTimeout.ts"],"sourcesContent":["/**\n * An error class representing an aborted operation.\n * @augments Error\n */\nexport class AbortError extends Error {\n constructor(message = 'The operation was aborted') {\n super(message);\n this.name = 'AbortError';\n }\n}\n","/**\n * An error class representing an timeout operation.\n * @augments Error\n */\nexport class TimeoutError extends Error {\n constructor(message = 'The operation was timed out') {\n super(message);\n this.name = 'TimeoutError';\n }\n}\n","import { AbortError } from '../error/AbortError.ts';\n\ninterface DelayOptions {\n signal?: AbortSignal;\n}\n\n/**\n * Delays the execution of code for a specified number of milliseconds.\n *\n * This function returns a Promise that resolves after the specified delay, allowing you to use it\n * with async/await to pause execution.\n *\n * @param {number} ms - The number of milliseconds to delay.\n * @param {DelayOptions} options - The options object.\n * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the delay.\n * @returns {Promise<void>} A Promise that resolves after the specified delay.\n *\n * @example\n * async function foo() {\n * console.log('Start');\n * await delay(1000); // Delays execution for 1 second\n * console.log('End');\n * }\n *\n * foo();\n *\n * // With AbortSignal\n * const controller = new AbortController();\n * const { signal } = controller;\n *\n * setTimeout(() => controller.abort(), 50); // Will cancel the delay after 50ms\n * try {\n * await delay(100, { signal });\n * } catch (error) {\n * console.error(error); // Will log 'AbortError'\n * }\n * }\n */\nexport function delay(ms: number, { signal }: DelayOptions = {}): Promise<void> {\n return new Promise((resolve, reject) => {\n const abortError = () => {\n reject(new AbortError());\n };\n\n const abortHandler = () => {\n clearTimeout(timeoutId);\n abortError();\n };\n\n if (signal?.aborted) {\n return abortError();\n }\n\n const timeoutId = setTimeout(resolve, ms);\n\n signal?.addEventListener('abort', abortHandler, { once: true });\n });\n}\n","import { delay } from './delay.ts';\nimport { TimeoutError } from '../error/TimeoutError.ts';\n\n/**\n * Returns a promise that rejects with a `TimeoutError` after a specified delay.\n *\n * @param {number} ms - The delay duration in milliseconds.\n * @returns {Promise<void>} A promise that rejects with a `TimeoutError` after the specified delay.\n * @throws {TimeoutError} Throws a `TimeoutError` after the specified delay.\n */\nexport async function timeout(ms: number): Promise<never> {\n await delay(ms);\n throw new TimeoutError();\n}\n","import { timeout } from './timeout.ts';\n\n/**\n * Executes an async function and enforces a timeout. \n * \n * If the promise does not resolve within the specified time,\n * the timeout will trigger and the returned promise will be rejected.\n *\n *\n * @template T \n * @param {() => Promise<T>} run - A function that returns a promise to be executed.\n * @param {number} ms - The timeout duration in milliseconds.\n * @returns {Promise<T>} A promise that resolves with the result of the `run` function or rejects if the timeout is reached.\n *\n * @example\n * try {\n * await withTimeout(() => {}, 1000); // Timeout exception after 1 second\n * } catch (error) {\n * console.error(error); // Will log 'TimeoutError'\n * }\n */\nexport async function withTimeout<T>(run: () => Promise<T>, ms: number): Promise<T> {\n return Promise.race([run(), timeout(ms) as T]);\n}\n"],"names":[],"mappings":";;AAIM,MAAO,UAAW,SAAQ,KAAK,CAAA;IACnC,WAAY,CAAA,OAAO,GAAG,2BAA2B,EAAA;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC;AACf,QAAA,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;KAC1B;AACF;;ACLK,MAAO,YAAa,SAAQ,KAAK,CAAA;IACrC,WAAY,CAAA,OAAO,GAAG,6BAA6B,EAAA;QACjD,KAAK,CAAC,OAAO,CAAC,CAAC;AACf,QAAA,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;KAC5B;AACF;;AC6BK,SAAU,KAAK,CAAC,EAAU,EAAE,EAAE,MAAM,KAAmB,EAAE,EAAA;IAC7D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAI;QACrC,MAAM,UAAU,GAAG,MAAK;AACtB,YAAA,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC;AAC3B,SAAC,CAAC;QAEF,MAAM,YAAY,GAAG,MAAK;YACxB,YAAY,CAAC,SAAS,CAAC,CAAC;AACxB,YAAA,UAAU,EAAE,CAAC;AACf,SAAC,CAAC;AAEF,QAAA,IAAI,MAAM,EAAE,OAAO,EAAE;YACnB,OAAO,UAAU,EAAE,CAAC;SACrB;QAED,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAE1C,QAAA,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAClE,KAAC,CAAC,CAAC;AACL;;AC/CO,eAAe,OAAO,CAAC,EAAU,EAAA;AACtC,IAAA,MAAM,KAAK,CAAC,EAAE,CAAC,CAAC;IAChB,MAAM,IAAI,YAAY,EAAE,CAAC;AAC3B;;ACQO,eAAe,WAAW,CAAI,GAAqB,EAAE,EAAU,EAAA;AACpE,IAAA,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,EAAE,CAAM,CAAC,CAAC,CAAC;AACjD;;;;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function isPlainObject(object) {
|
|
4
|
+
if (typeof object !== 'object') {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
if (object == null) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
if (Object.getPrototypeOf(object) === null) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
if (object.toString() !== '[object Object]') {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
let proto = object;
|
|
17
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
18
|
+
proto = Object.getPrototypeOf(proto);
|
|
19
|
+
}
|
|
20
|
+
return Object.getPrototypeOf(object) === proto;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.isPlainObject = isPlainObject;
|
|
24
|
+
//# sourceMappingURL=isPlainObject-bK22pA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPlainObject-bK22pA.js","sources":["../../src/predicate/isPlainObject.ts"],"sourcesContent":["/**\n * Checks if a given value is a plain object.\n * \n * @param {object} object - The value to check.\n * @returns {boolean} - True if the value is a plain object, otherwise false.\n * \n * @example\n * console.log(isPlainObject({})); // true\n * console.log(isPlainObject([])); // false\n * console.log(isPlainObject(null)); // false\n * console.log(isPlainObject(Object.create(null))); // true\n * console.log(Buffer.from('hello, world')); // false\n */\nexport function isPlainObject(object: object): boolean {\n if (typeof object !== 'object') {\n return false;\n }\n\n if (object == null) {\n return false;\n }\n\n if (Object.getPrototypeOf(object) === null) {\n return true;\n }\n\n if (object.toString() !== '[object Object]') {\n return false;\n }\n\n let proto = object;\n\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n\n return Object.getPrototypeOf(object) === proto;\n}"],"names":[],"mappings":";;AAaM,SAAU,aAAa,CAAC,MAAc,EAAA;AAC1C,IAAA,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;AAC9B,QAAA,OAAO,KAAK,CAAC;KACd;AAED,IAAA,IAAI,MAAM,IAAI,IAAI,EAAE;AAClB,QAAA,OAAO,KAAK,CAAC;KACd;IAED,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;AAC1C,QAAA,OAAO,IAAI,CAAC;KACb;AAED,IAAA,IAAI,MAAM,CAAC,QAAQ,EAAE,KAAK,iBAAiB,EAAE;AAC3C,QAAA,OAAO,KAAK,CAAC;KACd;IAED,IAAI,KAAK,GAAG,MAAM,CAAC;IAEnB,OAAO,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;AAC5C,QAAA,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;KACtC;IAED,OAAO,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,KAAK,CAAC;AACjD;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function random(minimum, maximum) {
|
|
4
|
+
if (maximum == null) {
|
|
5
|
+
maximum = minimum;
|
|
6
|
+
minimum = 0;
|
|
7
|
+
}
|
|
8
|
+
if (minimum >= maximum) {
|
|
9
|
+
throw new Error('Invalid input: The maximum value must be greater than the minimum value.');
|
|
10
|
+
}
|
|
11
|
+
return Math.random() * (maximum - minimum) + minimum;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function randomInt(minimum, maximum) {
|
|
15
|
+
return Math.floor(random(minimum, maximum));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
exports.random = random;
|
|
19
|
+
exports.randomInt = randomInt;
|
|
20
|
+
//# sourceMappingURL=randomInt-CF7bZK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"randomInt-CF7bZK.js","sources":["../../src/math/random.ts","../../src/math/randomInt.ts"],"sourcesContent":["/**\n * Generate a random number within the given range.\n *\n * If only one argument is provided, a number between `0` and the given number is returned.\n *\n * @param {number} minimum - The lower bound (inclusive).\n * @param {number} maximum - The upper bound (exclusive).\n * @returns {number} A random number between minimum (inclusive) and maximum (exclusive). The number can be an integer or a decimal.\n * @throws {Error} Throws an error if `maximum` is not greater than `minimum`.\n *\n * @example\n * const result1 = random(0, 5); // Returns a random number between 0 and 5.\n * const result2 = random(5, 0); // If the minimum is greater than the maximum, an error is thrown\n * const result3 = random(5, 5); // If the minimum is equal to the maximum, an error is thrown.\n */\nexport function random(maximum: number): number;\nexport function random(minimum: number, maximum: number): number;\nexport function random(minimum: number, maximum?: number): number {\n if (maximum == null) {\n maximum = minimum;\n minimum = 0;\n }\n\n if (minimum >= maximum) {\n throw new Error('Invalid input: The maximum value must be greater than the minimum value.');\n }\n\n return Math.random() * (maximum - minimum) + minimum;\n}\n","import { random } from './random.ts';\n\n/**\n * Generates a random integer between minimum (inclusive) and maximum (exclusive).\n *\n * If only one argument is provided, a number between `0` and the given number is returned.\n *\n * @param {number} minimum - The lower bound (inclusive).\n * @param {number} maximum - The upper bound (exclusive).\n * @returns {number} A random integer between minimum (inclusive) and maximum (exclusive).\n * @throws {Error} Throws an error if `maximum` is not greater than `minimum`.\n *\n * @example\n * const result = randomInt(0, 5); // result will be a random integer between 0 (inclusive) and 5 (exclusive)\n * const result2 = randomInt(5, 0); // This will throw an error\n */\nexport function randomInt(maximum: number): number;\nexport function randomInt(minimum: number, maximum: number): number;\nexport function randomInt(minimum: number, maximum?: number): number {\n return Math.floor(random(minimum, maximum!));\n}\n"],"names":[],"mappings":";;AAiBgB,SAAA,MAAM,CAAC,OAAe,EAAE,OAAgB,EAAA;AACtD,IAAA,IAAI,OAAO,IAAI,IAAI,EAAE;QACnB,OAAO,GAAG,OAAO,CAAC;QAClB,OAAO,GAAG,CAAC,CAAC;KACb;AAED,IAAA,IAAI,OAAO,IAAI,OAAO,EAAE;AACtB,QAAA,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC;KAC7F;AAED,IAAA,OAAO,IAAI,CAAC,MAAM,EAAE,IAAI,OAAO,GAAG,OAAO,CAAC,GAAG,OAAO,CAAC;AACvD;;ACVgB,SAAA,SAAS,CAAC,OAAe,EAAE,OAAgB,EAAA;IACzD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAQ,CAAC,CAAC,CAAC;AAC/C;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"union-CdQeDK.js","sources":["../../src/array/uniq.ts","../../src/array/union.ts"],"sourcesContent":["/**\n * Creates a duplicate-free version of an array.\n *\n * This function takes an array and returns a new array containing only the unique values\n * from the original array, preserving the order of first occurrence.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to process.\n * @returns {T[]} A new array with only unique values from the original array.\n *\n * @example\n * const array = [1, 2, 2, 3, 4, 4, 5];\n * const result = uniq(array);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function uniq<T>(arr: readonly T[]): T[] {\n return Array.from(new Set(arr));\n}\n","import { uniq } from './uniq.ts';\n\n/**\n * Creates an array of unique values from all given arrays.\n *\n * This function takes two arrays, merges them into a single array, and returns a new array\n * containing only the unique values from the merged array.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr1 - The first array to merge and filter for unique values.\n * @param {T[]} arr2 - The second array to merge and filter for unique values.\n * @returns {T[]} A new array of unique values.\n *\n * @example\n * const array1 = [1, 2, 3];\n * const array2 = [3, 4, 5];\n * const result = union(array1, array2);\n * // result will be [1, 2, 3, 4, 5]\n */\nexport function union<T>(arr1: readonly T[], arr2: readonly T[]): T[] {\n return uniq(arr1.concat(arr2));\n}\n"],"names":[],"mappings":";;AAeM,SAAU,IAAI,CAAI,GAAiB,EAAA;IACvC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAClC;;ACEgB,SAAA,KAAK,CAAI,IAAkB,EAAE,IAAkB,EAAA;IAC7D,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACjC;;;;;"}
|
package/dist/array/chunk.mjs
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
function chunk(arr, size) {
|
|
2
|
+
if (!Number.isInteger(size) || size <= 0) {
|
|
3
|
+
throw new Error('Size must be an integer greater than zero.');
|
|
4
|
+
}
|
|
5
|
+
const chunkLength = Math.ceil(arr.length / size);
|
|
6
|
+
const result = Array(chunkLength);
|
|
7
|
+
for (let index = 0; index < chunkLength; index++) {
|
|
8
|
+
const start = index * size;
|
|
9
|
+
const end = start + size;
|
|
10
|
+
result[index] = arr.slice(start, end);
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { chunk };
|
|
16
|
+
//# sourceMappingURL=chunk.mjs.map
|
package/dist/array/chunk.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],
|
|
1
|
+
{"version":3,"file":"chunk.mjs","sources":["../../src/array/chunk.ts"],"sourcesContent":["/**\n * Splits an array into smaller arrays of a specified length.\n *\n * This function takes an input array and divides it into multiple smaller arrays,\n * each of a specified length. If the input array cannot be evenly divided,\n * the final sub-array will contain the remaining elements.\n *\n * @template T The type of elements in the array.\n * @param {T[]} arr - The array to be chunked into smaller arrays.\n * @param {number} size - The size of each smaller array. Must be a positive integer.\n * @returns {T[][]} A two-dimensional array where each sub-array has a maximum length of `size`.\n * @throws {Error} Throws an error if `size` is not a positive integer.\n *\n * @example\n * // Splits an array of numbers into sub-arrays of length 2\n * chunk([1, 2, 3, 4, 5], 2);\n * // Returns: [[1, 2], [3, 4], [5]]\n *\n * @example\n * // Splits an array of strings into sub-arrays of length 3\n * chunk(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 3);\n * // Returns: [['a', 'b', 'c'], ['d', 'e', 'f'], ['g']]\n */\nexport function chunk<T>(arr: readonly T[], size: number): T[][] {\n if (!Number.isInteger(size) || size <= 0) {\n throw new Error('Size must be an integer greater than zero.');\n }\n\n const chunkLength = Math.ceil(arr.length / size);\n const result: T[][] = Array(chunkLength);\n\n for (let index = 0; index < chunkLength; index++) {\n const start = index * size;\n const end = start + size;\n\n result[index] = arr.slice(start, end);\n }\n\n return result;\n}\n"],"names":[],"mappings":"AAuBgB,SAAA,KAAK,CAAI,GAAiB,EAAE,IAAY,EAAA;AACtD,IAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE;AACxC,QAAA,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;KAC/D;AAED,IAAA,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AACjD,IAAA,MAAM,MAAM,GAAU,KAAK,CAAC,WAAW,CAAC,CAAC;AAEzC,IAAA,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,WAAW,EAAE,KAAK,EAAE,EAAE;AAChD,QAAA,MAAM,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC;AAC3B,QAAA,MAAM,GAAG,GAAG,KAAK,GAAG,IAAI,CAAC;AAEzB,QAAA,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;KACvC;AAED,IAAA,OAAO,MAAM,CAAC;AAChB;;;;"}
|
package/dist/array/compact.mjs
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
1
|
+
function compact(arr) {
|
|
2
|
+
const result = [];
|
|
3
|
+
for (const item of arr) {
|
|
4
|
+
if (item) {
|
|
5
|
+
result.push(item);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { compact };
|
|
12
|
+
//# sourceMappingURL=compact.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],
|
|
1
|
+
{"version":3,"file":"compact.mjs","sources":["../../src/array/compact.ts"],"sourcesContent":["type NotFalsey<T> = Exclude<T, false | null | 0 | '' | undefined>;\n\n/**\n * Removes falsey values (false, null, 0, '', undefined, NaN) from an array.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The input array to remove falsey values.\n * @returns {Array<Exclude<T, false | null | 0 | '' | undefined>>} - A new array with all falsey values removed.\n *\n * @example\n * compact([0, 1, false, 2, '', 3, null, undefined, 4, NaN, 5]);\n * Returns: [1, 2, 3, 4, 5]\n */\nexport function compact<T>(arr: readonly T[]): Array<NotFalsey<T>> {\n const result: Array<NotFalsey<T>> = [];\n\n for (const item of arr) {\n if (item) {\n result.push(item as NotFalsey<T>);\n }\n }\n\n return result;\n}\n"],"names":[],"mappings":"AAaM,SAAU,OAAO,CAAI,GAAiB,EAAA;IAC1C,MAAM,MAAM,GAAwB,EAAE,CAAC;AAEvC,IAAA,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE;QACtB,IAAI,IAAI,EAAE;AACR,YAAA,MAAM,CAAC,IAAI,CAAC,IAAoB,CAAC,CAAC;SACnC;KACF;AAED,IAAA,OAAO,MAAM,CAAC;AAChB;;;;"}
|
package/dist/array/countBy.mjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
function countBy(arr, mapper) {
|
|
2
|
+
const result = {};
|
|
3
|
+
for (const item of arr) {
|
|
4
|
+
const key = mapper(item);
|
|
5
|
+
result[key] = (result[key] ?? 0) + 1;
|
|
6
|
+
}
|
|
7
|
+
return result;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { countBy };
|
|
11
|
+
//# sourceMappingURL=countBy.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],
|
|
1
|
+
{"version":3,"file":"countBy.mjs","sources":["../../src/array/countBy.ts"],"sourcesContent":["/**\n * Count the occurrences of each item in an array\n * based on a transformation function.\n *\n * This function takes an array and a transformation function\n * that converts each item in the array to a string. It then\n * counts the occurrences of each transformed item and returns\n * an object with the transformed items as keys and the counts\n * as values.\n *\n * @template T - The type of the items in the input array.\n *\n * @param {T[]} arr - The input array to count occurrences.\n * @param {(item: T) => string} mapper - The transformation function that maps each item to a string key.\n * @returns {Record<string, number>} An object containing the transformed items as keys and the\n * counts as values.\n */\nexport function countBy<T>(arr: T[], mapper: (item: T) => string): Record<string, number> {\n const result: Record<string, number> = {};\n \n for (const item of arr) {\n const key = mapper(item);\n \n result[key] = (result[key] ?? 0) + 1;\n }\n \n return result;\n}\n"],"names":[],"mappings":"AAiBgB,SAAA,OAAO,CAAI,GAAQ,EAAE,MAA2B,EAAA;IAC9D,MAAM,MAAM,GAA2B,EAAE,CAAC;AAE1C,IAAA,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE;AACtB,QAAA,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;AAEzB,QAAA,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACtC;AAED,IAAA,OAAO,MAAM,CAAC;AAChB;;;;"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
//# sourceMappingURL=difference.mjs.map
|
|
1
|
+
function difference(firstArr, secondArr) {
|
|
2
|
+
const secondSet = new Set(secondArr);
|
|
3
|
+
return firstArr.filter(item => !secondSet.has(item));
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export { difference };
|
|
7
|
+
//# sourceMappingURL=difference.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],
|
|
1
|
+
{"version":3,"file":"difference.mjs","sources":["../../src/array/difference.ts"],"sourcesContent":["/**\n * Computes the difference between two arrays.\n *\n * This function takes two arrays and returns a new array containing the elements\n * that are present in the first array but not in the second array. It effectively\n * filters out any elements from the first array that also appear in the second array.\n *\n * @template T\n * @param {T[]} firstArr - The array from which to derive the difference. This is the primary array\n * from which elements will be compared and filtered.\n * @param {T[]} secondArr - The array containing elements to be excluded from the first array.\n * Each element in this array will be checked against the first array, and if a match is found,\n * that element will be excluded from the result.\n * @returns {T[]} A new array containing the elements that are present in the first array but not\n * in the second array.\n *\n * @example\n * const array1 = [1, 2, 3, 4, 5];\n * const array2 = [2, 4];\n * const result = difference(array1, array2);\n * // result will be [1, 3, 5] since 2 and 4 are in both arrays and are excluded from the result.\n */\nexport function difference<T>(firstArr: readonly T[], secondArr: readonly T[]): T[] {\n const secondSet = new Set(secondArr);\n\n return firstArr.filter(item => !secondSet.has(item));\n}\n"],"names":[],"mappings":"AAsBgB,SAAA,UAAU,CAAI,QAAsB,EAAE,SAAuB,EAAA;AAC3E,IAAA,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;AAErC,IAAA,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AACvD;;;;"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
function differenceBy(firstArr, secondArr, mapper) {
|
|
2
|
+
const mappedSecondSet = new Set(secondArr.map(item => mapper(item)));
|
|
3
|
+
return firstArr.filter(item => {
|
|
4
|
+
return !mappedSecondSet.has(mapper(item));
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { differenceBy };
|
|
9
|
+
//# sourceMappingURL=differenceBy.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],
|
|
1
|
+
{"version":3,"file":"differenceBy.mjs","sources":["../../src/array/differenceBy.ts"],"sourcesContent":["/**\n * Computes the difference between two arrays after mapping their elements through a provided function.\n *\n * This function takes two arrays and a mapper function. It returns a new array containing the elements\n * that are present in the first array but not in the second array, based on the identity calculated\n * by the mapper function.\n *\n * Essentially, it filters out any elements from the first array that, when\n * mapped, match an element in the mapped version of the second array.\n *\n * @template T, U\n * @param {T[]} firstArr - The primary array from which to derive the difference.\n * @param {T[]} secondArr - The array containing elements to be excluded from the first array.\n * @param {(value: T) => U} mapper - The function to map the elements of both arrays. This function\n * is applied to each element in both arrays, and the comparison is made based on the mapped values.\n * @returns {T[]} A new array containing the elements from the first array that do not have a corresponding\n * mapped identity in the second array.\n *\n * @example\n * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];\n * const array2 = [{ id: 2 }, { id: 4 }];\n * const mapper = item => item.id;\n * const result = differenceBy(array1, array2, mapper);\n * // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are in both arrays and are excluded from the result.\n */\nexport function differenceBy<T, U>(firstArr: readonly T[], secondArr: readonly T[], mapper: (value: T) => U): T[] {\n const mappedSecondSet = new Set(secondArr.map(item => mapper(item)));\n\n return firstArr.filter(item => {\n return !mappedSecondSet.has(mapper(item));\n });\n}\n"],"names":[],"mappings":"SAyBgB,YAAY,CAAO,QAAsB,EAAE,SAAuB,EAAE,MAAuB,EAAA;AACzG,IAAA,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAErE,IAAA,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAG;QAC5B,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC5C,KAAC,CAAC,CAAC;AACL;;;;"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
1
|
+
function differenceWith(firstArr, secondArr, areItemsEqual) {
|
|
2
|
+
return firstArr.filter(firstItem => {
|
|
3
|
+
return secondArr.every(secondItem => {
|
|
4
|
+
return !areItemsEqual(firstItem, secondItem);
|
|
5
|
+
});
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { differenceWith };
|
|
10
|
+
//# sourceMappingURL=differenceWith.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],
|
|
1
|
+
{"version":3,"file":"differenceWith.mjs","sources":["../../src/array/differenceWith.ts"],"sourcesContent":["/**\n * Computes the difference between two arrays based on a custom equality function.\n *\n * This function takes two arrays and a custom comparison function. It returns a new array containing\n * the elements that are present in the first array but not in the second array. The comparison to determine\n * if elements are equal is made using the provided custom function.\n *\n * @template T\n * @param {T[]} firstArr - The array from which to get the difference.\n * @param {T[]} secondArr - The array containing elements to exclude from the first array.\n * @param {(x: T, y: T) => boolean} areItemsEqual - A function to determine if two items are equal.\n * @returns {T[]} A new array containing the elements from the first array that do not match any elements in the second array\n * according to the custom equality function.\n *\n * @example\n * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];\n * const array2 = [{ id: 2 }, { id: 4 }];\n * const areItemsEqual = (a, b) => a.id === b.id;\n * const result = differenceWith(array1, array2, areItemsEqual);\n * // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are considered equal and are excluded from the result.\n */\nexport function differenceWith<T>(\n firstArr: readonly T[],\n secondArr: readonly T[],\n areItemsEqual: (x: T, y: T) => boolean\n): T[] {\n return firstArr.filter(firstItem => {\n return secondArr.every(secondItem => {\n return !areItemsEqual(firstItem, secondItem);\n });\n });\n}\n"],"names":[],"mappings":"SAqBgB,cAAc,CAC5B,QAAsB,EACtB,SAAuB,EACvB,aAAsC,EAAA;AAEtC,IAAA,OAAO,QAAQ,CAAC,MAAM,CAAC,SAAS,IAAG;AACjC,QAAA,OAAO,SAAS,CAAC,KAAK,CAAC,UAAU,IAAG;AAClC,YAAA,OAAO,CAAC,aAAa,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAC/C,SAAC,CAAC,CAAC;AACL,KAAC,CAAC,CAAC;AACL;;;;"}
|
package/dist/array/drop.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
//# sourceMappingURL=drop.mjs.map
|
|
1
|
+
function drop(arr, itemsCount) {
|
|
2
|
+
itemsCount = Math.max(itemsCount, 0);
|
|
3
|
+
return arr.slice(itemsCount);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export { drop };
|
|
7
|
+
//# sourceMappingURL=drop.mjs.map
|
package/dist/array/drop.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],
|
|
1
|
+
{"version":3,"file":"drop.mjs","sources":["../../src/array/drop.ts"],"sourcesContent":["/**\n * Removes a specified number of elements from the beginning of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the start.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the beginning of the array.\n * @returns {T[]} A new array with the specified number of elements removed from the start.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = drop(array, 2);\n * // result will be [3, 4, 5] since the first two elements are dropped.\n */\nexport function drop<T>(arr: readonly T[], itemsCount: number): T[] {\n itemsCount = Math.max(itemsCount, 0);\n\n return arr.slice(itemsCount);\n}\n"],"names":[],"mappings":"AAgBgB,SAAA,IAAI,CAAI,GAAiB,EAAE,UAAkB,EAAA;IAC3D,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;AAErC,IAAA,OAAO,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AAC/B;;;;"}
|
package/dist/array/dropRight.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
1
|
+
function dropRight(arr, itemsCount) {
|
|
2
|
+
itemsCount = Math.min(-itemsCount, 0);
|
|
3
|
+
if (itemsCount === 0) {
|
|
4
|
+
return arr.slice();
|
|
5
|
+
}
|
|
6
|
+
return arr.slice(0, itemsCount);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { dropRight };
|
|
10
|
+
//# sourceMappingURL=dropRight.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],
|
|
1
|
+
{"version":3,"file":"dropRight.mjs","sources":["../../src/array/dropRight.ts"],"sourcesContent":["/**\n * Removes a specified number of elements from the end of an array and returns the rest.\n *\n * This function takes an array and a number, and returns a new array with the specified number\n * of elements removed from the end.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {number} itemsCount - The number of elements to drop from the end of the array.\n * @returns {T[]} A new array with the specified number of elements removed from the end.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropRight(array, 2);\n * // result will be [1, 2, 3] since the last two elements are dropped.\n */\nexport function dropRight<T>(arr: readonly T[], itemsCount: number): T[] {\n itemsCount = Math.min(-itemsCount, 0);\n\n if (itemsCount === 0) {\n return arr.slice();\n }\n\n return arr.slice(0, itemsCount);\n}\n"],"names":[],"mappings":"AAgBgB,SAAA,SAAS,CAAI,GAAiB,EAAE,UAAkB,EAAA;IAChE,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;AAEtC,IAAA,IAAI,UAAU,KAAK,CAAC,EAAE;AACpB,QAAA,OAAO,GAAG,CAAC,KAAK,EAAE,CAAC;KACpB;IAED,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AAClC;;;;"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
function dropRightWhile(arr, canContinueDropping) {
|
|
2
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
3
|
+
if (!canContinueDropping(arr[i])) {
|
|
4
|
+
return arr.slice(0, i + 1);
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { dropRightWhile };
|
|
11
|
+
//# sourceMappingURL=dropRightWhile.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],
|
|
1
|
+
{"version":3,"file":"dropRightWhile.mjs","sources":["../../src/array/dropRightWhile.ts"],"sourcesContent":["/**\n * Removes elements from the end of an array until the predicate returns false.\n *\n * This function iterates over an array from the end and drops elements until the provided\n * predicate function returns false. It then returns a new array with the remaining elements.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {(item: T) => boolean} canContinueDropping - A predicate function that determines\n * whether to continue dropping elements. The function is called with each element from the end,\n * and dropping continues as long as it returns true.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropRightWhile(array, x => x > 3);\n * // result will be [1, 2, 3] since elements greater than 3 are dropped from the end.\n */\nexport function dropRightWhile<T>(arr: readonly T[], canContinueDropping: (item: T) => boolean): T[] {\n for (let i = arr.length - 1; i >= 0; i--) {\n if (!canContinueDropping(arr[i])) {\n return arr.slice(0, i + 1);\n }\n }\n\n return [];\n}\n"],"names":[],"mappings":"AAkBgB,SAAA,cAAc,CAAI,GAAiB,EAAE,mBAAyC,EAAA;AAC5F,IAAA,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QACxC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;YAChC,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;SAC5B;KACF;AAED,IAAA,OAAO,EAAE,CAAC;AACZ;;;;"}
|
package/dist/array/dropWhile.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
1
|
+
function dropWhile(arr, canContinueDropping) {
|
|
2
|
+
const dropEndIndex = arr.findIndex(item => !canContinueDropping(item));
|
|
3
|
+
if (dropEndIndex === -1) {
|
|
4
|
+
return [];
|
|
5
|
+
}
|
|
6
|
+
return arr.slice(dropEndIndex);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { dropWhile };
|
|
10
|
+
//# sourceMappingURL=dropWhile.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],
|
|
1
|
+
{"version":3,"file":"dropWhile.mjs","sources":["../../src/array/dropWhile.ts"],"sourcesContent":["/**\n * Removes elements from the beginning of an array until the predicate returns false.\n *\n * This function iterates over an array and drops elements from the start until the provided\n * predicate function returns false. It then returns a new array with the remaining elements.\n *\n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array from which to drop elements.\n * @param {(item: T) => boolean} canContinueDropping - A predicate function that determines\n * whether to continue dropping elements. The function is called with each element, and dropping\n * continues as long as it returns true.\n * @returns {T[]} A new array with the elements remaining after the predicate returns false.\n *\n * @example\n * const array = [1, 2, 3, 4, 5];\n * const result = dropWhile(array, x => x < 3);\n * // result will be [3, 4, 5] since elements less than 3 are dropped.\n */\nexport function dropWhile<T>(arr: readonly T[], canContinueDropping: (item: T) => boolean): T[] {\n const dropEndIndex = arr.findIndex(item => !canContinueDropping(item));\n if (dropEndIndex === -1) {\n return [];\n }\n\n return arr.slice(dropEndIndex);\n}\n"],"names":[],"mappings":"AAkBgB,SAAA,SAAS,CAAI,GAAiB,EAAE,mBAAyC,EAAA;AACvF,IAAA,MAAM,YAAY,GAAG,GAAG,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC;AACvE,IAAA,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE;AACvB,QAAA,OAAO,EAAE,CAAC;KACX;AAED,IAAA,OAAO,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AACjC;;;;"}
|
package/dist/array/fill.mjs
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
1
|
+
function fill(array, value, start = 0, end = array.length) {
|
|
2
|
+
const length = array.length;
|
|
3
|
+
const finalStart = Math.max(start >= 0 ? start : length + start, 0);
|
|
4
|
+
const finalEnd = Math.min(end >= 0 ? end : length + end, length);
|
|
5
|
+
for (let i = finalStart; i < finalEnd; i++) {
|
|
6
|
+
array[i] = value;
|
|
7
|
+
}
|
|
8
|
+
return array;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { fill };
|
|
12
|
+
//# sourceMappingURL=fill.mjs.map
|
package/dist/array/fill.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],
|
|
1
|
+
{"version":3,"file":"fill.mjs","sources":["../../src/array/fill.ts"],"sourcesContent":["/**\n * Fills elements of an array with a specified value from the start position up to, but not including, the end position.\n *\n * This function mutates the original array and replaces its elements with the provided value, starting from the specified\n * start index up to the end index (non-inclusive). If the start or end indices are not provided, it defaults to filling the\n * entire array.\n *\n * @template T, U\n * @param {Array<T | U>} array - The array to fill.\n * @param {U} value - The value to fill the array with.\n * @param {number} [start=0] - The start position. Defaults to 0.\n * @param {number} [end=arr.length] - The end position. Defaults to the array's length.\n * @returns {Array<T | U>} The array with the filled values.\n *\n * @example\n * const array = [1, 2, 3];\n * const result = fill(array, 'a');\n * // => ['a', 'a', 'a']\n *\n * const result = fill(Array(3), 2);\n * // => [2, 2, 2]\n *\n * const result = fill([4, 6, 8, 10], '*', 1, 3);\n * // => [4, '*', '*', 10]\n *\n * const result = fill(array, '*', -2, -1);\n * // => [1, '*', 3]\n */\nexport function fill<T>(array: unknown[], value: T): T[];\nexport function fill<T, U>(array: Array<T | U>, value: U, start: number): Array<T | U>;\nexport function fill<T, U>(array: Array<T | U>, value: U, start: number, end: number): Array<T | U>;\nexport function fill<T, U>(array: Array<T | U>, value: U, start = 0, end = array.length): Array<T | U> {\n const length = array.length;\n const finalStart = Math.max(start >= 0 ? start : length + start, 0);\n const finalEnd = Math.min(end >= 0 ? end : length + end, length);\n\n for (let i = finalStart; i < finalEnd; i++) {\n array[i] = value;\n }\n\n return array;\n}\n"],"names":[],"mappings":"AA+BgB,SAAA,IAAI,CAAO,KAAmB,EAAE,KAAQ,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,MAAM,EAAA;AACrF,IAAA,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC5B,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC;IACpE,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,MAAM,GAAG,GAAG,EAAE,MAAM,CAAC,CAAC;AAEjE,IAAA,KAAK,IAAI,CAAC,GAAG,UAAU,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE;AAC1C,QAAA,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;KAClB;AAED,IAAA,OAAO,KAAK,CAAC;AACf;;;;"}
|
package/dist/array/flatMap.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=flatMap.mjs.map
|
|
1
|
+
import { flatten } from './flatten.mjs';
|
|
2
|
+
|
|
3
|
+
function flatMap(arr, iteratee, depth = 1) {
|
|
4
|
+
return flatten(arr.map(item => iteratee(item)), depth);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export { flatMap };
|
|
8
|
+
//# sourceMappingURL=flatMap.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],
|
|
1
|
+
{"version":3,"file":"flatMap.mjs","sources":["../../src/array/flatMap.ts"],"sourcesContent":["import { flatten } from './flatten.ts';\n\n/**\n * Maps each element in the array using the iteratee function and flattens the result up to the specified depth.\n *\n * @template T - The type of elements within the array.\n * @template U - The type of elements within the returned array from the iteratee function.\n * @template D - The depth to which the array should be flattened.\n * @param {T[]} arr - The array to flatten.\n * @param {(item: T) => U} iteratee - The function that produces the new array elements.\n * @param {D} depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.\n * @returns {Array<FlatArray<U[], D>>} The new array with the mapped and flattened elements.\n *\n * @example\n * const arr = [1, 2, 3];\n *\n * flatMap(arr, (item: number) => [item, item]);\n * // [1, 1, 2, 2, 3, 3]\n *\n * flatMap(arr, (item: number) => [[item, item]], 2);\n * // [1, 1, 2, 2, 3, 3]\n */\nexport function flatMap<T, U, D extends number>(\n arr: readonly T[],\n iteratee: (item: T) => U,\n depth = 1 as D\n): Array<FlatArray<U[], D>> {\n return flatten(arr.map(item => iteratee(item)), depth);\n}\n"],"names":[],"mappings":";;AAsBM,SAAU,OAAO,CACrB,GAAiB,EACjB,QAAwB,EACxB,QAAQ,CAAM,EAAA;AAEd,IAAA,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AACzD;;;;"}
|
package/dist/array/flatten.mjs
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
function flatten(arr, depth = 1) {
|
|
2
|
+
const result = [];
|
|
3
|
+
const flooredDepth = Math.floor(depth);
|
|
4
|
+
const recursive = (arr, currentDepth) => {
|
|
5
|
+
for (const item of arr) {
|
|
6
|
+
if (Array.isArray(item) && currentDepth < flooredDepth) {
|
|
7
|
+
recursive(item, currentDepth + 1);
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
result.push(item);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
recursive(arr, 0);
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { flatten };
|
|
19
|
+
//# sourceMappingURL=flatten.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],
|
|
1
|
+
{"version":3,"file":"flatten.mjs","sources":["../../src/array/flatten.ts"],"sourcesContent":["/**\n * Flattens an array up to the specified depth.\n *\n * @template T - The type of elements within the array.\n * @template D - The depth to which the array should be flattened.\n * @param {T[]} arr - The array to flatten.\n * @param {D} depth - The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.\n * @returns {Array<FlatArray<T[], D>>} A new array that has been flattened.\n *\n * @example\n * const arr = flatten([1, [2, 3], [4, [5, 6]]], 1);\n * // Returns: [1, 2, 3, 4, [5, 6]]\n *\n * const arr = flatten([1, [2, 3], [4, [5, 6]]], 2);\n * // Returns: [1, 2, 3, 4, 5, 6]\n */\nexport function flatten<T, D extends number = 1>(arr: readonly T[], depth = 1 as D): Array<FlatArray<T[], D>> {\n const result: Array<FlatArray<T[], D>> = [];\n const flooredDepth = Math.floor(depth);\n\n const recursive = (arr: readonly T[], currentDepth: number) => {\n for (const item of arr) {\n if (Array.isArray(item) && currentDepth < flooredDepth) {\n recursive(item, currentDepth + 1);\n } else {\n result.push(item as FlatArray<T[], D>);\n }\n }\n };\n\n recursive(arr, 0);\n return result;\n}\n"],"names":[],"mappings":"SAgBgB,OAAO,CAA0B,GAAiB,EAAE,QAAQ,CAAM,EAAA;IAChF,MAAM,MAAM,GAA6B,EAAE,CAAC;IAC5C,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAEvC,IAAA,MAAM,SAAS,GAAG,CAAC,GAAiB,EAAE,YAAoB,KAAI;AAC5D,QAAA,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE;YACtB,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,YAAY,GAAG,YAAY,EAAE;AACtD,gBAAA,SAAS,CAAC,IAAI,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;aACnC;iBAAM;AACL,gBAAA,MAAM,CAAC,IAAI,CAAC,IAAyB,CAAC,CAAC;aACxC;SACF;AACH,KAAC,CAAC;AAEF,IAAA,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AAClB,IAAA,OAAO,MAAM,CAAC;AAChB;;;;"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=flattenDeep.mjs.map
|
|
1
|
+
import { flatten } from './flatten.mjs';
|
|
2
|
+
|
|
3
|
+
function flattenDeep(arr) {
|
|
4
|
+
return flatten(arr, Infinity);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export { flattenDeep };
|
|
8
|
+
//# sourceMappingURL=flattenDeep.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],
|
|
1
|
+
{"version":3,"file":"flattenDeep.mjs","sources":["../../src/array/flattenDeep.ts"],"sourcesContent":["import { flatten } from './flatten.ts';\n\n/**\n * Utility type for recursively unpacking nested array types to extract the type of the innermost element\n *\n * @example\n * ExtractNestedArrayType<(number | (number | number[])[])[]>\n * // number\n *\n * ExtractNestedArrayType<(boolean | (string | number[])[])[]>\n * // string | number | boolean\n */\ntype ExtractNestedArrayType<T> = T extends ReadonlyArray<infer U> ? ExtractNestedArrayType<U> : T;\n\n/**\n * Flattens all depths of a nested array.\n *\n * @template T - The type of elements within the array.\n * @param {T[]} arr - The array to flatten.\n * @returns {Array<ExtractNestedArrayType<T>>} A new array that has been flattened.\n *\n * @example\n * const arr = flattenDeep([1, [2, [3]], [4, [5, 6]]]);\n * // Returns: [1, 2, 3, 4, 5, 6]\n */\nexport function flattenDeep<T>(arr: readonly T[]): Array<ExtractNestedArrayType<T>> {\n return flatten(arr, Infinity) as Array<ExtractNestedArrayType<T>>;\n}\n"],"names":[],"mappings":";;AAyBM,SAAU,WAAW,CAAI,GAAiB,EAAA;AAC9C,IAAA,OAAO,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAqC,CAAC;AACpE;;;;"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
function forEachRight(arr, callback) {
|
|
2
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
3
|
+
const element = arr[i];
|
|
4
|
+
callback(element, i, arr);
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { forEachRight };
|
|
9
|
+
//# sourceMappingURL=forEachRight.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],
|
|
1
|
+
{"version":3,"file":"forEachRight.mjs","sources":["../../src/array/forEachRight.ts"],"sourcesContent":["/**\n * Iterates over elements of 'arr' from right to left and invokes 'callback' for each element.\n * \n * @template T - The type of elements in the array.\n * @param {T[]} arr - The array to iterate over.\n * @param {(value: T, index: number, arr: T[]) => void} callback - The function invoked per iteration.\n * The callback function receives three arguments:\n * - 'value': The current element being processed in the array.\n * - 'index': The index of the current element being processed in the array.\n * - 'arr': The array 'forEachRight' was called upon.\n * \n * @example\n * const array = [1, 2, 3];\n * const result: number[] = [];\n * \n * // Use the forEachRight function to iterate through the array and add each element to the result array.\n * forEachRight(array, (value) => {\n * result.push(value);\n * })\n * \n * console.log(result) // Output: [3, 2, 1]\n */\n\nexport function forEachRight<T>(arr: T[], callback: (value: T, index: number, arr: T[]) => void): void {\n for (let i = arr.length - 1; i >= 0; i--) {\n const element = arr[i];\n callback(element, i, arr);\n }\n}\n"],"names":[],"mappings":"AAuBgB,SAAA,YAAY,CAAI,GAAQ,EAAE,QAAqD,EAAA;AAC7F,IAAA,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;AACxC,QAAA,MAAM,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AACvB,QAAA,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;KAC3B;AACH;;;;"}
|
package/dist/array/groupBy.mjs
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
1
|
+
function groupBy(arr, getKeyFromItem) {
|
|
2
|
+
const result = {};
|
|
3
|
+
for (const item of arr) {
|
|
4
|
+
const key = getKeyFromItem(item);
|
|
5
|
+
if (result[key] == null) {
|
|
6
|
+
result[key] = [];
|
|
7
|
+
}
|
|
8
|
+
result[key].push(item);
|
|
9
|
+
}
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { groupBy };
|
|
14
|
+
//# sourceMappingURL=groupBy.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],
|
|
1
|
+
{"version":3,"file":"groupBy.mjs","sources":["../../src/array/groupBy.ts"],"sourcesContent":["/**\n * Groups the elements of an array based on a provided key-generating function.\n *\n * This function takes an array and a function that generates a key from each element. It returns\n * an object where the keys are the generated keys and the values are arrays of elements that share\n * the same key.\n *\n * @template T - The type of elements in the array.\n * @template K - The type of keys.\n * @param {T[]} arr - The array to group.\n * @param {(item: T) => K} getKeyFromItem - A function that generates a key from an element.\n * @returns {Record<K, T[]>} An object where each key is associated with an array of elements that\n * share that key.\n *\n * @example\n * const array = [\n * { category: 'fruit', name: 'apple' },\n * { category: 'fruit', name: 'banana' },\n * { category: 'vegetable', name: 'carrot' }\n * ];\n * const result = groupBy(array, item => item.category);\n * // result will be:\n * // {\n * // fruit: [\n * // { category: 'fruit', name: 'apple' },\n * // { category: 'fruit', name: 'banana' }\n * // ],\n * // vegetable: [\n * // { category: 'vegetable', name: 'carrot' }\n * // ]\n * // }\n */\nexport function groupBy<T, K extends PropertyKey>(arr: readonly T[], getKeyFromItem: (item: T) => K): Record<K, T[]> {\n const result = {} as Record<K, T[]>;\n\n for (const item of arr) {\n const key = getKeyFromItem(item);\n\n if (result[key] == null) {\n result[key] = [];\n }\n\n result[key].push(item);\n }\n\n return result;\n}\n"],"names":[],"mappings":"AAgCgB,SAAA,OAAO,CAA2B,GAAiB,EAAE,cAA8B,EAAA;IACjG,MAAM,MAAM,GAAG,EAAoB,CAAC;AAEpC,IAAA,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE;AACtB,QAAA,MAAM,GAAG,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;AAEjC,QAAA,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE;AACvB,YAAA,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;SAClB;QAED,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACxB;AAED,IAAA,OAAO,MAAM,CAAC;AAChB;;;;"}
|