@vielzeug/toolkit 1.1.3 → 2.0.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 +325 -452
- package/dist/array/chunk.cjs +2 -2
- package/dist/array/chunk.cjs.map +1 -1
- package/dist/array/chunk.d.ts +29 -0
- package/dist/array/chunk.d.ts.map +1 -0
- package/dist/array/chunk.js +22 -24
- package/dist/array/chunk.js.map +1 -1
- package/dist/array/contains.cjs +2 -2
- package/dist/array/contains.cjs.map +1 -1
- package/dist/array/contains.d.ts +19 -0
- package/dist/array/contains.d.ts.map +1 -0
- package/dist/array/contains.js +12 -9
- package/dist/array/contains.js.map +1 -1
- package/dist/array/fold.cjs +2 -0
- package/dist/array/fold.cjs.map +1 -0
- package/dist/array/fold.d.ts +21 -0
- package/dist/array/fold.d.ts.map +1 -0
- package/dist/array/fold.js +19 -0
- package/dist/array/fold.js.map +1 -0
- package/dist/array/group.cjs +2 -2
- package/dist/array/group.cjs.map +1 -1
- package/dist/array/group.d.ts +19 -0
- package/dist/array/group.d.ts.map +1 -0
- package/dist/array/group.js +18 -15
- package/dist/array/group.js.map +1 -1
- package/dist/array/index.d.ts +16 -0
- package/dist/array/index.d.ts.map +1 -0
- package/dist/array/keyBy.cjs +2 -0
- package/dist/array/keyBy.cjs.map +1 -0
- package/dist/array/keyBy.d.ts +20 -0
- package/dist/array/keyBy.d.ts.map +1 -0
- package/dist/array/keyBy.js +19 -0
- package/dist/array/keyBy.js.map +1 -0
- package/dist/array/list.cjs +2 -2
- package/dist/array/list.cjs.map +1 -1
- package/dist/array/list.d.ts +58 -0
- package/dist/array/list.d.ts.map +1 -0
- package/dist/array/list.js +103 -106
- package/dist/array/list.js.map +1 -1
- package/dist/array/pick.cjs +2 -2
- package/dist/array/pick.cjs.map +1 -1
- package/dist/array/pick.d.ts +19 -0
- package/dist/array/pick.d.ts.map +1 -0
- package/dist/array/pick.js +15 -14
- package/dist/array/pick.js.map +1 -1
- package/dist/array/remoteList.cjs +2 -2
- package/dist/array/remoteList.cjs.map +1 -1
- package/dist/array/remoteList.d.ts +64 -0
- package/dist/array/remoteList.d.ts.map +1 -0
- package/dist/array/remoteList.js +121 -122
- package/dist/array/remoteList.js.map +1 -1
- package/dist/array/replace.cjs +2 -0
- package/dist/array/replace.cjs.map +1 -0
- package/dist/array/replace.d.ts +20 -0
- package/dist/array/replace.d.ts.map +1 -0
- package/dist/array/replace.js +19 -0
- package/dist/array/replace.js.map +1 -0
- package/dist/array/rotate.cjs +2 -0
- package/dist/array/rotate.cjs.map +1 -0
- package/dist/array/rotate.d.ts +22 -0
- package/dist/array/rotate.d.ts.map +1 -0
- package/dist/array/rotate.js +19 -0
- package/dist/array/rotate.js.map +1 -0
- package/dist/array/search.cjs +2 -2
- package/dist/array/search.cjs.map +1 -1
- package/dist/array/search.d.ts +19 -0
- package/dist/array/search.d.ts.map +1 -0
- package/dist/array/search.js +23 -13
- package/dist/array/search.js.map +1 -1
- package/dist/array/select.cjs +2 -2
- package/dist/array/select.cjs.map +1 -1
- package/dist/array/select.d.ts +21 -0
- package/dist/array/select.d.ts.map +1 -0
- package/dist/array/select.js +16 -15
- package/dist/array/select.js.map +1 -1
- package/dist/array/sort.cjs +2 -2
- package/dist/array/sort.cjs.map +1 -1
- package/dist/array/sort.d.ts +26 -0
- package/dist/array/sort.d.ts.map +1 -0
- package/dist/array/sort.js +18 -12
- package/dist/array/sort.js.map +1 -1
- package/dist/array/toggle.cjs +2 -0
- package/dist/array/toggle.cjs.map +1 -0
- package/dist/array/toggle.d.ts +29 -0
- package/dist/array/toggle.d.ts.map +1 -0
- package/dist/array/toggle.js +9 -0
- package/dist/array/toggle.js.map +1 -0
- package/dist/array/uniq.cjs +2 -2
- package/dist/array/uniq.cjs.map +1 -1
- package/dist/array/uniq.d.ts +21 -0
- package/dist/array/uniq.d.ts.map +1 -0
- package/dist/array/uniq.js +15 -17
- package/dist/array/uniq.js.map +1 -1
- package/dist/async/attempt.cjs +2 -2
- package/dist/async/attempt.cjs.map +1 -1
- package/dist/async/attempt.d.ts +40 -0
- package/dist/async/attempt.d.ts.map +1 -0
- package/dist/async/attempt.js +19 -14
- package/dist/async/attempt.js.map +1 -1
- package/dist/async/defer.cjs +2 -2
- package/dist/async/defer.cjs.map +1 -1
- package/dist/async/defer.d.ts +23 -0
- package/dist/async/defer.d.ts.map +1 -0
- package/dist/async/defer.js +12 -9
- package/dist/async/defer.js.map +1 -1
- package/dist/async/index.d.ts +12 -0
- package/dist/async/index.d.ts.map +1 -0
- package/dist/async/parallel.cjs +2 -2
- package/dist/async/parallel.cjs.map +1 -1
- package/dist/async/parallel.d.ts +31 -0
- package/dist/async/parallel.d.ts.map +1 -0
- package/dist/async/parallel.js +26 -27
- package/dist/async/parallel.js.map +1 -1
- package/dist/async/pool.cjs +2 -2
- package/dist/async/pool.cjs.map +1 -1
- package/dist/async/pool.d.ts +21 -0
- package/dist/async/pool.d.ts.map +1 -0
- package/dist/async/pool.js +23 -21
- package/dist/async/pool.js.map +1 -1
- package/dist/async/predict.cjs +2 -2
- package/dist/async/predict.cjs.map +1 -1
- package/dist/async/predict.d.ts +24 -0
- package/dist/async/predict.d.ts.map +1 -0
- package/dist/async/predict.js +10 -12
- package/dist/async/predict.js.map +1 -1
- package/dist/async/queue.cjs +2 -2
- package/dist/async/queue.cjs.map +1 -1
- package/dist/async/queue.d.ts +43 -0
- package/dist/async/queue.d.ts.map +1 -0
- package/dist/async/queue.js +52 -56
- package/dist/async/queue.js.map +1 -1
- package/dist/async/race.cjs +2 -2
- package/dist/async/race.cjs.map +1 -1
- package/dist/async/race.d.ts +16 -0
- package/dist/async/race.d.ts.map +1 -0
- package/dist/async/race.js +8 -7
- package/dist/async/race.js.map +1 -1
- package/dist/async/retry.cjs +2 -2
- package/dist/async/retry.cjs.map +1 -1
- package/dist/async/retry.d.ts +32 -0
- package/dist/async/retry.d.ts.map +1 -0
- package/dist/async/retry.js +19 -24
- package/dist/async/retry.js.map +1 -1
- package/dist/async/scheduler.cjs +2 -0
- package/dist/async/scheduler.cjs.map +1 -0
- package/dist/async/scheduler.d.ts +51 -0
- package/dist/async/scheduler.d.ts.map +1 -0
- package/dist/async/scheduler.js +43 -0
- package/dist/async/scheduler.js.map +1 -0
- package/dist/async/sleep.cjs +2 -2
- package/dist/async/sleep.cjs.map +1 -1
- package/dist/async/sleep.d.ts +16 -0
- package/dist/async/sleep.d.ts.map +1 -0
- package/dist/async/sleep.js +11 -11
- package/dist/async/sleep.js.map +1 -1
- package/dist/async/waitFor.cjs +2 -2
- package/dist/async/waitFor.cjs.map +1 -1
- package/dist/async/waitFor.d.ts +33 -0
- package/dist/async/waitFor.d.ts.map +1 -0
- package/dist/async/waitFor.js +29 -36
- package/dist/async/waitFor.js.map +1 -1
- package/dist/date/expires.cjs +2 -2
- package/dist/date/expires.cjs.map +1 -1
- package/dist/date/expires.d.ts +15 -0
- package/dist/date/expires.d.ts.map +1 -0
- package/dist/date/expires.js +11 -10
- package/dist/date/expires.js.map +1 -1
- package/dist/date/index.d.ts +4 -0
- package/dist/date/index.d.ts.map +1 -0
- package/dist/date/interval.cjs +2 -2
- package/dist/date/interval.cjs.map +1 -1
- package/dist/date/interval.d.ts +25 -0
- package/dist/date/interval.d.ts.map +1 -0
- package/dist/date/interval.js +31 -37
- package/dist/date/interval.js.map +1 -1
- package/dist/date/timeDiff.cjs +2 -2
- package/dist/date/timeDiff.cjs.map +1 -1
- package/dist/date/timeDiff.d.ts +24 -0
- package/dist/date/timeDiff.d.ts.map +1 -0
- package/dist/date/timeDiff.js +58 -25
- package/dist/date/timeDiff.js.map +1 -1
- package/dist/function/assert.cjs +2 -3
- package/dist/function/assert.cjs.map +1 -1
- package/dist/function/assert.d.ts +38 -0
- package/dist/function/assert.d.ts.map +1 -0
- package/dist/function/assert.js +13 -11
- package/dist/function/assert.js.map +1 -1
- package/dist/function/assertParams.cjs +2 -2
- package/dist/function/assertParams.cjs.map +1 -1
- package/dist/function/assertParams.d.ts +24 -0
- package/dist/function/assertParams.d.ts.map +1 -0
- package/dist/function/assertParams.js +13 -12
- package/dist/function/assertParams.js.map +1 -1
- package/dist/function/compare.cjs +2 -2
- package/dist/function/compare.cjs.map +1 -1
- package/dist/function/compare.d.ts +23 -0
- package/dist/function/compare.d.ts.map +1 -0
- package/dist/function/compare.js +22 -21
- package/dist/function/compare.js.map +1 -1
- package/dist/function/compareBy.cjs +2 -2
- package/dist/function/compareBy.cjs.map +1 -1
- package/dist/function/compareBy.d.ts +24 -0
- package/dist/function/compareBy.d.ts.map +1 -0
- package/dist/function/compareBy.js +15 -14
- package/dist/function/compareBy.js.map +1 -1
- package/dist/function/compose.cjs +2 -2
- package/dist/function/compose.cjs.map +1 -1
- package/dist/function/compose.d.ts +22 -0
- package/dist/function/compose.d.ts.map +1 -0
- package/dist/function/compose.js +10 -13
- package/dist/function/compose.js.map +1 -1
- package/dist/function/curry.cjs +2 -2
- package/dist/function/curry.cjs.map +1 -1
- package/dist/function/curry.d.ts +21 -0
- package/dist/function/curry.d.ts.map +1 -0
- package/dist/function/curry.js +8 -7
- package/dist/function/curry.js.map +1 -1
- package/dist/function/debounce.cjs +2 -2
- package/dist/function/debounce.cjs.map +1 -1
- package/dist/function/debounce.d.ts +12 -0
- package/dist/function/debounce.d.ts.map +1 -0
- package/dist/function/debounce.js +34 -26
- package/dist/function/debounce.js.map +1 -1
- package/dist/function/fp.cjs +2 -2
- package/dist/function/fp.cjs.map +1 -1
- package/dist/function/fp.d.ts +24 -0
- package/dist/function/fp.d.ts.map +1 -0
- package/dist/function/fp.js +6 -10
- package/dist/function/fp.js.map +1 -1
- package/dist/function/index.d.ts +13 -0
- package/dist/function/index.d.ts.map +1 -0
- package/dist/function/memo.cjs +2 -2
- package/dist/function/memo.cjs.map +1 -1
- package/dist/function/memo.d.ts +30 -0
- package/dist/function/memo.d.ts.map +1 -0
- package/dist/function/memo.js +16 -24
- package/dist/function/memo.js.map +1 -1
- package/dist/function/once.cjs +2 -2
- package/dist/function/once.cjs.map +1 -1
- package/dist/function/once.d.ts +24 -0
- package/dist/function/once.d.ts.map +1 -0
- package/dist/function/once.js +10 -10
- package/dist/function/once.js.map +1 -1
- package/dist/function/pipe.cjs +2 -2
- package/dist/function/pipe.cjs.map +1 -1
- package/dist/function/pipe.d.ts +23 -0
- package/dist/function/pipe.d.ts.map +1 -0
- package/dist/function/pipe.js +10 -10
- package/dist/function/pipe.js.map +1 -1
- package/dist/function/throttle.cjs +2 -2
- package/dist/function/throttle.cjs.map +1 -1
- package/dist/function/throttle.d.ts +21 -0
- package/dist/function/throttle.d.ts.map +1 -0
- package/dist/function/throttle.js +45 -37
- package/dist/function/throttle.js.map +1 -1
- package/dist/index.cjs +1 -2
- package/dist/index.d.ts +77 -2813
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +75 -253
- package/dist/math/abs.cjs +2 -2
- package/dist/math/abs.cjs.map +1 -1
- package/dist/math/abs.d.ts +17 -0
- package/dist/math/abs.d.ts.map +1 -0
- package/dist/math/abs.js +7 -6
- package/dist/math/abs.js.map +1 -1
- package/dist/math/allocate.cjs +2 -2
- package/dist/math/allocate.cjs.map +1 -1
- package/dist/math/allocate.d.ts +24 -0
- package/dist/math/allocate.d.ts.map +1 -0
- package/dist/math/allocate.js +20 -28
- package/dist/math/allocate.js.map +1 -1
- package/dist/math/average.cjs +2 -2
- package/dist/math/average.cjs.map +1 -1
- package/dist/math/average.d.ts +16 -0
- package/dist/math/average.d.ts.map +1 -0
- package/dist/math/average.js +13 -24
- package/dist/math/average.js.map +1 -1
- package/dist/math/clamp.cjs +2 -2
- package/dist/math/clamp.cjs.map +1 -1
- package/dist/math/clamp.d.ts +18 -0
- package/dist/math/clamp.d.ts.map +1 -0
- package/dist/math/clamp.js +7 -6
- package/dist/math/clamp.js.map +1 -1
- package/dist/math/distribute.cjs +2 -2
- package/dist/math/distribute.cjs.map +1 -1
- package/dist/math/distribute.d.ts +24 -0
- package/dist/math/distribute.d.ts.map +1 -0
- package/dist/math/distribute.js +14 -17
- package/dist/math/distribute.js.map +1 -1
- package/dist/math/index.d.ts +14 -0
- package/dist/math/index.d.ts.map +1 -0
- package/dist/math/linspace.cjs +2 -0
- package/dist/math/linspace.cjs.map +1 -0
- package/dist/math/linspace.d.ts +19 -0
- package/dist/math/linspace.d.ts.map +1 -0
- package/dist/math/linspace.js +11 -0
- package/dist/math/linspace.js.map +1 -0
- package/dist/math/max.cjs +2 -2
- package/dist/math/max.cjs.map +1 -1
- package/dist/math/max.d.ts +23 -0
- package/dist/math/max.d.ts.map +1 -0
- package/dist/math/max.js +10 -11
- package/dist/math/max.js.map +1 -1
- package/dist/math/median.cjs +2 -2
- package/dist/math/median.cjs.map +1 -1
- package/dist/math/median.d.ts +17 -0
- package/dist/math/median.d.ts.map +1 -0
- package/dist/math/median.js +11 -10
- package/dist/math/median.js.map +1 -1
- package/dist/math/min.cjs +2 -2
- package/dist/math/min.cjs.map +1 -1
- package/dist/math/min.d.ts +23 -0
- package/dist/math/min.d.ts.map +1 -0
- package/dist/math/min.js +10 -11
- package/dist/math/min.js.map +1 -1
- package/dist/math/percent.cjs +2 -0
- package/dist/math/percent.cjs.map +1 -0
- package/dist/math/percent.d.ts +19 -0
- package/dist/math/percent.d.ts.map +1 -0
- package/dist/math/percent.js +8 -0
- package/dist/math/percent.js.map +1 -0
- package/dist/math/range.cjs +2 -2
- package/dist/math/range.cjs.map +1 -1
- package/dist/math/range.d.ts +23 -0
- package/dist/math/range.d.ts.map +1 -0
- package/dist/math/range.js +28 -17
- package/dist/math/range.js.map +1 -1
- package/dist/math/round.cjs +2 -2
- package/dist/math/round.cjs.map +1 -1
- package/dist/math/round.d.ts +21 -0
- package/dist/math/round.d.ts.map +1 -0
- package/dist/math/round.js +9 -8
- package/dist/math/round.js.map +1 -1
- package/dist/math/sum.cjs +2 -2
- package/dist/math/sum.cjs.map +1 -1
- package/dist/math/sum.d.ts +17 -0
- package/dist/math/sum.d.ts.map +1 -0
- package/dist/math/sum.js +11 -14
- package/dist/math/sum.js.map +1 -1
- package/dist/money/currency.cjs +2 -2
- package/dist/money/currency.cjs.map +1 -1
- package/dist/money/currency.d.ts +30 -0
- package/dist/money/currency.d.ts.map +1 -0
- package/dist/money/currency.js +19 -47
- package/dist/money/currency.js.map +1 -1
- package/dist/money/exchange.cjs +2 -2
- package/dist/money/exchange.cjs.map +1 -1
- package/dist/money/exchange.d.ts +29 -0
- package/dist/money/exchange.d.ts.map +1 -0
- package/dist/money/exchange.js +12 -12
- package/dist/money/exchange.js.map +1 -1
- package/dist/money/index.d.ts +4 -0
- package/dist/money/index.d.ts.map +1 -0
- package/dist/money/types.d.ts +9 -0
- package/dist/money/types.d.ts.map +1 -0
- package/dist/object/diff.cjs +2 -2
- package/dist/object/diff.cjs.map +1 -1
- package/dist/object/diff.d.ts +26 -0
- package/dist/object/diff.d.ts.map +1 -0
- package/dist/object/diff.js +19 -17
- package/dist/object/diff.js.map +1 -1
- package/dist/object/index.d.ts +9 -0
- package/dist/object/index.d.ts.map +1 -0
- package/dist/object/merge.cjs +2 -2
- package/dist/object/merge.cjs.map +1 -1
- package/dist/object/merge.d.ts +44 -0
- package/dist/object/merge.d.ts.map +1 -0
- package/dist/object/merge.js +27 -21
- package/dist/object/merge.js.map +1 -1
- package/dist/object/parseJSON.cjs +2 -2
- package/dist/object/parseJSON.cjs.map +1 -1
- package/dist/object/parseJSON.d.ts +32 -0
- package/dist/object/parseJSON.d.ts.map +1 -0
- package/dist/object/parseJSON.js +17 -18
- package/dist/object/parseJSON.js.map +1 -1
- package/dist/object/path.cjs +2 -2
- package/dist/object/path.cjs.map +1 -1
- package/dist/object/path.d.ts +32 -0
- package/dist/object/path.d.ts.map +1 -0
- package/dist/object/path.js +25 -23
- package/dist/object/path.js.map +1 -1
- package/dist/object/proxy.cjs +2 -0
- package/dist/object/proxy.cjs.map +1 -0
- package/dist/object/proxy.d.ts +30 -0
- package/dist/object/proxy.d.ts.map +1 -0
- package/dist/object/proxy.js +21 -0
- package/dist/object/proxy.js.map +1 -0
- package/dist/object/prune.cjs +2 -0
- package/dist/object/prune.cjs.map +1 -0
- package/dist/object/prune.d.ts +21 -0
- package/dist/object/prune.d.ts.map +1 -0
- package/dist/object/prune.js +31 -0
- package/dist/object/prune.js.map +1 -0
- package/dist/object/seek.cjs +2 -2
- package/dist/object/seek.cjs.map +1 -1
- package/dist/object/seek.d.ts +2 -0
- package/dist/object/seek.d.ts.map +1 -0
- package/dist/object/seek.js +25 -12
- package/dist/object/seek.js.map +1 -1
- package/dist/object/stash.cjs +2 -0
- package/dist/object/stash.cjs.map +1 -0
- package/dist/object/stash.d.ts +45 -0
- package/dist/object/stash.d.ts.map +1 -0
- package/dist/object/stash.js +99 -0
- package/dist/object/stash.js.map +1 -0
- package/dist/random/draw.cjs +2 -2
- package/dist/random/draw.cjs.map +1 -1
- package/dist/random/draw.d.ts +16 -0
- package/dist/random/draw.d.ts.map +1 -0
- package/dist/random/draw.js +13 -10
- package/dist/random/draw.js.map +1 -1
- package/dist/random/index.d.ts +5 -0
- package/dist/random/index.d.ts.map +1 -0
- package/dist/random/random.cjs +2 -2
- package/dist/random/random.cjs.map +1 -1
- package/dist/random/random.d.ts +14 -0
- package/dist/random/random.d.ts.map +1 -0
- package/dist/random/random.js +16 -9
- package/dist/random/random.js.map +1 -1
- package/dist/random/shuffle.cjs +2 -2
- package/dist/random/shuffle.cjs.map +1 -1
- package/dist/random/shuffle.d.ts +17 -0
- package/dist/random/shuffle.d.ts.map +1 -0
- package/dist/random/shuffle.js +18 -14
- package/dist/random/shuffle.js.map +1 -1
- package/dist/random/uuid.cjs +2 -2
- package/dist/random/uuid.cjs.map +1 -1
- package/dist/random/uuid.d.ts +12 -0
- package/dist/random/uuid.d.ts.map +1 -0
- package/dist/random/uuid.js +7 -9
- package/dist/random/uuid.js.map +1 -1
- package/dist/string/_caseUtils.cjs +2 -2
- package/dist/string/_caseUtils.cjs.map +1 -1
- package/dist/string/_caseUtils.d.ts +13 -0
- package/dist/string/_caseUtils.d.ts.map +1 -0
- package/dist/string/_caseUtils.js +8 -8
- package/dist/string/_caseUtils.js.map +1 -1
- package/dist/string/camelCase.cjs +2 -2
- package/dist/string/camelCase.cjs.map +1 -1
- package/dist/string/camelCase.d.ts +14 -0
- package/dist/string/camelCase.d.ts.map +1 -0
- package/dist/string/camelCase.js +8 -7
- package/dist/string/camelCase.js.map +1 -1
- package/dist/string/index.d.ts +7 -0
- package/dist/string/index.d.ts.map +1 -0
- package/dist/string/kebabCase.cjs +2 -2
- package/dist/string/kebabCase.cjs.map +1 -1
- package/dist/string/kebabCase.d.ts +15 -0
- package/dist/string/kebabCase.d.ts.map +1 -0
- package/dist/string/kebabCase.js +8 -7
- package/dist/string/kebabCase.js.map +1 -1
- package/dist/string/pascalCase.cjs +2 -2
- package/dist/string/pascalCase.cjs.map +1 -1
- package/dist/string/pascalCase.d.ts +15 -0
- package/dist/string/pascalCase.d.ts.map +1 -0
- package/dist/string/pascalCase.js +8 -7
- package/dist/string/pascalCase.js.map +1 -1
- package/dist/string/similarity.cjs +2 -2
- package/dist/string/similarity.cjs.map +1 -1
- package/dist/string/similarity.d.ts +20 -0
- package/dist/string/similarity.d.ts.map +1 -0
- package/dist/string/similarity.js +20 -36
- package/dist/string/similarity.js.map +1 -1
- package/dist/string/snakeCase.cjs +2 -2
- package/dist/string/snakeCase.cjs.map +1 -1
- package/dist/string/snakeCase.d.ts +15 -0
- package/dist/string/snakeCase.d.ts.map +1 -0
- package/dist/string/snakeCase.js +8 -7
- package/dist/string/snakeCase.js.map +1 -1
- package/dist/string/truncate.cjs +2 -2
- package/dist/string/truncate.cjs.map +1 -1
- package/dist/string/truncate.d.ts +28 -0
- package/dist/string/truncate.d.ts.map +1 -0
- package/dist/string/truncate.js +20 -17
- package/dist/string/truncate.js.map +1 -1
- package/dist/toolkit.cjs +2 -0
- package/dist/toolkit.cjs.map +1 -0
- package/dist/toolkit.js +1523 -0
- package/dist/toolkit.js.map +1 -0
- package/dist/typed/index.d.ts +24 -0
- package/dist/typed/index.d.ts.map +1 -0
- package/dist/typed/is.cjs +2 -2
- package/dist/typed/is.cjs.map +1 -1
- package/dist/typed/is.d.ts +95 -0
- package/dist/typed/is.d.ts.map +1 -0
- package/dist/typed/is.js +54 -42
- package/dist/typed/is.js.map +1 -1
- package/dist/typed/isArray.cjs +2 -2
- package/dist/typed/isArray.cjs.map +1 -1
- package/dist/typed/isArray.d.ts +16 -0
- package/dist/typed/isArray.d.ts.map +1 -0
- package/dist/typed/isArray.js +8 -8
- package/dist/typed/isArray.js.map +1 -1
- package/dist/typed/isBoolean.cjs +2 -2
- package/dist/typed/isBoolean.cjs.map +1 -1
- package/dist/typed/isBoolean.d.ts +23 -0
- package/dist/typed/isBoolean.d.ts.map +1 -0
- package/dist/typed/isBoolean.js +7 -6
- package/dist/typed/isBoolean.js.map +1 -1
- package/dist/typed/isDate.cjs +2 -2
- package/dist/typed/isDate.cjs.map +1 -1
- package/dist/typed/isDate.d.ts +16 -0
- package/dist/typed/isDate.d.ts.map +1 -0
- package/dist/typed/isDate.js +7 -8
- package/dist/typed/isDate.js.map +1 -1
- package/dist/typed/isDefined.cjs +2 -2
- package/dist/typed/isDefined.cjs.map +1 -1
- package/dist/typed/isDefined.d.ts +19 -0
- package/dist/typed/isDefined.d.ts.map +1 -0
- package/dist/typed/isDefined.js +7 -6
- package/dist/typed/isDefined.js.map +1 -1
- package/dist/typed/isEmpty.cjs +2 -2
- package/dist/typed/isEmpty.cjs.map +1 -1
- package/dist/typed/isEmpty.d.ts +24 -0
- package/dist/typed/isEmpty.d.ts.map +1 -0
- package/dist/typed/isEmpty.js +8 -9
- package/dist/typed/isEmpty.js.map +1 -1
- package/dist/typed/isEqual.cjs +2 -2
- package/dist/typed/isEqual.cjs.map +1 -1
- package/dist/typed/isEqual.d.ts +24 -0
- package/dist/typed/isEqual.d.ts.map +1 -0
- package/dist/typed/isEqual.js +27 -28
- package/dist/typed/isEqual.js.map +1 -1
- package/dist/typed/isEven.cjs +2 -2
- package/dist/typed/isEven.cjs.map +1 -1
- package/dist/typed/isEven.d.ts +9 -0
- package/dist/typed/isEven.d.ts.map +1 -0
- package/dist/typed/isEven.js +7 -6
- package/dist/typed/isEven.js.map +1 -1
- package/dist/typed/isFunction.cjs +2 -2
- package/dist/typed/isFunction.cjs.map +1 -1
- package/dist/typed/isFunction.d.ts +16 -0
- package/dist/typed/isFunction.d.ts.map +1 -0
- package/dist/typed/isFunction.js +7 -8
- package/dist/typed/isFunction.js.map +1 -1
- package/dist/typed/isMatch.cjs +2 -2
- package/dist/typed/isMatch.cjs.map +1 -1
- package/dist/typed/isMatch.d.ts +23 -0
- package/dist/typed/isMatch.d.ts.map +1 -0
- package/dist/typed/isMatch.js +16 -18
- package/dist/typed/isMatch.js.map +1 -1
- package/dist/typed/isNegative.cjs +2 -2
- package/dist/typed/isNegative.cjs.map +1 -1
- package/dist/typed/isNegative.d.ts +26 -0
- package/dist/typed/isNegative.d.ts.map +1 -0
- package/dist/typed/isNegative.js +7 -6
- package/dist/typed/isNegative.js.map +1 -1
- package/dist/typed/isNil.cjs +2 -2
- package/dist/typed/isNil.cjs.map +1 -1
- package/dist/typed/isNil.d.ts +17 -0
- package/dist/typed/isNil.d.ts.map +1 -0
- package/dist/typed/isNil.js +7 -8
- package/dist/typed/isNil.js.map +1 -1
- package/dist/typed/isNumber.cjs +2 -2
- package/dist/typed/isNumber.cjs.map +1 -1
- package/dist/typed/isNumber.d.ts +16 -0
- package/dist/typed/isNumber.d.ts.map +1 -0
- package/dist/typed/isNumber.js +8 -8
- package/dist/typed/isNumber.js.map +1 -1
- package/dist/typed/isObject.cjs +2 -2
- package/dist/typed/isObject.cjs.map +1 -1
- package/dist/typed/isObject.d.ts +19 -0
- package/dist/typed/isObject.d.ts.map +1 -0
- package/dist/typed/isObject.js +8 -8
- package/dist/typed/isObject.js.map +1 -1
- package/dist/typed/isOdd.cjs +2 -2
- package/dist/typed/isOdd.cjs.map +1 -1
- package/dist/typed/isOdd.d.ts +9 -0
- package/dist/typed/isOdd.d.ts.map +1 -0
- package/dist/typed/isOdd.js +7 -6
- package/dist/typed/isOdd.js.map +1 -1
- package/dist/typed/isPositive.cjs +2 -2
- package/dist/typed/isPositive.cjs.map +1 -1
- package/dist/typed/isPositive.d.ts +26 -0
- package/dist/typed/isPositive.d.ts.map +1 -0
- package/dist/typed/isPositive.js +7 -6
- package/dist/typed/isPositive.js.map +1 -1
- package/dist/typed/isPrimitive.cjs +2 -2
- package/dist/typed/isPrimitive.cjs.map +1 -1
- package/dist/typed/isPrimitive.d.ts +18 -0
- package/dist/typed/isPrimitive.d.ts.map +1 -0
- package/dist/typed/isPrimitive.js +8 -9
- package/dist/typed/isPrimitive.js.map +1 -1
- package/dist/typed/isPromise.cjs +2 -2
- package/dist/typed/isPromise.cjs.map +1 -1
- package/dist/typed/isPromise.d.ts +17 -0
- package/dist/typed/isPromise.d.ts.map +1 -0
- package/dist/typed/isPromise.js +7 -9
- package/dist/typed/isPromise.js.map +1 -1
- package/dist/typed/isRegex.cjs +2 -2
- package/dist/typed/isRegex.cjs.map +1 -1
- package/dist/typed/isRegex.d.ts +21 -0
- package/dist/typed/isRegex.d.ts.map +1 -0
- package/dist/typed/isRegex.js +7 -6
- package/dist/typed/isRegex.js.map +1 -1
- package/dist/typed/isString.cjs +2 -2
- package/dist/typed/isString.cjs.map +1 -1
- package/dist/typed/isString.d.ts +16 -0
- package/dist/typed/isString.d.ts.map +1 -0
- package/dist/typed/isString.js +8 -8
- package/dist/typed/isString.js.map +1 -1
- package/dist/typed/isWithin.cjs +2 -2
- package/dist/typed/isWithin.cjs.map +1 -1
- package/dist/typed/isWithin.d.ts +20 -0
- package/dist/typed/isWithin.d.ts.map +1 -0
- package/dist/typed/isWithin.js +9 -9
- package/dist/typed/isWithin.js.map +1 -1
- package/dist/typed/isZero.cjs +2 -2
- package/dist/typed/isZero.cjs.map +1 -1
- package/dist/typed/isZero.d.ts +25 -0
- package/dist/typed/isZero.d.ts.map +1 -0
- package/dist/typed/isZero.js +7 -6
- package/dist/typed/isZero.js.map +1 -1
- package/dist/typed/typeOf.cjs +2 -2
- package/dist/typed/typeOf.cjs.map +1 -1
- package/dist/typed/typeOf.d.ts +30 -0
- package/dist/typed/typeOf.d.ts.map +1 -0
- package/dist/typed/typeOf.js +11 -13
- package/dist/typed/typeOf.js.map +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +77 -12
- package/dist/array/aggregate.cjs +0 -2
- package/dist/array/aggregate.cjs.map +0 -1
- package/dist/array/aggregate.js +0 -16
- package/dist/array/aggregate.js.map +0 -1
- package/dist/array/alternate.cjs +0 -2
- package/dist/array/alternate.cjs.map +0 -1
- package/dist/array/alternate.js +0 -9
- package/dist/array/alternate.js.map +0 -1
- package/dist/array/arrange.cjs +0 -2
- package/dist/array/arrange.cjs.map +0 -1
- package/dist/array/arrange.js +0 -6
- package/dist/array/arrange.js.map +0 -1
- package/dist/array/compact.cjs +0 -2
- package/dist/array/compact.cjs.map +0 -1
- package/dist/array/compact.js +0 -9
- package/dist/array/compact.js.map +0 -1
- package/dist/array/every.cjs +0 -2
- package/dist/array/every.cjs.map +0 -1
- package/dist/array/every.js +0 -14
- package/dist/array/every.js.map +0 -1
- package/dist/array/filter.cjs +0 -2
- package/dist/array/filter.cjs.map +0 -1
- package/dist/array/filter.js +0 -14
- package/dist/array/filter.js.map +0 -1
- package/dist/array/find.cjs +0 -2
- package/dist/array/find.cjs.map +0 -1
- package/dist/array/find.js +0 -14
- package/dist/array/find.js.map +0 -1
- package/dist/array/findIndex.cjs +0 -2
- package/dist/array/findIndex.cjs.map +0 -1
- package/dist/array/findIndex.js +0 -14
- package/dist/array/findIndex.js.map +0 -1
- package/dist/array/findLast.cjs +0 -2
- package/dist/array/findLast.cjs.map +0 -1
- package/dist/array/findLast.js +0 -14
- package/dist/array/findLast.js.map +0 -1
- package/dist/array/flatten.cjs +0 -2
- package/dist/array/flatten.cjs.map +0 -1
- package/dist/array/flatten.js +0 -7
- package/dist/array/flatten.js.map +0 -1
- package/dist/array/map.cjs +0 -2
- package/dist/array/map.cjs.map +0 -1
- package/dist/array/map.js +0 -18
- package/dist/array/map.js.map +0 -1
- package/dist/array/reduce.cjs +0 -2
- package/dist/array/reduce.cjs.map +0 -1
- package/dist/array/reduce.js +0 -16
- package/dist/array/reduce.js.map +0 -1
- package/dist/array/shift.cjs +0 -2
- package/dist/array/shift.cjs.map +0 -1
- package/dist/array/shift.js +0 -13
- package/dist/array/shift.js.map +0 -1
- package/dist/array/some.cjs +0 -2
- package/dist/array/some.cjs.map +0 -1
- package/dist/array/some.js +0 -14
- package/dist/array/some.js.map +0 -1
- package/dist/array/substitute.cjs +0 -2
- package/dist/array/substitute.cjs.map +0 -1
- package/dist/array/substitute.js +0 -13
- package/dist/array/substitute.js.map +0 -1
- package/dist/async/delay.cjs +0 -2
- package/dist/async/delay.cjs.map +0 -1
- package/dist/async/delay.js +0 -8
- package/dist/async/delay.js.map +0 -1
- package/dist/function/proxy.cjs +0 -2
- package/dist/function/proxy.cjs.map +0 -1
- package/dist/function/proxy.js +0 -22
- package/dist/function/proxy.js.map +0 -1
- package/dist/function/prune.cjs +0 -2
- package/dist/function/prune.cjs.map +0 -1
- package/dist/function/prune.js +0 -30
- package/dist/function/prune.js.map +0 -1
- package/dist/function/worker.cjs +0 -14
- package/dist/function/worker.cjs.map +0 -1
- package/dist/function/worker.js +0 -29
- package/dist/function/worker.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/logit/dist/logit.cjs +0 -2
- package/dist/logit/dist/logit.cjs.map +0 -1
- package/dist/logit/dist/logit.js +0 -263
- package/dist/logit/dist/logit.js.map +0 -1
- package/dist/math/add.cjs +0 -2
- package/dist/math/add.cjs.map +0 -1
- package/dist/math/add.js +0 -9
- package/dist/math/add.js.map +0 -1
- package/dist/math/boil.cjs +0 -2
- package/dist/math/boil.cjs.map +0 -1
- package/dist/math/boil.js +0 -17
- package/dist/math/boil.js.map +0 -1
- package/dist/math/divide.cjs +0 -2
- package/dist/math/divide.cjs.map +0 -1
- package/dist/math/divide.js +0 -11
- package/dist/math/divide.js.map +0 -1
- package/dist/math/multiply.cjs +0 -2
- package/dist/math/multiply.cjs.map +0 -1
- package/dist/math/multiply.js +0 -9
- package/dist/math/multiply.js.map +0 -1
- package/dist/math/rate.cjs +0 -2
- package/dist/math/rate.cjs.map +0 -1
- package/dist/math/rate.js +0 -9
- package/dist/math/rate.js.map +0 -1
- package/dist/math/subtract.cjs +0 -2
- package/dist/math/subtract.cjs.map +0 -1
- package/dist/math/subtract.js +0 -9
- package/dist/math/subtract.js.map +0 -1
- package/dist/object/cache.cjs +0 -2
- package/dist/object/cache.cjs.map +0 -1
- package/dist/object/cache.js +0 -63
- package/dist/object/cache.js.map +0 -1
- package/dist/object/clone.cjs +0 -2
- package/dist/object/clone.cjs.map +0 -1
- package/dist/object/clone.js +0 -17
- package/dist/object/clone.js.map +0 -1
- package/dist/object/entries.cjs +0 -2
- package/dist/object/entries.cjs.map +0 -1
- package/dist/object/entries.js +0 -9
- package/dist/object/entries.js.map +0 -1
- package/dist/object/keys.cjs +0 -2
- package/dist/object/keys.cjs.map +0 -1
- package/dist/object/keys.js +0 -9
- package/dist/object/keys.js.map +0 -1
- package/dist/object/values.cjs +0 -2
- package/dist/object/values.cjs.map +0 -1
- package/dist/object/values.js +0 -9
- package/dist/object/values.js.map +0 -1
- package/dist/typed/ge.cjs +0 -2
- package/dist/typed/ge.cjs.map +0 -1
- package/dist/typed/ge.js +0 -7
- package/dist/typed/ge.js.map +0 -1
- package/dist/typed/gt.cjs +0 -2
- package/dist/typed/gt.cjs.map +0 -1
- package/dist/typed/gt.js +0 -7
- package/dist/typed/gt.js.map +0 -1
- package/dist/typed/le.cjs +0 -2
- package/dist/typed/le.cjs.map +0 -1
- package/dist/typed/le.js +0 -7
- package/dist/typed/le.js.map +0 -1
- package/dist/typed/lt.cjs +0 -2
- package/dist/typed/lt.cjs.map +0 -1
- package/dist/typed/lt.js +0 -7
- package/dist/typed/lt.js.map +0 -1
package/dist/array/select.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","sources":["../../src/array/select.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"select.js","names":[],"sources":["../../src/array/select.ts"],"sourcesContent":["import type { Predicate } from '../types';\n\nimport { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport { isNil } from '../typed/isNil';\n\n/**\n * Selects elements from an array based on a callback function and an optional predicate function.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4];\n * select(arr, x => x * x, x => x > 2) // [9, 16]\n * select(arr, x => x * x) // [1, 4, 9, 16]\n * ```\n *\n * @param array - The array to select from.\n * @param callback - The function to map the values.\n * @param [predicate] - (optional) The function to filter the values.\n *\n * @returns A new array with the selected values.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function select<T, R>(\n array: T[],\n callback: (item: T, index: number, array: T[]) => R,\n predicate?: Predicate<T>,\n): R[] {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n const isValid = predicate ?? ((value: T) => !isNil(value));\n const result: R[] = [];\n\n for (let index = 0; index < array.length; index++) {\n if (isValid(array[index], index, array)) {\n result.push(callback(array[index], index, array));\n }\n }\n\n return result;\n}\n"],"mappings":";;;;AAwBA,SAAgB,EACd,GACA,GACA,GACK;AACL,GAAO,EAAQ,EAAM,EAAE,GAAoB;EAAE,MAAM,EAAE,UAAO;EAAE,MAAM;EAAW,CAAC;CAEhF,IAAM,IAAU,OAAe,MAAa,CAAC,EAAM,EAAM,GACnD,IAAc,EAAE;AAEtB,MAAK,IAAI,IAAQ,GAAG,IAAQ,EAAM,QAAQ,IACxC,CAAI,EAAQ,EAAM,IAAQ,GAAO,EAAM,IACrC,EAAO,KAAK,EAAS,EAAM,IAAQ,GAAO,EAAM,CAAC;AAIrD,QAAO"}
|
package/dist/array/sort.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=sort.cjs.map
|
|
1
|
+
const e=require(`../function/assert.cjs`),t=require(`../typed/isArray.cjs`),n=require(`../function/compare.cjs`),r=require(`../function/compareBy.cjs`);function i(i,a,o=`asc`){if(e.assert(t.isArray(i),t.IS_ARRAY_ERROR_MSG,{args:{array:i},type:TypeError}),typeof a==`function`){let e=o===`desc`?-1:1;return[...i].sort((t,r)=>n.compare(a(t),a(r))*e)}return[...i].sort(r.compareBy(a))}exports.sort=i;
|
|
2
|
+
//# sourceMappingURL=sort.cjs.map
|
package/dist/array/sort.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.cjs","sources":["../../src/array/sort.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { compare } from '../function/compare';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\n\n/**\n * Sorts an array
|
|
1
|
+
{"version":3,"file":"sort.cjs","names":[],"sources":["../../src/array/sort.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { compare } from '../function/compare';\nimport { compareBy } from '../function/compareBy';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\n\nexport type SortDirection = 'asc' | 'desc';\nexport type SortSelectors<T> = Partial<Record<keyof T, SortDirection>>;\n\n/**\n * Sorts an array by a selector function (single-field) or by a multi-field\n * object of `{ key: 'asc' | 'desc' }` entries.\n *\n * @example\n * ```ts\n * // Single field\n * sort([{ a: 2 }, { a: 1 }], item => item.a); // [{ a:1 }, { a:2 }]\n * sort([{ a: 2 }, { a: 1 }], item => item.a, 'desc'); // [{ a:2 }, { a:1 }]\n *\n * // Multi-field\n * sort(users, { name: 'asc', age: 'desc' });\n * ```\n *\n * @param array - The array to sort.\n * @param selector - A function extracting the sort key, or a multi-field object.\n * @param direction - `'asc'` (default) or `'desc'` — only applies to single-field mode.\n * @returns A new sorted array.\n *\n * @throws {TypeError} If the first argument is not an array.\n */\nexport function sort<T>(array: T[], selector: (item: T) => unknown, direction?: SortDirection): T[];\nexport function sort<T>(array: T[], selectors: SortSelectors<T>): T[];\nexport function sort<T>(\n array: T[],\n selectorOrSelectors: ((item: T) => unknown) | SortSelectors<T>,\n direction: SortDirection = 'asc',\n): T[] {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n if (typeof selectorOrSelectors === 'function') {\n const multiplier = direction === 'desc' ? -1 : 1;\n\n return [...array].sort((a, b) => compare(selectorOrSelectors(a), selectorOrSelectors(b)) * multiplier);\n }\n\n return [...array].sort(compareBy(selectorOrSelectors));\n}\n"],"mappings":"wJA+BA,SAAgB,EACd,EACA,EACA,EAA2B,MACtB,CAGL,GAFA,EAAA,OAAO,EAAA,QAAQ,EAAM,CAAE,EAAA,mBAAoB,CAAE,KAAM,CAAE,QAAO,CAAE,KAAM,UAAW,CAAC,CAE5E,OAAO,GAAwB,WAAY,CAC7C,IAAM,EAAa,IAAc,OAAS,GAAK,EAE/C,MAAO,CAAC,GAAG,EAAM,CAAC,MAAM,EAAG,IAAM,EAAA,QAAQ,EAAoB,EAAE,CAAE,EAAoB,EAAE,CAAC,CAAG,EAAW,CAGxG,MAAO,CAAC,GAAG,EAAM,CAAC,KAAK,EAAA,UAAU,EAAoB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type SortDirection = 'asc' | 'desc';
|
|
2
|
+
export type SortSelectors<T> = Partial<Record<keyof T, SortDirection>>;
|
|
3
|
+
/**
|
|
4
|
+
* Sorts an array by a selector function (single-field) or by a multi-field
|
|
5
|
+
* object of `{ key: 'asc' | 'desc' }` entries.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* // Single field
|
|
10
|
+
* sort([{ a: 2 }, { a: 1 }], item => item.a); // [{ a:1 }, { a:2 }]
|
|
11
|
+
* sort([{ a: 2 }, { a: 1 }], item => item.a, 'desc'); // [{ a:2 }, { a:1 }]
|
|
12
|
+
*
|
|
13
|
+
* // Multi-field
|
|
14
|
+
* sort(users, { name: 'asc', age: 'desc' });
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @param array - The array to sort.
|
|
18
|
+
* @param selector - A function extracting the sort key, or a multi-field object.
|
|
19
|
+
* @param direction - `'asc'` (default) or `'desc'` — only applies to single-field mode.
|
|
20
|
+
* @returns A new sorted array.
|
|
21
|
+
*
|
|
22
|
+
* @throws {TypeError} If the first argument is not an array.
|
|
23
|
+
*/
|
|
24
|
+
export declare function sort<T>(array: T[], selector: (item: T) => unknown, direction?: SortDirection): T[];
|
|
25
|
+
export declare function sort<T>(array: T[], selectors: SortSelectors<T>): T[];
|
|
26
|
+
//# sourceMappingURL=sort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../src/array/sort.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,CAAC;AAC3C,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,EAAE,SAAS,CAAC,EAAE,aAAa,GAAG,CAAC,EAAE,CAAC;AACpG,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC"}
|
package/dist/array/sort.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { assert as e } from "../function/assert.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
import { IS_ARRAY_ERROR_MSG as t, isArray as n } from "../typed/isArray.js";
|
|
3
|
+
import { compare as r } from "../function/compare.js";
|
|
4
|
+
import { compareBy as i } from "../function/compareBy.js";
|
|
5
|
+
//#region src/array/sort.ts
|
|
6
|
+
function a(a, o, s = "asc") {
|
|
7
|
+
if (e(n(a), t, {
|
|
8
|
+
args: { array: a },
|
|
9
|
+
type: TypeError
|
|
10
|
+
}), typeof o == "function") {
|
|
11
|
+
let e = s === "desc" ? -1 : 1;
|
|
12
|
+
return [...a].sort((t, n) => r(o(t), o(n)) * e);
|
|
13
|
+
}
|
|
14
|
+
return [...a].sort(i(o));
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { a as sort };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=sort.js.map
|
package/dist/array/sort.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.js","sources":["../../src/array/sort.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { compare } from '../function/compare';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\n\n/**\n * Sorts an array
|
|
1
|
+
{"version":3,"file":"sort.js","names":[],"sources":["../../src/array/sort.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { compare } from '../function/compare';\nimport { compareBy } from '../function/compareBy';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\n\nexport type SortDirection = 'asc' | 'desc';\nexport type SortSelectors<T> = Partial<Record<keyof T, SortDirection>>;\n\n/**\n * Sorts an array by a selector function (single-field) or by a multi-field\n * object of `{ key: 'asc' | 'desc' }` entries.\n *\n * @example\n * ```ts\n * // Single field\n * sort([{ a: 2 }, { a: 1 }], item => item.a); // [{ a:1 }, { a:2 }]\n * sort([{ a: 2 }, { a: 1 }], item => item.a, 'desc'); // [{ a:2 }, { a:1 }]\n *\n * // Multi-field\n * sort(users, { name: 'asc', age: 'desc' });\n * ```\n *\n * @param array - The array to sort.\n * @param selector - A function extracting the sort key, or a multi-field object.\n * @param direction - `'asc'` (default) or `'desc'` — only applies to single-field mode.\n * @returns A new sorted array.\n *\n * @throws {TypeError} If the first argument is not an array.\n */\nexport function sort<T>(array: T[], selector: (item: T) => unknown, direction?: SortDirection): T[];\nexport function sort<T>(array: T[], selectors: SortSelectors<T>): T[];\nexport function sort<T>(\n array: T[],\n selectorOrSelectors: ((item: T) => unknown) | SortSelectors<T>,\n direction: SortDirection = 'asc',\n): T[] {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n if (typeof selectorOrSelectors === 'function') {\n const multiplier = direction === 'desc' ? -1 : 1;\n\n return [...array].sort((a, b) => compare(selectorOrSelectors(a), selectorOrSelectors(b)) * multiplier);\n }\n\n return [...array].sort(compareBy(selectorOrSelectors));\n}\n"],"mappings":";;;;;AA+BA,SAAgB,EACd,GACA,GACA,IAA2B,OACtB;AAGL,KAFA,EAAO,EAAQ,EAAM,EAAE,GAAoB;EAAE,MAAM,EAAE,UAAO;EAAE,MAAM;EAAW,CAAC,EAE5E,OAAO,KAAwB,YAAY;EAC7C,IAAM,IAAa,MAAc,SAAS,KAAK;AAE/C,SAAO,CAAC,GAAG,EAAM,CAAC,MAAM,GAAG,MAAM,EAAQ,EAAoB,EAAE,EAAE,EAAoB,EAAE,CAAC,GAAG,EAAW;;AAGxG,QAAO,CAAC,GAAG,EAAM,CAAC,KAAK,EAAU,EAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggle.cjs","names":[],"sources":["../../src/array/toggle.ts"],"sourcesContent":["import type { Primitive } from '../types';\n\n/**\n * Either adds or removes an item from an array, based on whether it already\n * exists in the array (toggle behaviour).\n *\n * @example\n * ```ts\n * toggle([1, 2, 3], 4) // [1, 2, 3, 4]\n * toggle([1, 2, 3], 2) // [1, 3]\n *\n * toggle(\n * [{ id: 1 }, { id: 2 }],\n * { id: 3 },\n * (obj) => obj.id,\n * { strategy: 'prepend' }\n * ) // [{ id: 3 }, { id: 1 }, { id: 2 }]\n * ```\n *\n * @param array - The array to modify.\n * @param item - The item to add or remove.\n * @param selector - A function to determine item identity.\n * @param [options] - Options for the toggle operation.\n * @param [options.strategy] - Where to insert when adding: 'prepend' or 'append' (default).\n * @returns A new array with the item toggled.\n */\nexport function toggle<T>(\n array: T[],\n item: T,\n selector?: (item: T) => Primitive,\n options: { strategy?: 'prepend' | 'append' } = {},\n): T[] {\n const { strategy = 'append' } = options;\n const compareFn = selector ? (el: T) => selector(el) === selector(item) : (el: T) => el === item;\n\n const index = array.findIndex(compareFn);\n\n if (index !== -1) {\n return [...array.slice(0, index), ...array.slice(index + 1)];\n }\n\n return strategy === 'prepend' ? [item, ...array] : [...array, item];\n}\n"],"mappings":"AA0BA,SAAgB,EACd,EACA,EACA,EACA,EAA+C,EAAE,CAC5C,CACL,GAAM,CAAE,WAAW,UAAa,EAC1B,EAAY,EAAY,GAAU,EAAS,EAAG,GAAK,EAAS,EAAK,CAAI,GAAU,IAAO,EAEtF,EAAQ,EAAM,UAAU,EAAU,CAMxC,OAJI,IAAU,GAIP,IAAa,UAAY,CAAC,EAAM,GAAG,EAAM,CAAG,CAAC,GAAG,EAAO,EAAK,CAH1D,CAAC,GAAG,EAAM,MAAM,EAAG,EAAM,CAAE,GAAG,EAAM,MAAM,EAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Primitive } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Either adds or removes an item from an array, based on whether it already
|
|
4
|
+
* exists in the array (toggle behaviour).
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* toggle([1, 2, 3], 4) // [1, 2, 3, 4]
|
|
9
|
+
* toggle([1, 2, 3], 2) // [1, 3]
|
|
10
|
+
*
|
|
11
|
+
* toggle(
|
|
12
|
+
* [{ id: 1 }, { id: 2 }],
|
|
13
|
+
* { id: 3 },
|
|
14
|
+
* (obj) => obj.id,
|
|
15
|
+
* { strategy: 'prepend' }
|
|
16
|
+
* ) // [{ id: 3 }, { id: 1 }, { id: 2 }]
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param array - The array to modify.
|
|
20
|
+
* @param item - The item to add or remove.
|
|
21
|
+
* @param selector - A function to determine item identity.
|
|
22
|
+
* @param [options] - Options for the toggle operation.
|
|
23
|
+
* @param [options.strategy] - Where to insert when adding: 'prepend' or 'append' (default).
|
|
24
|
+
* @returns A new array with the item toggled.
|
|
25
|
+
*/
|
|
26
|
+
export declare function toggle<T>(array: T[], item: T, selector?: (item: T) => Primitive, options?: {
|
|
27
|
+
strategy?: 'prepend' | 'append';
|
|
28
|
+
}): T[];
|
|
29
|
+
//# sourceMappingURL=toggle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../../src/array/toggle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EACtB,KAAK,EAAE,CAAC,EAAE,EACV,IAAI,EAAE,CAAC,EACP,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,SAAS,EACjC,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;CAAO,GAChD,CAAC,EAAE,CAWL"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/array/toggle.ts
|
|
2
|
+
function e(e, t, n, r = {}) {
|
|
3
|
+
let { strategy: i = "append" } = r, a = n ? (e) => n(e) === n(t) : (e) => e === t, o = e.findIndex(a);
|
|
4
|
+
return o === -1 ? i === "prepend" ? [t, ...e] : [...e, t] : [...e.slice(0, o), ...e.slice(o + 1)];
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { e as toggle };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=toggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggle.js","names":[],"sources":["../../src/array/toggle.ts"],"sourcesContent":["import type { Primitive } from '../types';\n\n/**\n * Either adds or removes an item from an array, based on whether it already\n * exists in the array (toggle behaviour).\n *\n * @example\n * ```ts\n * toggle([1, 2, 3], 4) // [1, 2, 3, 4]\n * toggle([1, 2, 3], 2) // [1, 3]\n *\n * toggle(\n * [{ id: 1 }, { id: 2 }],\n * { id: 3 },\n * (obj) => obj.id,\n * { strategy: 'prepend' }\n * ) // [{ id: 3 }, { id: 1 }, { id: 2 }]\n * ```\n *\n * @param array - The array to modify.\n * @param item - The item to add or remove.\n * @param selector - A function to determine item identity.\n * @param [options] - Options for the toggle operation.\n * @param [options.strategy] - Where to insert when adding: 'prepend' or 'append' (default).\n * @returns A new array with the item toggled.\n */\nexport function toggle<T>(\n array: T[],\n item: T,\n selector?: (item: T) => Primitive,\n options: { strategy?: 'prepend' | 'append' } = {},\n): T[] {\n const { strategy = 'append' } = options;\n const compareFn = selector ? (el: T) => selector(el) === selector(item) : (el: T) => el === item;\n\n const index = array.findIndex(compareFn);\n\n if (index !== -1) {\n return [...array.slice(0, index), ...array.slice(index + 1)];\n }\n\n return strategy === 'prepend' ? [item, ...array] : [...array, item];\n}\n"],"mappings":";AA0BA,SAAgB,EACd,GACA,GACA,GACA,IAA+C,EAAE,EAC5C;CACL,IAAM,EAAE,cAAW,aAAa,GAC1B,IAAY,KAAY,MAAU,EAAS,EAAG,KAAK,EAAS,EAAK,IAAI,MAAU,MAAO,GAEtF,IAAQ,EAAM,UAAU,EAAU;AAMxC,QAJI,MAAU,KAIP,MAAa,YAAY,CAAC,GAAM,GAAG,EAAM,GAAG,CAAC,GAAG,GAAO,EAAK,GAH1D,CAAC,GAAG,EAAM,MAAM,GAAG,EAAM,EAAE,GAAG,EAAM,MAAM,IAAQ,EAAE,CAAC"}
|
package/dist/array/uniq.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=uniq.cjs.map
|
|
1
|
+
const e=require(`../function/assert.cjs`),t=require(`../typed/isArray.cjs`);function n(n,r){if(e.assert(t.isArray(n),t.IS_ARRAY_ERROR_MSG,{type:TypeError}),n.length<=1)return[...n];if(!r)return[...new Set(n)];let i=new Set,a=typeof r==`function`?r:e=>e[r];return n.filter(e=>{let t=a(e);return i.has(t)?!1:(i.add(t),!0)})}exports.uniq=n;
|
|
2
|
+
//# sourceMappingURL=uniq.cjs.map
|
package/dist/array/uniq.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniq.cjs","sources":["../../src/array/uniq.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"uniq.cjs","names":[],"sources":["../../src/array/uniq.ts"],"sourcesContent":["import type { Primitive, Selector } from '../types';\n\nimport { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\n\n/**\n * Creates a new array with duplicate values removed.\n *\n * @example\n * ```ts\n * uniq([1, 2, 2, 3, 3, 3]); // [1, 2, 3]\n * const arrObj = [{ id: 1 }, { id: 2 }, { id: 2 }, { id: 3 }, { id: 3 }, { id: 3 }];\n * uniq(arrObj, 'id'); // [{ id: 1 }, { id: 2 }, { id: 3 }]\n * uniq(arrObj, item => item.id); // [{ id: 1 }, { id: 2 }, { id: 3 }]\n * ```\n *\n * @param array - The array to process.\n * @param [selector] - The key(s) to compare objects or a function to generate comparison values.\n\n * @returns A new duplicate-free array.\n\n * @throws {TypeError} - If the input is not an array or if the key is invalid.\n */\nexport function uniq<T>(array: T[], selector?: Selector<T>): T[] {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { type: TypeError });\n\n if (array.length <= 1) {\n return [...array];\n }\n\n if (!selector) {\n return [...new Set(array)];\n }\n\n const seen = new Set<Primitive>();\n const getKey = typeof selector === 'function' ? selector : (item: T) => item[selector];\n\n return array.filter((item) => {\n const key = getKey(item) as Primitive;\n\n if (seen.has(key)) {\n return false;\n }\n\n seen.add(key);\n\n return true;\n });\n}\n"],"mappings":"4EAuBA,SAAgB,EAAQ,EAAY,EAA6B,CAG/D,GAFA,EAAA,OAAO,EAAA,QAAQ,EAAM,CAAE,EAAA,mBAAoB,CAAE,KAAM,UAAW,CAAC,CAE3D,EAAM,QAAU,EAClB,MAAO,CAAC,GAAG,EAAM,CAGnB,GAAI,CAAC,EACH,MAAO,CAAC,GAAG,IAAI,IAAI,EAAM,CAAC,CAG5B,IAAM,EAAO,IAAI,IACX,EAAS,OAAO,GAAa,WAAa,EAAY,GAAY,EAAK,GAE7E,OAAO,EAAM,OAAQ,GAAS,CAC5B,IAAM,EAAM,EAAO,EAAK,CAQxB,OANI,EAAK,IAAI,EAAI,CACR,IAGT,EAAK,IAAI,EAAI,CAEN,KACP"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Selector } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new array with duplicate values removed.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* uniq([1, 2, 2, 3, 3, 3]); // [1, 2, 3]
|
|
8
|
+
* const arrObj = [{ id: 1 }, { id: 2 }, { id: 2 }, { id: 3 }, { id: 3 }, { id: 3 }];
|
|
9
|
+
* uniq(arrObj, 'id'); // [{ id: 1 }, { id: 2 }, { id: 3 }]
|
|
10
|
+
* uniq(arrObj, item => item.id); // [{ id: 1 }, { id: 2 }, { id: 3 }]
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param array - The array to process.
|
|
14
|
+
* @param [selector] - The key(s) to compare objects or a function to generate comparison values.
|
|
15
|
+
|
|
16
|
+
* @returns A new duplicate-free array.
|
|
17
|
+
|
|
18
|
+
* @throws {TypeError} - If the input is not an array or if the key is invalid.
|
|
19
|
+
*/
|
|
20
|
+
export declare function uniq<T>(array: T[], selector?: Selector<T>): T[];
|
|
21
|
+
//# sourceMappingURL=uniq.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniq.d.ts","sourceRoot":"","sources":["../../src/array/uniq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKpD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAyB/D"}
|
package/dist/array/uniq.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { assert as
|
|
2
|
-
import { IS_ARRAY_ERROR_MSG as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
1
|
+
import { assert as e } from "../function/assert.js";
|
|
2
|
+
import { IS_ARRAY_ERROR_MSG as t, isArray as n } from "../typed/isArray.js";
|
|
3
|
+
//#region src/array/uniq.ts
|
|
4
|
+
function r(r, i) {
|
|
5
|
+
if (e(n(r), t, { type: TypeError }), r.length <= 1) return [...r];
|
|
6
|
+
if (!i) return [...new Set(r)];
|
|
7
|
+
let a = /* @__PURE__ */ new Set(), o = typeof i == "function" ? i : (e) => e[i];
|
|
8
|
+
return r.filter((e) => {
|
|
9
|
+
let t = o(e);
|
|
10
|
+
return a.has(t) ? !1 : (a.add(t), !0);
|
|
11
|
+
});
|
|
13
12
|
}
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
//# sourceMappingURL=uniq.js.map
|
|
13
|
+
//#endregion
|
|
14
|
+
export { r as uniq };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=uniq.js.map
|
package/dist/array/uniq.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniq.js","sources":["../../src/array/uniq.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"uniq.js","names":[],"sources":["../../src/array/uniq.ts"],"sourcesContent":["import type { Primitive, Selector } from '../types';\n\nimport { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\n\n/**\n * Creates a new array with duplicate values removed.\n *\n * @example\n * ```ts\n * uniq([1, 2, 2, 3, 3, 3]); // [1, 2, 3]\n * const arrObj = [{ id: 1 }, { id: 2 }, { id: 2 }, { id: 3 }, { id: 3 }, { id: 3 }];\n * uniq(arrObj, 'id'); // [{ id: 1 }, { id: 2 }, { id: 3 }]\n * uniq(arrObj, item => item.id); // [{ id: 1 }, { id: 2 }, { id: 3 }]\n * ```\n *\n * @param array - The array to process.\n * @param [selector] - The key(s) to compare objects or a function to generate comparison values.\n\n * @returns A new duplicate-free array.\n\n * @throws {TypeError} - If the input is not an array or if the key is invalid.\n */\nexport function uniq<T>(array: T[], selector?: Selector<T>): T[] {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { type: TypeError });\n\n if (array.length <= 1) {\n return [...array];\n }\n\n if (!selector) {\n return [...new Set(array)];\n }\n\n const seen = new Set<Primitive>();\n const getKey = typeof selector === 'function' ? selector : (item: T) => item[selector];\n\n return array.filter((item) => {\n const key = getKey(item) as Primitive;\n\n if (seen.has(key)) {\n return false;\n }\n\n seen.add(key);\n\n return true;\n });\n}\n"],"mappings":";;;AAuBA,SAAgB,EAAQ,GAAY,GAA6B;AAG/D,KAFA,EAAO,EAAQ,EAAM,EAAE,GAAoB,EAAE,MAAM,WAAW,CAAC,EAE3D,EAAM,UAAU,EAClB,QAAO,CAAC,GAAG,EAAM;AAGnB,KAAI,CAAC,EACH,QAAO,CAAC,GAAG,IAAI,IAAI,EAAM,CAAC;CAG5B,IAAM,oBAAO,IAAI,KAAgB,EAC3B,IAAS,OAAO,KAAa,aAAa,KAAY,MAAY,EAAK;AAE7E,QAAO,EAAM,QAAQ,MAAS;EAC5B,IAAM,IAAM,EAAO,EAAK;AAQxB,SANI,EAAK,IAAI,EAAI,GACR,MAGT,EAAK,IAAI,EAAI,EAEN;GACP"}
|
package/dist/async/attempt.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=attempt.cjs.map
|
|
1
|
+
const e=require(`./predict.cjs`),t=require(`./retry.cjs`);async function n(n,{onError:r,timeout:i=7e3,times:a=3}={}){try{return{ok:!0,value:await t.retry(()=>e.predict(()=>n(),{timeout:i}),{times:a})}}catch(e){return r?.(e),{error:e,ok:!1}}}exports.attempt=n;
|
|
2
|
+
//# sourceMappingURL=attempt.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attempt.cjs","sources":["../../src/async/attempt.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"attempt.cjs","names":[],"sources":["../../src/async/attempt.ts"],"sourcesContent":["import type { Fn } from '../types';\n\nimport { predict } from './predict';\nimport { retry } from './retry';\n\ntype AttemptOptions = {\n onError?: (err: unknown) => void;\n timeout?: number;\n times?: number;\n};\n\nexport type AttemptResult<R> = { ok: true; value: R } | { error: unknown; ok: false };\n\n/**\n * Attempts to execute a function with retry logic and an optional timeout.\n * Returns a discriminated union so callers can handle success and failure\n * explicitly without relying on `undefined`.\n *\n * @example\n * ```ts\n * const result = await attempt(fetchUser, { times: 3, timeout: 5000 });\n *\n * if (result.ok) {\n * console.log(result.value);\n * } else {\n * console.error(result.error);\n * }\n * ```\n *\n * @param fn - The function to be executed.\n * @param [options] - Configuration options.\n * @param [options.times=3] - Total number of attempts (including the first).\n * @param [options.onError] - Called with the error when all attempts fail.\n * @param [options.timeout=7000] - Per-attempt timeout in milliseconds.\n *\n * @returns `{ ok: true, value }` on success or `{ ok: false, error }` on failure.\n */\nexport async function attempt<T extends Fn, R = Awaited<ReturnType<T>>>(\n fn: T,\n { onError, timeout = 7000, times = 3 }: AttemptOptions = {},\n): Promise<AttemptResult<R>> {\n try {\n const value = await retry(() => predict<R>(() => fn(), { timeout }), { times });\n\n return { ok: true, value };\n } catch (err) {\n onError?.(err);\n\n return { error: err, ok: false };\n }\n}\n"],"mappings":"0DAqCA,eAAsB,EACpB,EACA,CAAE,UAAS,UAAU,IAAM,QAAQ,GAAsB,EAAE,CAChC,CAC3B,GAAI,CAGF,MAAO,CAAE,GAAI,GAAM,MAFL,MAAM,EAAA,UAAY,EAAA,YAAiB,GAAI,CAAE,CAAE,UAAS,CAAC,CAAE,CAAE,QAAO,CAAC,CAErD,OACnB,EAAK,CAGZ,OAFA,IAAU,EAAI,CAEP,CAAE,MAAO,EAAK,GAAI,GAAO"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Fn } from '../types';
|
|
2
|
+
type AttemptOptions = {
|
|
3
|
+
onError?: (err: unknown) => void;
|
|
4
|
+
timeout?: number;
|
|
5
|
+
times?: number;
|
|
6
|
+
};
|
|
7
|
+
export type AttemptResult<R> = {
|
|
8
|
+
ok: true;
|
|
9
|
+
value: R;
|
|
10
|
+
} | {
|
|
11
|
+
error: unknown;
|
|
12
|
+
ok: false;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Attempts to execute a function with retry logic and an optional timeout.
|
|
16
|
+
* Returns a discriminated union so callers can handle success and failure
|
|
17
|
+
* explicitly without relying on `undefined`.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const result = await attempt(fetchUser, { times: 3, timeout: 5000 });
|
|
22
|
+
*
|
|
23
|
+
* if (result.ok) {
|
|
24
|
+
* console.log(result.value);
|
|
25
|
+
* } else {
|
|
26
|
+
* console.error(result.error);
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @param fn - The function to be executed.
|
|
31
|
+
* @param [options] - Configuration options.
|
|
32
|
+
* @param [options.times=3] - Total number of attempts (including the first).
|
|
33
|
+
* @param [options.onError] - Called with the error when all attempts fail.
|
|
34
|
+
* @param [options.timeout=7000] - Per-attempt timeout in milliseconds.
|
|
35
|
+
*
|
|
36
|
+
* @returns `{ ok: true, value }` on success or `{ ok: false, error }` on failure.
|
|
37
|
+
*/
|
|
38
|
+
export declare function attempt<T extends Fn, R = Awaited<ReturnType<T>>>(fn: T, { onError, timeout, times }?: AttemptOptions): Promise<AttemptResult<R>>;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=attempt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attempt.d.ts","sourceRoot":"","sources":["../../src/async/attempt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAKnC,KAAK,cAAc,GAAG;IACpB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,KAAK,CAAA;CAAE,CAAC;AAEtF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EACpE,EAAE,EAAE,CAAC,EACL,EAAE,OAAO,EAAE,OAAc,EAAE,KAAS,EAAE,GAAE,cAAmB,GAC1D,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAU3B"}
|
package/dist/async/attempt.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
async function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { predict as e } from "./predict.js";
|
|
2
|
+
import { retry as t } from "./retry.js";
|
|
3
|
+
//#region src/async/attempt.ts
|
|
4
|
+
async function n(n, { onError: r, timeout: i = 7e3, times: a = 3 } = {}) {
|
|
5
|
+
try {
|
|
6
|
+
return {
|
|
7
|
+
ok: !0,
|
|
8
|
+
value: await t(() => e(() => n(), { timeout: i }), { times: a })
|
|
9
|
+
};
|
|
10
|
+
} catch (e) {
|
|
11
|
+
return r?.(e), {
|
|
12
|
+
error: e,
|
|
13
|
+
ok: !1
|
|
14
|
+
};
|
|
15
|
+
}
|
|
11
16
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=attempt.js.map
|
|
17
|
+
//#endregion
|
|
18
|
+
export { n as attempt };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=attempt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attempt.js","sources":["../../src/async/attempt.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"attempt.js","names":[],"sources":["../../src/async/attempt.ts"],"sourcesContent":["import type { Fn } from '../types';\n\nimport { predict } from './predict';\nimport { retry } from './retry';\n\ntype AttemptOptions = {\n onError?: (err: unknown) => void;\n timeout?: number;\n times?: number;\n};\n\nexport type AttemptResult<R> = { ok: true; value: R } | { error: unknown; ok: false };\n\n/**\n * Attempts to execute a function with retry logic and an optional timeout.\n * Returns a discriminated union so callers can handle success and failure\n * explicitly without relying on `undefined`.\n *\n * @example\n * ```ts\n * const result = await attempt(fetchUser, { times: 3, timeout: 5000 });\n *\n * if (result.ok) {\n * console.log(result.value);\n * } else {\n * console.error(result.error);\n * }\n * ```\n *\n * @param fn - The function to be executed.\n * @param [options] - Configuration options.\n * @param [options.times=3] - Total number of attempts (including the first).\n * @param [options.onError] - Called with the error when all attempts fail.\n * @param [options.timeout=7000] - Per-attempt timeout in milliseconds.\n *\n * @returns `{ ok: true, value }` on success or `{ ok: false, error }` on failure.\n */\nexport async function attempt<T extends Fn, R = Awaited<ReturnType<T>>>(\n fn: T,\n { onError, timeout = 7000, times = 3 }: AttemptOptions = {},\n): Promise<AttemptResult<R>> {\n try {\n const value = await retry(() => predict<R>(() => fn(), { timeout }), { times });\n\n return { ok: true, value };\n } catch (err) {\n onError?.(err);\n\n return { error: err, ok: false };\n }\n}\n"],"mappings":";;;AAqCA,eAAsB,EACpB,GACA,EAAE,YAAS,aAAU,KAAM,WAAQ,MAAsB,EAAE,EAChC;AAC3B,KAAI;AAGF,SAAO;GAAE,IAAI;GAAM,OAFL,MAAM,QAAY,QAAiB,GAAI,EAAE,EAAE,YAAS,CAAC,EAAE,EAAE,UAAO,CAAC;GAErD;UACnB,GAAK;AAGZ,SAFA,IAAU,EAAI,EAEP;GAAE,OAAO;GAAK,IAAI;GAAO"}
|
package/dist/async/defer.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=defer.cjs.map
|
|
1
|
+
function e(){let{promise:e,reject:t,resolve:n}=Promise.withResolvers();return{promise:e,reject:t,resolve:n}}exports.defer=e;
|
|
2
|
+
//# sourceMappingURL=defer.cjs.map
|
package/dist/async/defer.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defer.cjs","sources":["../../src/async/defer.ts"],"sourcesContent":["/**\n * Creates a deferred promise with resolve and reject methods exposed.\n * Useful for creating promises that are resolved/rejected externally.\n *\n * @example\n * ```ts\n * const deferred = defer<string>();\n *\n * setTimeout(() => {\n * deferred.resolve('Done!');\n * }, 1000);\n *\n * const result = await deferred.promise; // 'Done!'\n * ```\n *\n * @returns Object with promise and resolve/reject methods\n */\nexport function defer<T = void>(): {\n promise: Promise<T>;\n
|
|
1
|
+
{"version":3,"file":"defer.cjs","names":[],"sources":["../../src/async/defer.ts"],"sourcesContent":["/**\n * Creates a deferred promise with resolve and reject methods exposed.\n * Useful for creating promises that are resolved/rejected externally.\n *\n * @example\n * ```ts\n * const deferred = defer<string>();\n *\n * setTimeout(() => {\n * deferred.resolve('Done!');\n * }, 1000);\n *\n * const result = await deferred.promise; // 'Done!'\n * ```\n *\n * @returns Object with promise and resolve/reject methods\n */\nexport function defer<T = void>(): {\n promise: Promise<T>;\n reject: (reason?: unknown) => void;\n resolve: (value: T | PromiseLike<T>) => void;\n} {\n const { promise, reject, resolve } = Promise.withResolvers<T>();\n\n return { promise, reject, resolve };\n}\n"],"mappings":"AAiBA,SAAgB,GAId,CACA,GAAM,CAAE,UAAS,SAAQ,WAAY,QAAQ,eAAkB,CAE/D,MAAO,CAAE,UAAS,SAAQ,UAAS"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a deferred promise with resolve and reject methods exposed.
|
|
3
|
+
* Useful for creating promises that are resolved/rejected externally.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* const deferred = defer<string>();
|
|
8
|
+
*
|
|
9
|
+
* setTimeout(() => {
|
|
10
|
+
* deferred.resolve('Done!');
|
|
11
|
+
* }, 1000);
|
|
12
|
+
*
|
|
13
|
+
* const result = await deferred.promise; // 'Done!'
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @returns Object with promise and resolve/reject methods
|
|
17
|
+
*/
|
|
18
|
+
export declare function defer<T = void>(): {
|
|
19
|
+
promise: Promise<T>;
|
|
20
|
+
reject: (reason?: unknown) => void;
|
|
21
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=defer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defer.d.ts","sourceRoot":"","sources":["../../src/async/defer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,KAAK,CAAC,CAAC,GAAG,IAAI,KAAK;IACjC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;CAC9C,CAIA"}
|
package/dist/async/defer.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
//#region src/async/defer.ts
|
|
2
|
+
function e() {
|
|
3
|
+
let { promise: e, reject: t, resolve: n } = Promise.withResolvers();
|
|
4
|
+
return {
|
|
5
|
+
promise: e,
|
|
6
|
+
reject: t,
|
|
7
|
+
resolve: n
|
|
8
|
+
};
|
|
6
9
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=defer.js.map
|
|
10
|
+
//#endregion
|
|
11
|
+
export { e as defer };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=defer.js.map
|
package/dist/async/defer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defer.js","sources":["../../src/async/defer.ts"],"sourcesContent":["/**\n * Creates a deferred promise with resolve and reject methods exposed.\n * Useful for creating promises that are resolved/rejected externally.\n *\n * @example\n * ```ts\n * const deferred = defer<string>();\n *\n * setTimeout(() => {\n * deferred.resolve('Done!');\n * }, 1000);\n *\n * const result = await deferred.promise; // 'Done!'\n * ```\n *\n * @returns Object with promise and resolve/reject methods\n */\nexport function defer<T = void>(): {\n promise: Promise<T>;\n
|
|
1
|
+
{"version":3,"file":"defer.js","names":[],"sources":["../../src/async/defer.ts"],"sourcesContent":["/**\n * Creates a deferred promise with resolve and reject methods exposed.\n * Useful for creating promises that are resolved/rejected externally.\n *\n * @example\n * ```ts\n * const deferred = defer<string>();\n *\n * setTimeout(() => {\n * deferred.resolve('Done!');\n * }, 1000);\n *\n * const result = await deferred.promise; // 'Done!'\n * ```\n *\n * @returns Object with promise and resolve/reject methods\n */\nexport function defer<T = void>(): {\n promise: Promise<T>;\n reject: (reason?: unknown) => void;\n resolve: (value: T | PromiseLike<T>) => void;\n} {\n const { promise, reject, resolve } = Promise.withResolvers<T>();\n\n return { promise, reject, resolve };\n}\n"],"mappings":";AAiBA,SAAgB,IAId;CACA,IAAM,EAAE,YAAS,WAAQ,eAAY,QAAQ,eAAkB;AAE/D,QAAO;EAAE;EAAS;EAAQ;EAAS"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './attempt';
|
|
2
|
+
export * from './defer';
|
|
3
|
+
export * from './parallel';
|
|
4
|
+
export * from './pool';
|
|
5
|
+
export * from './predict';
|
|
6
|
+
export * from './queue';
|
|
7
|
+
export * from './race';
|
|
8
|
+
export * from './retry';
|
|
9
|
+
export * from './scheduler';
|
|
10
|
+
export * from './sleep';
|
|
11
|
+
export * from './waitFor';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/async/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC"}
|
package/dist/async/parallel.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=parallel.cjs.map
|
|
1
|
+
async function e(e,t,n,r){if(e<1)throw Error(`Limit must be at least 1`);if(r?.aborted)throw new DOMException(`Aborted`,`AbortError`);let i=Array(t.length),a=0,o=!1,s,c=async()=>{for(;a<t.length&&!o;){if(r?.aborted){o=!0,s=new DOMException(`Aborted`,`AbortError`);break}let e=a++;try{i[e]=await n(t[e],e,t)}catch(e){o=!0,s=e;break}}},l=[],u=Math.min(e,t.length);for(let e=0;e<u;e++)l.push(c());if(await Promise.all(l),o)throw s;return i}exports.parallel=e;
|
|
2
|
+
//# sourceMappingURL=parallel.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parallel.cjs","sources":["../../src/async/parallel.ts"],"sourcesContent":["/**\n * Processes an array with an async callback with controlled parallelism.\n * Similar to Promise.all, but limits how many items are processed concurrently.\n * Returns an ordered array of results.\n *\n * @example\n * ```ts\n * // Process 3 items at a time\n * const results = await parallel(3, [1, 2, 3, 4, 5], async (n) => {\n * await delay(100);\n * return n * 2;\n * });\n * // [2, 4, 6, 8, 10]\n *\n * // With abort signal\n * const controller = new AbortController();\n * const results = await parallel(2, items, async (item) => {\n * return processItem(item);\n * }, controller.signal);\n * ```\n *\n * @param limit - Maximum number of concurrent operations (must be >= 1)\n * @param array - Array of items to process\n * @param callback - Async function to process each item\n * @param signal - Optional AbortSignal to cancel processing\n * @returns Promise resolving to an ordered array of results\n * @throws {Error} If limit is less than 1\n * @throws {DOMException} If aborted via signal\n */\nexport async function parallel<T, R>(\n limit: number,\n array: T[],\n callback: (item: T, index: number, array: T[]) => Promise<R>,\n signal?: AbortSignal,\n): Promise<R[]> {\n if (limit < 1) {\n throw new Error('Limit must be at least 1');\n }\n\n if (signal?.aborted) {\n throw new DOMException('Aborted', 'AbortError');\n }\n\n const results: R[] = new Array(array.length);\n let currentIndex = 0;\n let hasError = false;\n let error: unknown;\n\n
|
|
1
|
+
{"version":3,"file":"parallel.cjs","names":[],"sources":["../../src/async/parallel.ts"],"sourcesContent":["/**\n * Processes an array with an async callback with controlled parallelism.\n * Similar to Promise.all, but limits how many items are processed concurrently.\n * Returns an ordered array of results.\n *\n * @example\n * ```ts\n * // Process 3 items at a time\n * const results = await parallel(3, [1, 2, 3, 4, 5], async (n) => {\n * await delay(100);\n * return n * 2;\n * });\n * // [2, 4, 6, 8, 10]\n *\n * // With abort signal\n * const controller = new AbortController();\n * const results = await parallel(2, items, async (item) => {\n * return processItem(item);\n * }, controller.signal);\n * ```\n *\n * @param limit - Maximum number of concurrent operations (must be >= 1)\n * @param array - Array of items to process\n * @param callback - Async function to process each item\n * @param signal - Optional AbortSignal to cancel processing\n * @returns Promise resolving to an ordered array of results\n * @throws {Error} If limit is less than 1\n * @throws {DOMException} If aborted via signal\n */\nexport async function parallel<T, R>(\n limit: number,\n array: T[],\n callback: (item: T, index: number, array: T[]) => Promise<R>,\n signal?: AbortSignal,\n): Promise<R[]> {\n if (limit < 1) {\n throw new Error('Limit must be at least 1');\n }\n\n if (signal?.aborted) {\n throw new DOMException('Aborted', 'AbortError');\n }\n\n const results: R[] = new Array(array.length);\n let currentIndex = 0;\n let hasError = false;\n let error: unknown;\n\n const worker = async (): Promise<void> => {\n while (currentIndex < array.length && !hasError) {\n if (signal?.aborted) {\n hasError = true;\n error = new DOMException('Aborted', 'AbortError');\n break;\n }\n\n const index = currentIndex++;\n\n try {\n results[index] = await callback(array[index], index, array);\n } catch (err) {\n hasError = true;\n error = err;\n break;\n }\n }\n };\n\n // Create workers up to the limit\n const workers: Promise<void>[] = [];\n const workerCount = Math.min(limit, array.length);\n\n for (let i = 0; i < workerCount; i++) {\n workers.push(worker());\n }\n\n // Wait for all workers to complete\n await Promise.all(workers);\n\n // If there was an error, throw it\n if (hasError) {\n throw error;\n }\n\n return results;\n}\n"],"mappings":"AA6BA,eAAsB,EACpB,EACA,EACA,EACA,EACc,CACd,GAAI,EAAQ,EACV,MAAU,MAAM,2BAA2B,CAG7C,GAAI,GAAQ,QACV,MAAM,IAAI,aAAa,UAAW,aAAa,CAGjD,IAAM,EAAmB,MAAM,EAAM,OAAO,CACxC,EAAe,EACf,EAAW,GACX,EAEE,EAAS,SAA2B,CACxC,KAAO,EAAe,EAAM,QAAU,CAAC,GAAU,CAC/C,GAAI,GAAQ,QAAS,CACnB,EAAW,GACX,EAAQ,IAAI,aAAa,UAAW,aAAa,CACjD,MAGF,IAAM,EAAQ,IAEd,GAAI,CACF,EAAQ,GAAS,MAAM,EAAS,EAAM,GAAQ,EAAO,EAAM,OACpD,EAAK,CACZ,EAAW,GACX,EAAQ,EACR,SAMA,EAA2B,EAAE,CAC7B,EAAc,KAAK,IAAI,EAAO,EAAM,OAAO,CAEjD,IAAK,IAAI,EAAI,EAAG,EAAI,EAAa,IAC/B,EAAQ,KAAK,GAAQ,CAAC,CAOxB,GAHA,MAAM,QAAQ,IAAI,EAAQ,CAGtB,EACF,MAAM,EAGR,OAAO"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Processes an array with an async callback with controlled parallelism.
|
|
3
|
+
* Similar to Promise.all, but limits how many items are processed concurrently.
|
|
4
|
+
* Returns an ordered array of results.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* // Process 3 items at a time
|
|
9
|
+
* const results = await parallel(3, [1, 2, 3, 4, 5], async (n) => {
|
|
10
|
+
* await delay(100);
|
|
11
|
+
* return n * 2;
|
|
12
|
+
* });
|
|
13
|
+
* // [2, 4, 6, 8, 10]
|
|
14
|
+
*
|
|
15
|
+
* // With abort signal
|
|
16
|
+
* const controller = new AbortController();
|
|
17
|
+
* const results = await parallel(2, items, async (item) => {
|
|
18
|
+
* return processItem(item);
|
|
19
|
+
* }, controller.signal);
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param limit - Maximum number of concurrent operations (must be >= 1)
|
|
23
|
+
* @param array - Array of items to process
|
|
24
|
+
* @param callback - Async function to process each item
|
|
25
|
+
* @param signal - Optional AbortSignal to cancel processing
|
|
26
|
+
* @returns Promise resolving to an ordered array of results
|
|
27
|
+
* @throws {Error} If limit is less than 1
|
|
28
|
+
* @throws {DOMException} If aborted via signal
|
|
29
|
+
*/
|
|
30
|
+
export declare function parallel<T, R>(limit: number, array: T[], callback: (item: T, index: number, array: T[]) => Promise<R>, signal?: AbortSignal): Promise<R[]>;
|
|
31
|
+
//# sourceMappingURL=parallel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallel.d.ts","sourceRoot":"","sources":["../../src/async/parallel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAAE,CAAC,EACjC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,CAAC,EAAE,EACV,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,EAC5D,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,CAAC,EAAE,CAAC,CAmDd"}
|