@vielzeug/toolkit 1.1.3 → 2.1.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/chunk.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=chunk.cjs.map
|
|
1
|
+
const e=require(`../function/assert.cjs`),t=require(`../typed/isArray.cjs`),n=require(`../typed/isString.cjs`);function r(r,i=2,a={}){e.assert(t.isArray(r)||n.isString(r),`Argument must be an array or string.`,{args:{input:r},type:TypeError}),e.assert(i>=1,`Chunk size must be at least 1.`,{args:{size:i},type:RangeError});let{overlap:o=!1,pad:s=` `}=a;if(n.isString(r)&&o){let e=s+r+s,t=e.length-i+1;return Array.from({length:t},(t,n)=>e.slice(n,n+i))}return Array.from({length:Math.ceil(r.length/i)},(e,t)=>r.slice(t*i,t*i+i))}exports.chunk=r;
|
|
2
|
+
//# sourceMappingURL=chunk.cjs.map
|
package/dist/array/chunk.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk.cjs","sources":["../../src/array/chunk.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { isArray } from '../typed/isArray';\nimport { isString } from '../typed/isString';\n\n// #region ChunkTypes\ntype ChunkOptions = {\n overlap?: boolean;\n pad?: string;\n};\n\ntype ChunkResult<T> = (T extends string ? string : T[])[];\n// #endregion ChunkTypes\n\n/**\n * Splits an array or string into chunks of a specified size.\n *\n * @example\n * ```ts\n * chunk([1, 2, 3, 4, 5], 2) // [[1, 2], [3, 4], [5]]\n * chunk(\"hello\", 2) // [\"he\", \"ll\", \"o\"]\n * chunk(\"hello\", 2, { overlap: true }) // [\" h\", \"he\", \"el\", \"ll\", \"lo\", \"o \"]\n * ```\n *\n * @param input - The input array or string to be chunked.\n * @param size - The size of each chunk.\n * @param [options] - Additional options for chunking.\n * @param [options.overlap] -\n * @param [options.pad] -\n *\n * @returns An array of chunks.\n *\n * @throws {RangeError} If the chunk size is invalid.\n * @throws {TypeError} If the input type is invalid.\n */\nexport function chunk<T>(input: T[] | string, size = 2, options: ChunkOptions = {}): ChunkResult<T> {\n assert(isArray(input as T[]) || isString(input), 'Argument must be an array or string.', {\n args: { input },\n type: TypeError,\n });\n\n assert(size >= 1, 'Chunk size must be at least 1.', {\n args: { size },\n type: RangeError,\n });\n\n const { overlap = false, pad = ' ' } = options;\n\n if (isString(input) && overlap) {\n const padded = pad + input + pad;\n const numChunks = padded.length - size + 1;\n return Array.from({ length: numChunks }, (_, i) => padded.slice(i, i + size)) as ChunkResult<T>;\n }\n\n return Array.from({ length: Math.ceil(input.length / size) }, (_, i) =>\n input.slice(i * size, i * size + size),\n ) as ChunkResult<T>;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"chunk.cjs","names":[],"sources":["../../src/array/chunk.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { isArray } from '../typed/isArray';\nimport { isString } from '../typed/isString';\n\n// #region ChunkTypes\ntype ChunkOptions = {\n overlap?: boolean;\n pad?: string;\n};\n\ntype ChunkResult<T> = (T extends string ? string : T[])[];\n// #endregion ChunkTypes\n\n/**\n * Splits an array or string into chunks of a specified size.\n *\n * @example\n * ```ts\n * chunk([1, 2, 3, 4, 5], 2) // [[1, 2], [3, 4], [5]]\n * chunk(\"hello\", 2) // [\"he\", \"ll\", \"o\"]\n * chunk(\"hello\", 2, { overlap: true }) // [\" h\", \"he\", \"el\", \"ll\", \"lo\", \"o \"]\n * ```\n *\n * @param input - The input array or string to be chunked.\n * @param size - The size of each chunk.\n * @param [options] - Additional options for chunking.\n * @param [options.overlap] -\n * @param [options.pad] -\n *\n * @returns An array of chunks.\n *\n * @throws {RangeError} If the chunk size is invalid.\n * @throws {TypeError} If the input type is invalid.\n */\nexport function chunk<T>(input: T[] | string, size = 2, options: ChunkOptions = {}): ChunkResult<T> {\n assert(isArray(input as T[]) || isString(input), 'Argument must be an array or string.', {\n args: { input },\n type: TypeError,\n });\n\n assert(size >= 1, 'Chunk size must be at least 1.', {\n args: { size },\n type: RangeError,\n });\n\n const { overlap = false, pad = ' ' } = options;\n\n if (isString(input) && overlap) {\n const padded = pad + input + pad;\n const numChunks = padded.length - size + 1;\n\n return Array.from({ length: numChunks }, (_, i) => padded.slice(i, i + size)) as ChunkResult<T>;\n }\n\n return Array.from({ length: Math.ceil(input.length / size) }, (_, i) =>\n input.slice(i * size, i * size + size),\n ) as ChunkResult<T>;\n}\n"],"mappings":"+GAkCA,SAAgB,EAAS,EAAqB,EAAO,EAAG,EAAwB,EAAE,CAAkB,CAClG,EAAA,OAAO,EAAA,QAAQ,EAAa,EAAI,EAAA,SAAS,EAAM,CAAE,uCAAwC,CACvF,KAAM,CAAE,QAAO,CACf,KAAM,UACP,CAAC,CAEF,EAAA,OAAO,GAAQ,EAAG,iCAAkC,CAClD,KAAM,CAAE,OAAM,CACd,KAAM,WACP,CAAC,CAEF,GAAM,CAAE,UAAU,GAAO,MAAM,KAAQ,EAEvC,GAAI,EAAA,SAAS,EAAM,EAAI,EAAS,CAC9B,IAAM,EAAS,EAAM,EAAQ,EACvB,EAAY,EAAO,OAAS,EAAO,EAEzC,OAAO,MAAM,KAAK,CAAE,OAAQ,EAAW,EAAG,EAAG,IAAM,EAAO,MAAM,EAAG,EAAI,EAAK,CAAC,CAG/E,OAAO,MAAM,KAAK,CAAE,OAAQ,KAAK,KAAK,EAAM,OAAS,EAAK,CAAE,EAAG,EAAG,IAChE,EAAM,MAAM,EAAI,EAAM,EAAI,EAAO,EAAK,CACvC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type ChunkOptions = {
|
|
2
|
+
overlap?: boolean;
|
|
3
|
+
pad?: string;
|
|
4
|
+
};
|
|
5
|
+
type ChunkResult<T> = (T extends string ? string : T[])[];
|
|
6
|
+
/**
|
|
7
|
+
* Splits an array or string into chunks of a specified size.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* chunk([1, 2, 3, 4, 5], 2) // [[1, 2], [3, 4], [5]]
|
|
12
|
+
* chunk("hello", 2) // ["he", "ll", "o"]
|
|
13
|
+
* chunk("hello", 2, { overlap: true }) // [" h", "he", "el", "ll", "lo", "o "]
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param input - The input array or string to be chunked.
|
|
17
|
+
* @param size - The size of each chunk.
|
|
18
|
+
* @param [options] - Additional options for chunking.
|
|
19
|
+
* @param [options.overlap] -
|
|
20
|
+
* @param [options.pad] -
|
|
21
|
+
*
|
|
22
|
+
* @returns An array of chunks.
|
|
23
|
+
*
|
|
24
|
+
* @throws {RangeError} If the chunk size is invalid.
|
|
25
|
+
* @throws {TypeError} If the input type is invalid.
|
|
26
|
+
*/
|
|
27
|
+
export declare function chunk<T>(input: T[] | string, size?: number, options?: ChunkOptions): ChunkResult<T>;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=chunk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../../src/array/chunk.ts"],"names":[],"mappings":"AAKA,KAAK,YAAY,GAAG;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;AAG1D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,IAAI,SAAI,EAAE,OAAO,GAAE,YAAiB,GAAG,WAAW,CAAC,CAAC,CAAC,CAuBlG"}
|
package/dist/array/chunk.js
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
import { assert as
|
|
2
|
-
import { isArray as
|
|
3
|
-
import { isString as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
(o, a) => t.slice(a * r, a * r + r)
|
|
20
|
-
);
|
|
1
|
+
import { assert as e } from "../function/assert.js";
|
|
2
|
+
import { isArray as t } from "../typed/isArray.js";
|
|
3
|
+
import { isString as n } from "../typed/isString.js";
|
|
4
|
+
//#region src/array/chunk.ts
|
|
5
|
+
function r(r, i = 2, a = {}) {
|
|
6
|
+
e(t(r) || n(r), "Argument must be an array or string.", {
|
|
7
|
+
args: { input: r },
|
|
8
|
+
type: TypeError
|
|
9
|
+
}), e(i >= 1, "Chunk size must be at least 1.", {
|
|
10
|
+
args: { size: i },
|
|
11
|
+
type: RangeError
|
|
12
|
+
});
|
|
13
|
+
let { overlap: o = !1, pad: s = " " } = a;
|
|
14
|
+
if (n(r) && o) {
|
|
15
|
+
let e = s + r + s, t = e.length - i + 1;
|
|
16
|
+
return Array.from({ length: t }, (t, n) => e.slice(n, n + i));
|
|
17
|
+
}
|
|
18
|
+
return Array.from({ length: Math.ceil(r.length / i) }, (e, t) => r.slice(t * i, t * i + i));
|
|
21
19
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
//# sourceMappingURL=chunk.js.map
|
|
20
|
+
//#endregion
|
|
21
|
+
export { r as chunk };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=chunk.js.map
|
package/dist/array/chunk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk.js","sources":["../../src/array/chunk.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { isArray } from '../typed/isArray';\nimport { isString } from '../typed/isString';\n\n// #region ChunkTypes\ntype ChunkOptions = {\n overlap?: boolean;\n pad?: string;\n};\n\ntype ChunkResult<T> = (T extends string ? string : T[])[];\n// #endregion ChunkTypes\n\n/**\n * Splits an array or string into chunks of a specified size.\n *\n * @example\n * ```ts\n * chunk([1, 2, 3, 4, 5], 2) // [[1, 2], [3, 4], [5]]\n * chunk(\"hello\", 2) // [\"he\", \"ll\", \"o\"]\n * chunk(\"hello\", 2, { overlap: true }) // [\" h\", \"he\", \"el\", \"ll\", \"lo\", \"o \"]\n * ```\n *\n * @param input - The input array or string to be chunked.\n * @param size - The size of each chunk.\n * @param [options] - Additional options for chunking.\n * @param [options.overlap] -\n * @param [options.pad] -\n *\n * @returns An array of chunks.\n *\n * @throws {RangeError} If the chunk size is invalid.\n * @throws {TypeError} If the input type is invalid.\n */\nexport function chunk<T>(input: T[] | string, size = 2, options: ChunkOptions = {}): ChunkResult<T> {\n assert(isArray(input as T[]) || isString(input), 'Argument must be an array or string.', {\n args: { input },\n type: TypeError,\n });\n\n assert(size >= 1, 'Chunk size must be at least 1.', {\n args: { size },\n type: RangeError,\n });\n\n const { overlap = false, pad = ' ' } = options;\n\n if (isString(input) && overlap) {\n const padded = pad + input + pad;\n const numChunks = padded.length - size + 1;\n return Array.from({ length: numChunks }, (_, i) => padded.slice(i, i + size)) as ChunkResult<T>;\n }\n\n return Array.from({ length: Math.ceil(input.length / size) }, (_, i) =>\n input.slice(i * size, i * size + size),\n ) as ChunkResult<T>;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"chunk.js","names":[],"sources":["../../src/array/chunk.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { isArray } from '../typed/isArray';\nimport { isString } from '../typed/isString';\n\n// #region ChunkTypes\ntype ChunkOptions = {\n overlap?: boolean;\n pad?: string;\n};\n\ntype ChunkResult<T> = (T extends string ? string : T[])[];\n// #endregion ChunkTypes\n\n/**\n * Splits an array or string into chunks of a specified size.\n *\n * @example\n * ```ts\n * chunk([1, 2, 3, 4, 5], 2) // [[1, 2], [3, 4], [5]]\n * chunk(\"hello\", 2) // [\"he\", \"ll\", \"o\"]\n * chunk(\"hello\", 2, { overlap: true }) // [\" h\", \"he\", \"el\", \"ll\", \"lo\", \"o \"]\n * ```\n *\n * @param input - The input array or string to be chunked.\n * @param size - The size of each chunk.\n * @param [options] - Additional options for chunking.\n * @param [options.overlap] -\n * @param [options.pad] -\n *\n * @returns An array of chunks.\n *\n * @throws {RangeError} If the chunk size is invalid.\n * @throws {TypeError} If the input type is invalid.\n */\nexport function chunk<T>(input: T[] | string, size = 2, options: ChunkOptions = {}): ChunkResult<T> {\n assert(isArray(input as T[]) || isString(input), 'Argument must be an array or string.', {\n args: { input },\n type: TypeError,\n });\n\n assert(size >= 1, 'Chunk size must be at least 1.', {\n args: { size },\n type: RangeError,\n });\n\n const { overlap = false, pad = ' ' } = options;\n\n if (isString(input) && overlap) {\n const padded = pad + input + pad;\n const numChunks = padded.length - size + 1;\n\n return Array.from({ length: numChunks }, (_, i) => padded.slice(i, i + size)) as ChunkResult<T>;\n }\n\n return Array.from({ length: Math.ceil(input.length / size) }, (_, i) =>\n input.slice(i * size, i * size + size),\n ) as ChunkResult<T>;\n}\n"],"mappings":";;;;AAkCA,SAAgB,EAAS,GAAqB,IAAO,GAAG,IAAwB,EAAE,EAAkB;AAMlG,CALA,EAAO,EAAQ,EAAa,IAAI,EAAS,EAAM,EAAE,wCAAwC;EACvF,MAAM,EAAE,UAAO;EACf,MAAM;EACP,CAAC,EAEF,EAAO,KAAQ,GAAG,kCAAkC;EAClD,MAAM,EAAE,SAAM;EACd,MAAM;EACP,CAAC;CAEF,IAAM,EAAE,aAAU,IAAO,SAAM,QAAQ;AAEvC,KAAI,EAAS,EAAM,IAAI,GAAS;EAC9B,IAAM,IAAS,IAAM,IAAQ,GACvB,IAAY,EAAO,SAAS,IAAO;AAEzC,SAAO,MAAM,KAAK,EAAE,QAAQ,GAAW,GAAG,GAAG,MAAM,EAAO,MAAM,GAAG,IAAI,EAAK,CAAC;;AAG/E,QAAO,MAAM,KAAK,EAAE,QAAQ,KAAK,KAAK,EAAM,SAAS,EAAK,EAAE,GAAG,GAAG,MAChE,EAAM,MAAM,IAAI,GAAM,IAAI,IAAO,EAAK,CACvC"}
|
package/dist/array/contains.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=contains.cjs.map
|
|
1
|
+
const e=require(`../function/assert.cjs`),t=require(`../typed/isArray.cjs`),n=require(`../typed/isEqual.cjs`);function r(r,i){return e.assert(t.isArray(r),t.IS_ARRAY_ERROR_MSG,{args:{array:r},type:TypeError}),r.some(e=>n.isEqual(e,i))}exports.contains=r;
|
|
2
|
+
//# sourceMappingURL=contains.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contains.cjs","sources":["../../src/array/contains.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport { isEqual } from '../typed/isEqual';\n\n/**\n * Checks if a value is present in an array.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, { a: 1 }, 'hello'];\n * const value = { a: 1 };\n * contains(arr, value) // true;\n * ```\n *\n * @param array - The array to check.\n * @param value - The value to search for.\n *\n * @returns true if the value is present in the array, else false.\n *\n * @throws {TypeError} If the first argument is not an array.\n */\n\
|
|
1
|
+
{"version":3,"file":"contains.cjs","names":[],"sources":["../../src/array/contains.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport { isEqual } from '../typed/isEqual';\n\n/**\n * Checks if a value is present in an array.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, { a: 1 }, 'hello'];\n * const value = { a: 1 };\n * contains(arr, value) // true;\n * ```\n *\n * @param array - The array to check.\n * @param value - The value to search for.\n *\n * @returns true if the value is present in the array, else false.\n *\n * @throws {TypeError} If the first argument is not an array.\n */\n\nexport function contains<T>(array: T[], value: unknown): boolean {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n return array.some((val) => isEqual(val, value));\n}\n"],"mappings":"8GAsBA,SAAgB,EAAY,EAAY,EAAyB,CAG/D,OAFA,EAAA,OAAO,EAAA,QAAQ,EAAM,CAAE,EAAA,mBAAoB,CAAE,KAAM,CAAE,QAAO,CAAE,KAAM,UAAW,CAAC,CAEzE,EAAM,KAAM,GAAQ,EAAA,QAAQ,EAAK,EAAM,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a value is present in an array.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* const arr = [1, 2, 3, { a: 1 }, 'hello'];
|
|
7
|
+
* const value = { a: 1 };
|
|
8
|
+
* contains(arr, value) // true;
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @param array - The array to check.
|
|
12
|
+
* @param value - The value to search for.
|
|
13
|
+
*
|
|
14
|
+
* @returns true if the value is present in the array, else false.
|
|
15
|
+
*
|
|
16
|
+
* @throws {TypeError} If the first argument is not an array.
|
|
17
|
+
*/
|
|
18
|
+
export declare function contains<T>(array: T[], value: unknown): boolean;
|
|
19
|
+
//# sourceMappingURL=contains.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contains.d.ts","sourceRoot":"","sources":["../../src/array/contains.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAI/D"}
|
package/dist/array/contains.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { assert as e } from "../function/assert.js";
|
|
2
|
-
import { IS_ARRAY_ERROR_MSG as
|
|
3
|
-
import { isEqual as
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { IS_ARRAY_ERROR_MSG as t, isArray as n } from "../typed/isArray.js";
|
|
3
|
+
import { isEqual as r } from "../typed/isEqual.js";
|
|
4
|
+
//#region src/array/contains.ts
|
|
5
|
+
function i(i, a) {
|
|
6
|
+
return e(n(i), t, {
|
|
7
|
+
args: { array: i },
|
|
8
|
+
type: TypeError
|
|
9
|
+
}), i.some((e) => r(e, a));
|
|
6
10
|
}
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=contains.js.map
|
|
11
|
+
//#endregion
|
|
12
|
+
export { i as contains };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=contains.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contains.js","sources":["../../src/array/contains.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport { isEqual } from '../typed/isEqual';\n\n/**\n * Checks if a value is present in an array.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, { a: 1 }, 'hello'];\n * const value = { a: 1 };\n * contains(arr, value) // true;\n * ```\n *\n * @param array - The array to check.\n * @param value - The value to search for.\n *\n * @returns true if the value is present in the array, else false.\n *\n * @throws {TypeError} If the first argument is not an array.\n */\n\
|
|
1
|
+
{"version":3,"file":"contains.js","names":[],"sources":["../../src/array/contains.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\nimport { isEqual } from '../typed/isEqual';\n\n/**\n * Checks if a value is present in an array.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, { a: 1 }, 'hello'];\n * const value = { a: 1 };\n * contains(arr, value) // true;\n * ```\n *\n * @param array - The array to check.\n * @param value - The value to search for.\n *\n * @returns true if the value is present in the array, else false.\n *\n * @throws {TypeError} If the first argument is not an array.\n */\n\nexport function contains<T>(array: T[], value: unknown): boolean {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n return array.some((val) => isEqual(val, value));\n}\n"],"mappings":";;;;AAsBA,SAAgB,EAAY,GAAY,GAAyB;AAG/D,QAFA,EAAO,EAAQ,EAAM,EAAE,GAAoB;EAAE,MAAM,EAAE,UAAO;EAAE,MAAM;EAAW,CAAC,EAEzE,EAAM,MAAM,MAAQ,EAAQ,GAAK,EAAM,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require(`../function/assert.cjs`),t=require(`../typed/isArray.cjs`);function n(n,r){e.assert(t.isArray(n),t.IS_ARRAY_ERROR_MSG,{args:{array:n,callback:r},type:TypeError});let i=n[0];for(let e=1;e<n.length;e++)i=r(i,n[e]);return i}exports.fold=n;
|
|
2
|
+
//# sourceMappingURL=fold.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fold.cjs","names":[],"sources":["../../src/array/fold.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\n\n/**\n * Folds an array down to a single value by applying a callback to each pair of\n * elements (reduce without an initial value).\n *\n * @example\n * ```ts\n * fold([1, 2, 3], (a, b) => a + b) // 6\n * fold([1, 2, 3], (a, b) => a > b ? a : b) // 3\n * fold([{ a: 1 }, { a: 2 }], (a, b) => ({ a: a.a + b.a })) // { a: 3 }\n * fold([], (a, b) => a + b) // undefined\n * fold([1], (a, b) => a + b) // 1\n * ```\n *\n * @param array - The array to fold.\n * @param callback - The function to invoke for each pair of elements.\n * @returns The folded value, or `undefined` if the array is empty.\n *\n * @throws {TypeError} If the first argument is not an array.\n */\nexport function fold<T>(array: readonly T[], callback: (a: T, b: T) => T): T | undefined {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, {\n args: { array, callback },\n type: TypeError,\n });\n\n let result = array[0];\n\n for (let i = 1; i < array.length; i++) {\n result = callback(result, array[i]);\n }\n\n return result;\n}\n"],"mappings":"4EAsBA,SAAgB,EAAQ,EAAqB,EAA4C,CACvF,EAAA,OAAO,EAAA,QAAQ,EAAM,CAAE,EAAA,mBAAoB,CACzC,KAAM,CAAE,QAAO,WAAU,CACzB,KAAM,UACP,CAAC,CAEF,IAAI,EAAS,EAAM,GAEnB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAQ,IAChC,EAAS,EAAS,EAAQ,EAAM,GAAG,CAGrC,OAAO"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Folds an array down to a single value by applying a callback to each pair of
|
|
3
|
+
* elements (reduce without an initial value).
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* fold([1, 2, 3], (a, b) => a + b) // 6
|
|
8
|
+
* fold([1, 2, 3], (a, b) => a > b ? a : b) // 3
|
|
9
|
+
* fold([{ a: 1 }, { a: 2 }], (a, b) => ({ a: a.a + b.a })) // { a: 3 }
|
|
10
|
+
* fold([], (a, b) => a + b) // undefined
|
|
11
|
+
* fold([1], (a, b) => a + b) // 1
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @param array - The array to fold.
|
|
15
|
+
* @param callback - The function to invoke for each pair of elements.
|
|
16
|
+
* @returns The folded value, or `undefined` if the array is empty.
|
|
17
|
+
*
|
|
18
|
+
* @throws {TypeError} If the first argument is not an array.
|
|
19
|
+
*/
|
|
20
|
+
export declare function fold<T>(array: readonly T[], callback: (a: T, b: T) => T): T | undefined;
|
|
21
|
+
//# sourceMappingURL=fold.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fold.d.ts","sourceRoot":"","sources":["../../src/array/fold.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAavF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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/fold.ts
|
|
4
|
+
function r(r, i) {
|
|
5
|
+
e(n(r), t, {
|
|
6
|
+
args: {
|
|
7
|
+
array: r,
|
|
8
|
+
callback: i
|
|
9
|
+
},
|
|
10
|
+
type: TypeError
|
|
11
|
+
});
|
|
12
|
+
let a = r[0];
|
|
13
|
+
for (let e = 1; e < r.length; e++) a = i(a, r[e]);
|
|
14
|
+
return a;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { r as fold };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=fold.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fold.js","names":[],"sources":["../../src/array/fold.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\n\n/**\n * Folds an array down to a single value by applying a callback to each pair of\n * elements (reduce without an initial value).\n *\n * @example\n * ```ts\n * fold([1, 2, 3], (a, b) => a + b) // 6\n * fold([1, 2, 3], (a, b) => a > b ? a : b) // 3\n * fold([{ a: 1 }, { a: 2 }], (a, b) => ({ a: a.a + b.a })) // { a: 3 }\n * fold([], (a, b) => a + b) // undefined\n * fold([1], (a, b) => a + b) // 1\n * ```\n *\n * @param array - The array to fold.\n * @param callback - The function to invoke for each pair of elements.\n * @returns The folded value, or `undefined` if the array is empty.\n *\n * @throws {TypeError} If the first argument is not an array.\n */\nexport function fold<T>(array: readonly T[], callback: (a: T, b: T) => T): T | undefined {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, {\n args: { array, callback },\n type: TypeError,\n });\n\n let result = array[0];\n\n for (let i = 1; i < array.length; i++) {\n result = callback(result, array[i]);\n }\n\n return result;\n}\n"],"mappings":";;;AAsBA,SAAgB,EAAQ,GAAqB,GAA4C;AACvF,GAAO,EAAQ,EAAM,EAAE,GAAoB;EACzC,MAAM;GAAE;GAAO;GAAU;EACzB,MAAM;EACP,CAAC;CAEF,IAAI,IAAS,EAAM;AAEnB,MAAK,IAAI,IAAI,GAAG,IAAI,EAAM,QAAQ,IAChC,KAAS,EAAS,GAAQ,EAAM,GAAG;AAGrC,QAAO"}
|
package/dist/array/group.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=group.cjs.map
|
|
1
|
+
const e=require(`../function/assert.cjs`),t=require(`../typed/isArray.cjs`);function n(n,r){e.assert(t.isArray(n),t.IS_ARRAY_ERROR_MSG,{args:{array:n},type:TypeError});let i={},a=typeof r==`function`?r:e=>e[r];for(let e of n){let t=a(e),n=t==null?`_`:String(t);i[n]||(i[n]=[]),i[n].push(e)}return i}exports.group=n;
|
|
2
|
+
//# sourceMappingURL=group.cjs.map
|
package/dist/array/group.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.cjs","sources":["../../src/array/group.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"group.cjs","names":[],"sources":["../../src/array/group.ts"],"sourcesContent":["import type { Selector } from '../types';\n\nimport { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\n\n/**\n * Groups the elements of an array based on the given key.\n *\n * @example\n * ```ts\n * const data = [{ a: 2 }, { a: 1 }];\n * group(data, 'a') // { '2': [{ a: 2 }], '1': [{ a: 1 }] };\n * ```\n *\n * @param array - The array to group.\n * @param selector - The function to generate the key for each element. It can be a string representing the key or a function that returns the key.\n *\n * @returns an object with keys as the grouped values and values as arrays of elements.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function group<T>(array: T[], selector: Selector<T>): Record<string, T[]> {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n const result: Record<string, T[]> = {};\n const getKey = typeof selector === 'function' ? selector : (item: T) => item[selector];\n\n for (const item of array) {\n const rawKey = getKey(item);\n const key = rawKey === undefined || rawKey === null ? '_' : String(rawKey);\n\n if (!result[key]) {\n result[key] = [];\n }\n\n result[key].push(item);\n }\n\n return result;\n}\n"],"mappings":"4EAqBA,SAAgB,EAAS,EAAY,EAA4C,CAC/E,EAAA,OAAO,EAAA,QAAQ,EAAM,CAAE,EAAA,mBAAoB,CAAE,KAAM,CAAE,QAAO,CAAE,KAAM,UAAW,CAAC,CAEhF,IAAM,EAA8B,EAAE,CAChC,EAAS,OAAO,GAAa,WAAa,EAAY,GAAY,EAAK,GAE7E,IAAK,IAAM,KAAQ,EAAO,CACxB,IAAM,EAAS,EAAO,EAAK,CACrB,EAAM,GAAmC,KAAO,IAAM,OAAO,EAAO,CAErE,EAAO,KACV,EAAO,GAAO,EAAE,EAGlB,EAAO,GAAK,KAAK,EAAK,CAGxB,OAAO"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Selector } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Groups the elements of an array based on the given key.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* const data = [{ a: 2 }, { a: 1 }];
|
|
8
|
+
* group(data, 'a') // { '2': [{ a: 2 }], '1': [{ a: 1 }] };
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @param array - The array to group.
|
|
12
|
+
* @param selector - The function to generate the key for each element. It can be a string representing the key or a function that returns the key.
|
|
13
|
+
*
|
|
14
|
+
* @returns an object with keys as the grouped values and values as arrays of elements.
|
|
15
|
+
*
|
|
16
|
+
* @throws {TypeError} If the provided array is not an array.
|
|
17
|
+
*/
|
|
18
|
+
export declare function group<T>(array: T[], selector: Selector<T>): Record<string, T[]>;
|
|
19
|
+
//# sourceMappingURL=group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../src/array/group.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKzC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAkB/E"}
|
package/dist/array/group.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import { assert as
|
|
2
|
-
import { IS_ARRAY_ERROR_MSG as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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/group.ts
|
|
4
|
+
function r(r, i) {
|
|
5
|
+
e(n(r), t, {
|
|
6
|
+
args: { array: r },
|
|
7
|
+
type: TypeError
|
|
8
|
+
});
|
|
9
|
+
let a = {}, o = typeof i == "function" ? i : (e) => e[i];
|
|
10
|
+
for (let e of r) {
|
|
11
|
+
let t = o(e), n = t == null ? "_" : String(t);
|
|
12
|
+
a[n] || (a[n] = []), a[n].push(e);
|
|
13
|
+
}
|
|
14
|
+
return a;
|
|
11
15
|
}
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=group.js.map
|
|
16
|
+
//#endregion
|
|
17
|
+
export { r as group };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=group.js.map
|
package/dist/array/group.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.js","sources":["../../src/array/group.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"group.js","names":[],"sources":["../../src/array/group.ts"],"sourcesContent":["import type { Selector } from '../types';\n\nimport { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\n\n/**\n * Groups the elements of an array based on the given key.\n *\n * @example\n * ```ts\n * const data = [{ a: 2 }, { a: 1 }];\n * group(data, 'a') // { '2': [{ a: 2 }], '1': [{ a: 1 }] };\n * ```\n *\n * @param array - The array to group.\n * @param selector - The function to generate the key for each element. It can be a string representing the key or a function that returns the key.\n *\n * @returns an object with keys as the grouped values and values as arrays of elements.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function group<T>(array: T[], selector: Selector<T>): Record<string, T[]> {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n const result: Record<string, T[]> = {};\n const getKey = typeof selector === 'function' ? selector : (item: T) => item[selector];\n\n for (const item of array) {\n const rawKey = getKey(item);\n const key = rawKey === undefined || rawKey === null ? '_' : String(rawKey);\n\n if (!result[key]) {\n result[key] = [];\n }\n\n result[key].push(item);\n }\n\n return result;\n}\n"],"mappings":";;;AAqBA,SAAgB,EAAS,GAAY,GAA4C;AAC/E,GAAO,EAAQ,EAAM,EAAE,GAAoB;EAAE,MAAM,EAAE,UAAO;EAAE,MAAM;EAAW,CAAC;CAEhF,IAAM,IAA8B,EAAE,EAChC,IAAS,OAAO,KAAa,aAAa,KAAY,MAAY,EAAK;AAE7E,MAAK,IAAM,KAAQ,GAAO;EACxB,IAAM,IAAS,EAAO,EAAK,EACrB,IAAM,KAAmC,OAAO,MAAM,OAAO,EAAO;AAM1E,EAJK,EAAO,OACV,EAAO,KAAO,EAAE,GAGlB,EAAO,GAAK,KAAK,EAAK;;AAGxB,QAAO"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './chunk';
|
|
2
|
+
export * from './contains';
|
|
3
|
+
export * from './fold';
|
|
4
|
+
export * from './group';
|
|
5
|
+
export * from './keyBy';
|
|
6
|
+
export * from './list';
|
|
7
|
+
export * from './pick';
|
|
8
|
+
export * from './remoteList';
|
|
9
|
+
export * from './replace';
|
|
10
|
+
export * from './rotate';
|
|
11
|
+
export * from './search';
|
|
12
|
+
export * from './select';
|
|
13
|
+
export * from './sort';
|
|
14
|
+
export * from './toggle';
|
|
15
|
+
export * from './uniq';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/array/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require(`../function/assert.cjs`),t=require(`../typed/isArray.cjs`);function n(n,r){e.assert(t.isArray(n),t.IS_ARRAY_ERROR_MSG,{args:{array:n},type:TypeError});let i={},a=typeof r==`function`?r:e=>e[r];for(let e of n){let t=String(a(e));i[t]=e}return i}exports.keyBy=n;
|
|
2
|
+
//# sourceMappingURL=keyBy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyBy.cjs","names":[],"sources":["../../src/array/keyBy.ts"],"sourcesContent":["import type { Selector } from '../types';\n\nimport { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\n\n/**\n * Creates an object keyed by a property or selector function. When multiple\n * items share the same key, the last one wins.\n *\n * @example\n * ```ts\n * const data = [{ a: 'x', v: 1 }, { a: 'y', v: 2 }, { a: 'x', v: 3 }];\n * keyBy(data, 'a') // { x: { a: 'x', v: 3 }, y: { a: 'y', v: 2 } }\n * keyBy(data, item => item.a) // same result\n * ```\n *\n * @param array - The array to index.\n * @param selector - A property key or a function returning the key for each element.\n * @returns A record mapping each key to the corresponding element.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function keyBy<T>(array: T[], selector: Selector<T>): Record<string, T> {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n const result: Record<string, T> = {};\n const getKey = typeof selector === 'function' ? selector : (item: T) => item[selector];\n\n for (const item of array) {\n const key = String(getKey(item));\n\n result[key] = item;\n }\n\n return result;\n}\n"],"mappings":"4EAsBA,SAAgB,EAAS,EAAY,EAA0C,CAC7E,EAAA,OAAO,EAAA,QAAQ,EAAM,CAAE,EAAA,mBAAoB,CAAE,KAAM,CAAE,QAAO,CAAE,KAAM,UAAW,CAAC,CAEhF,IAAM,EAA4B,EAAE,CAC9B,EAAS,OAAO,GAAa,WAAa,EAAY,GAAY,EAAK,GAE7E,IAAK,IAAM,KAAQ,EAAO,CACxB,IAAM,EAAM,OAAO,EAAO,EAAK,CAAC,CAEhC,EAAO,GAAO,EAGhB,OAAO"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Selector } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates an object keyed by a property or selector function. When multiple
|
|
4
|
+
* items share the same key, the last one wins.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const data = [{ a: 'x', v: 1 }, { a: 'y', v: 2 }, { a: 'x', v: 3 }];
|
|
9
|
+
* keyBy(data, 'a') // { x: { a: 'x', v: 3 }, y: { a: 'y', v: 2 } }
|
|
10
|
+
* keyBy(data, item => item.a) // same result
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param array - The array to index.
|
|
14
|
+
* @param selector - A property key or a function returning the key for each element.
|
|
15
|
+
* @returns A record mapping each key to the corresponding element.
|
|
16
|
+
*
|
|
17
|
+
* @throws {TypeError} If the provided array is not an array.
|
|
18
|
+
*/
|
|
19
|
+
export declare function keyBy<T>(array: T[], selector: Selector<T>): Record<string, T>;
|
|
20
|
+
//# sourceMappingURL=keyBy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyBy.d.ts","sourceRoot":"","sources":["../../src/array/keyBy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKzC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAa7E"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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/keyBy.ts
|
|
4
|
+
function r(r, i) {
|
|
5
|
+
e(n(r), t, {
|
|
6
|
+
args: { array: r },
|
|
7
|
+
type: TypeError
|
|
8
|
+
});
|
|
9
|
+
let a = {}, o = typeof i == "function" ? i : (e) => e[i];
|
|
10
|
+
for (let e of r) {
|
|
11
|
+
let t = String(o(e));
|
|
12
|
+
a[t] = e;
|
|
13
|
+
}
|
|
14
|
+
return a;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { r as keyBy };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=keyBy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyBy.js","names":[],"sources":["../../src/array/keyBy.ts"],"sourcesContent":["import type { Selector } from '../types';\n\nimport { assert } from '../function/assert';\nimport { IS_ARRAY_ERROR_MSG, isArray } from '../typed/isArray';\n\n/**\n * Creates an object keyed by a property or selector function. When multiple\n * items share the same key, the last one wins.\n *\n * @example\n * ```ts\n * const data = [{ a: 'x', v: 1 }, { a: 'y', v: 2 }, { a: 'x', v: 3 }];\n * keyBy(data, 'a') // { x: { a: 'x', v: 3 }, y: { a: 'y', v: 2 } }\n * keyBy(data, item => item.a) // same result\n * ```\n *\n * @param array - The array to index.\n * @param selector - A property key or a function returning the key for each element.\n * @returns A record mapping each key to the corresponding element.\n *\n * @throws {TypeError} If the provided array is not an array.\n */\nexport function keyBy<T>(array: T[], selector: Selector<T>): Record<string, T> {\n assert(isArray(array), IS_ARRAY_ERROR_MSG, { args: { array }, type: TypeError });\n\n const result: Record<string, T> = {};\n const getKey = typeof selector === 'function' ? selector : (item: T) => item[selector];\n\n for (const item of array) {\n const key = String(getKey(item));\n\n result[key] = item;\n }\n\n return result;\n}\n"],"mappings":";;;AAsBA,SAAgB,EAAS,GAAY,GAA0C;AAC7E,GAAO,EAAQ,EAAM,EAAE,GAAoB;EAAE,MAAM,EAAE,UAAO;EAAE,MAAM;EAAW,CAAC;CAEhF,IAAM,IAA4B,EAAE,EAC9B,IAAS,OAAO,KAAa,aAAa,KAAY,MAAY,EAAK;AAE7E,MAAK,IAAM,KAAQ,GAAO;EACxB,IAAM,IAAM,OAAO,EAAO,EAAK,CAAC;AAEhC,IAAO,KAAO;;AAGhB,QAAO"}
|
package/dist/array/list.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=list.cjs.map
|
|
1
|
+
const e=require(`./search.cjs`);function t(t,n={}){let r=new Set,i={debounceMs:300,limit:10,searchTone:.5},a=[...t],o=Math.max(1,n.limit??i.limit),s=n.filterFn??(()=>!0),c=n.sortFn,l=n.searchFn??((t,n,r)=>e.search([...t],n,r)),u=n.searchTone??i.searchTone,d=``,f=0,p=[],m=()=>{for(let e of r)e()},h=()=>{let e=a;d&&(e=l(e,d,u)),s&&(e=e.filter(s)),e=c?[...e].sort(c):[...e];let t=Math.max(1,Math.ceil(e.length/o));f=Math.min(f,t-1),p=e},g=()=>{if(!p.length)return[];let e=f*o;return p.slice(e,e+o)},_=()=>{h(),m()},v,y=(e,t)=>{v&&clearTimeout(v),v=setTimeout(()=>{d=e,v=void 0,_()},t)};return h(),{batch(e){let t=o,n=s,r=c,i=d,l=a,u=f,m=(e,t,n)=>Math.max(0,Math.min(e,Math.max(0,Math.ceil(t/n)-1)));e({goTo:e=>{u=m(e-1,p.length,t)},setData:e=>{l=[...e],u=0},setFilter:e=>{n=e},setLimit:e=>{t=Math.max(1,e)},setQuery:e=>{i=e,u=0},setSort:e=>{r=e}}),o=t,s=n,c=r,d=i,a=l,f=u,_()},get current(){return g()},goTo(e){let t=Math.max(1,Math.ceil(p.length/o));f=Math.max(0,Math.min(e-1,t-1)),m()},get meta(){let e=p.length,t=Math.max(1,Math.ceil(e/o)),n=e===0,r=Math.min(f+1,t),i=n?0:(r-1)*o+1;return{end:n?0:Math.min(r*o,e),isEmpty:n,isFirst:r<=1,isLast:r>=t,limit:o,page:r,pages:t,start:i,total:e}},next(){let e=Math.max(1,Math.ceil(p.length/o));f<e-1&&(f++,m())},prev(){f>0&&(f--,m())},reset(){o=Math.max(1,n.limit??i.limit),s=n.filterFn??(()=>!0),c=n.sortFn,d=``,f=0,_()},search(e,t){t?.immediate?(d=e,f=0,_()):y(e,n.debounceMs??i.debounceMs)},setData(e){a=[...e],f=0,_()},setFilter(e){s=e,f=0,_()},setLimit(e){o=Math.max(1,e),f=0,_()},setSort(e){c=e,_()},subscribe(e){return r.add(e),()=>r.delete(e)}}}exports.list=t;
|
|
2
|
+
//# sourceMappingURL=list.cjs.map
|
package/dist/array/list.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.cjs","sources":["../../src/array/list.ts"],"sourcesContent":["import type { Predicate, Sorter } from '../types';\nimport { search as defaultSearch } from './search';\n\n// #region
|
|
1
|
+
{"version":3,"file":"list.cjs","names":[],"sources":["../../src/array/list.ts"],"sourcesContent":["import type { Predicate, Sorter } from '../types';\n\nimport { search as defaultSearch } from './search';\n\n// #region BaseMeta\n/** Minimal pagination metadata shared by both `list` and `remoteList`. */\nexport type BaseMeta = Readonly<{\n end: number;\n isEmpty: boolean;\n isFirst: boolean;\n isLast: boolean;\n limit: number;\n page: number;\n pages: number;\n start: number;\n total: number;\n}>;\n// #endregion BaseMeta\n\n// #region BaseList\n/**\n * Minimal shared interface satisfied by both `list()` and `remoteList()` results.\n * Use this type for code that works with either.\n */\nexport type BaseList<T> = {\n readonly current: readonly T[];\n readonly meta: BaseMeta;\n subscribe(listener: () => void): () => void;\n};\n// #endregion BaseList\n\n// #region Meta\nexport type Meta = BaseMeta;\n// #endregion Meta\n\n// #region List\nexport type List<T, F, S> = {\n // Batch updates across properties in one recompute/refetch\n batch(\n mutator: (ctx: {\n goTo(p: number): void; // 1-based\n setData?(d: readonly T[]): void; // local-only\n setFilter(f: F): void;\n setLimit(n: number): void;\n setQuery(q: string): void;\n setSort(s?: S): void;\n }) => void,\n ): void;\n readonly current: readonly T[];\n goTo(page: number): void;\n\n readonly meta: Meta;\n next(): void;\n prev(): void;\n reset(): void;\n search(query: string, opts?: { immediate?: boolean }): void;\n setData?(data: readonly T[]): void; // implemented by local\n setFilter(filter: F): void;\n setLimit(n: number): void;\n setSort(sort?: S): void;\n\n subscribe(listener: () => void): () => void;\n};\n// #endregion List\n\n// #region LocalConfig\ntype LocalConfig<T> = Readonly<{\n debounceMs?: number;\n filterFn?: Predicate<T>;\n limit?: number;\n searchFn?: (items: readonly T[], query: string, tone: number) => readonly T[];\n searchTone?: number;\n sortFn?: Sorter<T>;\n}>;\n// #endregion LocalConfig\n\nexport function list<T>(initialData: readonly T[], cfg: LocalConfig<T> = {}): List<T, Predicate<T>, Sorter<T>> {\n const listeners = new Set<() => void>();\n\n const DEFAULTS = { debounceMs: 300, limit: 10, searchTone: 0.5 } as const;\n\n let rawData: readonly T[] = [...initialData];\n let limit = Math.max(1, cfg.limit ?? DEFAULTS.limit);\n let filterFn: Predicate<T> = cfg.filterFn ?? (() => true);\n let sortFn: Sorter<T> | undefined = cfg.sortFn;\n const searchFn = cfg.searchFn ?? ((items: readonly T[], q: string, t: number) => defaultSearch([...items], q, t));\n const searchTone = cfg.searchTone ?? DEFAULTS.searchTone;\n\n let query = '';\n let offset = 0;\n let view: readonly T[] = [];\n\n const notify = () => {\n for (const l of listeners) {\n l();\n }\n };\n\n const recompute = () => {\n let arr = rawData;\n\n if (query) arr = searchFn(arr, query, searchTone);\n\n if (filterFn) arr = arr.filter(filterFn);\n\n arr = sortFn ? [...arr].sort(sortFn) : [...arr];\n\n const pages = Math.max(1, Math.ceil(arr.length / limit));\n\n offset = Math.min(offset, pages - 1);\n view = arr;\n };\n\n const slice = (): readonly T[] => {\n if (!view.length) return [];\n\n const start = offset * limit;\n\n return view.slice(start, start + limit);\n };\n\n const update = () => {\n recompute();\n notify();\n };\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n const debouncedSearch = (q: string, ms: number) => {\n if (timer) clearTimeout(timer);\n\n timer = setTimeout(() => {\n query = q;\n timer = undefined;\n void update();\n }, ms);\n };\n\n // initial compute\n recompute();\n\n return {\n batch(mutator) {\n let nextLimit = limit;\n let nextFilter = filterFn;\n let nextSort = sortFn;\n let nextQuery = query;\n let nextData = rawData;\n let nextOffset = offset;\n\n const clamp = (i: number, total: number, lim: number) =>\n Math.max(0, Math.min(i, Math.max(0, Math.ceil(total / lim) - 1)));\n\n mutator({\n goTo: (p) => {\n nextOffset = clamp(p - 1, view.length, nextLimit);\n },\n setData: (d) => {\n nextData = [...d];\n nextOffset = 0;\n },\n setFilter: (f) => {\n nextFilter = f;\n },\n setLimit: (n) => {\n nextLimit = Math.max(1, n);\n },\n setQuery: (q) => {\n nextQuery = q;\n nextOffset = 0;\n },\n setSort: (s) => {\n nextSort = s;\n },\n });\n\n // apply once\n limit = nextLimit;\n filterFn = nextFilter;\n sortFn = nextSort;\n query = nextQuery;\n rawData = nextData;\n offset = nextOffset;\n\n update();\n },\n get current() {\n return slice();\n },\n goTo(page) {\n const pages = Math.max(1, Math.ceil(view.length / limit));\n\n offset = Math.max(0, Math.min(page - 1, pages - 1));\n notify();\n },\n get meta() {\n const total = view.length;\n const pages = Math.max(1, Math.ceil(total / limit));\n const isEmpty = total === 0;\n const page = Math.min(offset + 1, pages);\n const start = isEmpty ? 0 : (page - 1) * limit + 1;\n const end = isEmpty ? 0 : Math.min(page * limit, total);\n\n return {\n end,\n isEmpty,\n isFirst: page <= 1,\n isLast: page >= pages,\n limit,\n page,\n pages,\n start,\n total,\n };\n },\n next() {\n const pages = Math.max(1, Math.ceil(view.length / limit));\n\n if (offset < pages - 1) {\n offset++;\n notify();\n }\n },\n prev() {\n if (offset > 0) {\n offset--;\n notify();\n }\n },\n reset() {\n limit = Math.max(1, cfg.limit ?? DEFAULTS.limit);\n filterFn = cfg.filterFn ?? (() => true);\n sortFn = cfg.sortFn;\n query = '';\n offset = 0;\n update();\n },\n search(q, opts) {\n if (opts?.immediate) {\n query = q;\n offset = 0;\n update();\n } else {\n debouncedSearch(q, cfg.debounceMs ?? DEFAULTS.debounceMs);\n }\n },\n setData(data) {\n rawData = [...data];\n offset = 0;\n update();\n },\n setFilter(f) {\n filterFn = f;\n offset = 0;\n update();\n },\n setLimit(n) {\n limit = Math.max(1, n);\n offset = 0;\n update();\n },\n setSort(s) {\n sortFn = s;\n update();\n },\n subscribe(listener) {\n listeners.add(listener);\n\n return () => listeners.delete(listener);\n },\n };\n}\n"],"mappings":"gCA4EA,SAAgB,EAAQ,EAA2B,EAAsB,EAAE,CAAoC,CAC7G,IAAM,EAAY,IAAI,IAEhB,EAAW,CAAE,WAAY,IAAK,MAAO,GAAI,WAAY,GAAK,CAE5D,EAAwB,CAAC,GAAG,EAAY,CACxC,EAAQ,KAAK,IAAI,EAAG,EAAI,OAAS,EAAS,MAAM,CAChD,EAAyB,EAAI,eAAmB,IAChD,EAAgC,EAAI,OAClC,EAAW,EAAI,YAAc,EAAqB,EAAW,IAAc,EAAA,OAAc,CAAC,GAAG,EAAM,CAAE,EAAG,EAAE,EAC1G,EAAa,EAAI,YAAc,EAAS,WAE1C,EAAQ,GACR,EAAS,EACT,EAAqB,EAAE,CAErB,MAAe,CACnB,IAAK,IAAM,KAAK,EACd,GAAG,EAID,MAAkB,CACtB,IAAI,EAAM,EAEN,IAAO,EAAM,EAAS,EAAK,EAAO,EAAW,EAE7C,IAAU,EAAM,EAAI,OAAO,EAAS,EAExC,EAAM,EAAS,CAAC,GAAG,EAAI,CAAC,KAAK,EAAO,CAAG,CAAC,GAAG,EAAI,CAE/C,IAAM,EAAQ,KAAK,IAAI,EAAG,KAAK,KAAK,EAAI,OAAS,EAAM,CAAC,CAExD,EAAS,KAAK,IAAI,EAAQ,EAAQ,EAAE,CACpC,EAAO,GAGH,MAA4B,CAChC,GAAI,CAAC,EAAK,OAAQ,MAAO,EAAE,CAE3B,IAAM,EAAQ,EAAS,EAEvB,OAAO,EAAK,MAAM,EAAO,EAAQ,EAAM,EAGnC,MAAe,CACnB,GAAW,CACX,GAAQ,EAGN,EACE,GAAmB,EAAW,IAAe,CAC7C,GAAO,aAAa,EAAM,CAE9B,EAAQ,eAAiB,CACvB,EAAQ,EACR,EAAQ,IAAA,GACH,GAAQ,EACZ,EAAG,EAMR,OAFA,GAAW,CAEJ,CACL,MAAM,EAAS,CACb,IAAI,EAAY,EACZ,EAAa,EACb,EAAW,EACX,EAAY,EACZ,EAAW,EACX,EAAa,EAEX,GAAS,EAAW,EAAe,IACvC,KAAK,IAAI,EAAG,KAAK,IAAI,EAAG,KAAK,IAAI,EAAG,KAAK,KAAK,EAAQ,EAAI,CAAG,EAAE,CAAC,CAAC,CAEnE,EAAQ,CACN,KAAO,GAAM,CACX,EAAa,EAAM,EAAI,EAAG,EAAK,OAAQ,EAAU,EAEnD,QAAU,GAAM,CACd,EAAW,CAAC,GAAG,EAAE,CACjB,EAAa,GAEf,UAAY,GAAM,CAChB,EAAa,GAEf,SAAW,GAAM,CACf,EAAY,KAAK,IAAI,EAAG,EAAE,EAE5B,SAAW,GAAM,CACf,EAAY,EACZ,EAAa,GAEf,QAAU,GAAM,CACd,EAAW,GAEd,CAAC,CAGF,EAAQ,EACR,EAAW,EACX,EAAS,EACT,EAAQ,EACR,EAAU,EACV,EAAS,EAET,GAAQ,EAEV,IAAI,SAAU,CACZ,OAAO,GAAO,EAEhB,KAAK,EAAM,CACT,IAAM,EAAQ,KAAK,IAAI,EAAG,KAAK,KAAK,EAAK,OAAS,EAAM,CAAC,CAEzD,EAAS,KAAK,IAAI,EAAG,KAAK,IAAI,EAAO,EAAG,EAAQ,EAAE,CAAC,CACnD,GAAQ,EAEV,IAAI,MAAO,CACT,IAAM,EAAQ,EAAK,OACb,EAAQ,KAAK,IAAI,EAAG,KAAK,KAAK,EAAQ,EAAM,CAAC,CAC7C,EAAU,IAAU,EACpB,EAAO,KAAK,IAAI,EAAS,EAAG,EAAM,CAClC,EAAQ,EAAU,GAAK,EAAO,GAAK,EAAQ,EAGjD,MAAO,CACL,IAHU,EAAU,EAAI,KAAK,IAAI,EAAO,EAAO,EAAM,CAIrD,UACA,QAAS,GAAQ,EACjB,OAAQ,GAAQ,EAChB,QACA,OACA,QACA,QACA,QACD,EAEH,MAAO,CACL,IAAM,EAAQ,KAAK,IAAI,EAAG,KAAK,KAAK,EAAK,OAAS,EAAM,CAAC,CAErD,EAAS,EAAQ,IACnB,IACA,GAAQ,GAGZ,MAAO,CACD,EAAS,IACX,IACA,GAAQ,GAGZ,OAAQ,CACN,EAAQ,KAAK,IAAI,EAAG,EAAI,OAAS,EAAS,MAAM,CAChD,EAAW,EAAI,eAAmB,IAClC,EAAS,EAAI,OACb,EAAQ,GACR,EAAS,EACT,GAAQ,EAEV,OAAO,EAAG,EAAM,CACV,GAAM,WACR,EAAQ,EACR,EAAS,EACT,GAAQ,EAER,EAAgB,EAAG,EAAI,YAAc,EAAS,WAAW,EAG7D,QAAQ,EAAM,CACZ,EAAU,CAAC,GAAG,EAAK,CACnB,EAAS,EACT,GAAQ,EAEV,UAAU,EAAG,CACX,EAAW,EACX,EAAS,EACT,GAAQ,EAEV,SAAS,EAAG,CACV,EAAQ,KAAK,IAAI,EAAG,EAAE,CACtB,EAAS,EACT,GAAQ,EAEV,QAAQ,EAAG,CACT,EAAS,EACT,GAAQ,EAEV,UAAU,EAAU,CAGlB,OAFA,EAAU,IAAI,EAAS,KAEV,EAAU,OAAO,EAAS,EAE1C"}
|