@vielzeug/arsenal 3.0.0 → 26.10.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/dist/_common/_lruMap.cjs +1 -1
- package/dist/_common/_lruMap.cjs.map +1 -1
- package/dist/_common/_lruMap.js +1 -17
- package/dist/_common/_lruMap.js.map +1 -1
- package/dist/_common/_selectorSet.cjs +1 -1
- package/dist/_common/_selectorSet.cjs.map +1 -1
- package/dist/_common/_selectorSet.js +1 -15
- package/dist/_common/_selectorSet.js.map +1 -1
- package/dist/_common/unsafePaths.cjs +1 -1
- package/dist/_common/unsafePaths.cjs.map +1 -1
- package/dist/_common/unsafePaths.js +1 -12
- package/dist/_common/unsafePaths.js.map +1 -1
- package/dist/_dev.cjs +1 -1
- package/dist/_dev.cjs.map +1 -1
- package/dist/_dev.js +1 -5
- package/dist/_dev.js.map +1 -1
- package/dist/array/chunk.cjs +1 -1
- package/dist/array/chunk.cjs.map +1 -1
- package/dist/array/chunk.js +1 -9
- package/dist/array/chunk.js.map +1 -1
- package/dist/array/compact.cjs +1 -1
- package/dist/array/compact.cjs.map +1 -1
- package/dist/array/compact.js +1 -7
- package/dist/array/compact.js.map +1 -1
- package/dist/array/compare.cjs +1 -1
- package/dist/array/compare.cjs.map +1 -1
- package/dist/array/compare.js +1 -18
- package/dist/array/compare.js.map +1 -1
- package/dist/array/compareBy.cjs +1 -1
- package/dist/array/compareBy.cjs.map +1 -1
- package/dist/array/compareBy.js +1 -15
- package/dist/array/compareBy.js.map +1 -1
- package/dist/array/contains.cjs +1 -1
- package/dist/array/contains.cjs.map +1 -1
- package/dist/array/contains.js +1 -8
- package/dist/array/contains.js.map +1 -1
- package/dist/array/countBy.cjs +1 -1
- package/dist/array/countBy.cjs.map +1 -1
- package/dist/array/countBy.js +1 -13
- package/dist/array/countBy.js.map +1 -1
- package/dist/array/difference.cjs +1 -1
- package/dist/array/difference.cjs.map +1 -1
- package/dist/array/difference.js +1 -13
- package/dist/array/difference.js.map +1 -1
- package/dist/array/drop.cjs +1 -1
- package/dist/array/drop.cjs.map +1 -1
- package/dist/array/drop.js +1 -8
- package/dist/array/drop.js.map +1 -1
- package/dist/array/dropLast.cjs +1 -1
- package/dist/array/dropLast.cjs.map +1 -1
- package/dist/array/dropLast.js +1 -8
- package/dist/array/dropLast.js.map +1 -1
- package/dist/array/filterMap.cjs +1 -1
- package/dist/array/filterMap.cjs.map +1 -1
- package/dist/array/filterMap.js +1 -12
- package/dist/array/filterMap.js.map +1 -1
- package/dist/array/first.cjs +1 -1
- package/dist/array/first.cjs.map +1 -1
- package/dist/array/first.js +1 -7
- package/dist/array/first.js.map +1 -1
- package/dist/array/groupBy.cjs +1 -1
- package/dist/array/groupBy.cjs.map +1 -1
- package/dist/array/groupBy.js +1 -13
- package/dist/array/groupBy.js.map +1 -1
- package/dist/array/index.js +1 -28
- package/dist/array/indexBy.cjs +1 -1
- package/dist/array/indexBy.cjs.map +1 -1
- package/dist/array/indexBy.js +1 -13
- package/dist/array/indexBy.js.map +1 -1
- package/dist/array/intersection.cjs +1 -1
- package/dist/array/intersection.cjs.map +1 -1
- package/dist/array/intersection.js +1 -13
- package/dist/array/intersection.js.map +1 -1
- package/dist/array/last.cjs +1 -1
- package/dist/array/last.cjs.map +1 -1
- package/dist/array/last.js +1 -7
- package/dist/array/last.js.map +1 -1
- package/dist/array/partition.cjs +1 -1
- package/dist/array/partition.cjs.map +1 -1
- package/dist/array/partition.js +1 -9
- package/dist/array/partition.js.map +1 -1
- package/dist/array/replace.cjs +1 -1
- package/dist/array/replace.cjs.map +1 -1
- package/dist/array/replace.js +1 -12
- package/dist/array/replace.js.map +1 -1
- package/dist/array/rotate.cjs +1 -1
- package/dist/array/rotate.cjs.map +1 -1
- package/dist/array/rotate.js +1 -9
- package/dist/array/rotate.js.map +1 -1
- package/dist/array/search.cjs +1 -1
- package/dist/array/search.cjs.map +1 -1
- package/dist/array/search.js +1 -29
- package/dist/array/search.js.map +1 -1
- package/dist/array/sort.cjs +1 -1
- package/dist/array/sort.cjs.map +1 -1
- package/dist/array/sort.js +1 -14
- package/dist/array/sort.js.map +1 -1
- package/dist/array/take.cjs +1 -1
- package/dist/array/take.cjs.map +1 -1
- package/dist/array/take.js +1 -8
- package/dist/array/take.js.map +1 -1
- package/dist/array/takeLast.cjs +1 -1
- package/dist/array/takeLast.cjs.map +1 -1
- package/dist/array/takeLast.js +1 -8
- package/dist/array/takeLast.js.map +1 -1
- package/dist/array/toggle.cjs +1 -1
- package/dist/array/toggle.cjs.map +1 -1
- package/dist/array/toggle.js +1 -8
- package/dist/array/toggle.js.map +1 -1
- package/dist/array/union.cjs +1 -1
- package/dist/array/union.cjs.map +1 -1
- package/dist/array/union.js +1 -8
- package/dist/array/union.js.map +1 -1
- package/dist/array/uniq.cjs +1 -1
- package/dist/array/uniq.cjs.map +1 -1
- package/dist/array/uniq.js +1 -8
- package/dist/array/uniq.js.map +1 -1
- package/dist/array/unzip.cjs +1 -1
- package/dist/array/unzip.cjs.map +1 -1
- package/dist/array/unzip.js +1 -10
- package/dist/array/unzip.js.map +1 -1
- package/dist/array/zip.cjs +1 -1
- package/dist/array/zip.cjs.map +1 -1
- package/dist/array/zip.js +1 -10
- package/dist/array/zip.js.map +1 -1
- package/dist/arsenal.cjs +1 -1
- package/dist/arsenal.cjs.map +1 -1
- package/dist/arsenal.iife.js +1 -1
- package/dist/arsenal.iife.js.map +1 -1
- package/dist/arsenal.js +1 -1
- package/dist/arsenal.js.map +1 -1
- package/dist/async/abortError.cjs +1 -1
- package/dist/async/abortError.cjs.map +1 -1
- package/dist/async/abortError.js +1 -7
- package/dist/async/abortError.js.map +1 -1
- package/dist/async/abortable.cjs +1 -1
- package/dist/async/abortable.cjs.map +1 -1
- package/dist/async/abortable.js +1 -11
- package/dist/async/abortable.js.map +1 -1
- package/dist/async/attempt.cjs +1 -1
- package/dist/async/attempt.cjs.map +1 -1
- package/dist/async/attempt.js +1 -23
- package/dist/async/attempt.js.map +1 -1
- package/dist/async/backoff.cjs +1 -1
- package/dist/async/backoff.cjs.map +1 -1
- package/dist/async/backoff.js +1 -7
- package/dist/async/backoff.js.map +1 -1
- package/dist/async/index.js +1 -10
- package/dist/async/parallel.cjs +1 -1
- package/dist/async/parallel.cjs.map +1 -1
- package/dist/async/parallel.js +1 -24
- package/dist/async/parallel.js.map +1 -1
- package/dist/async/retry.cjs +1 -1
- package/dist/async/retry.cjs.map +1 -1
- package/dist/async/retry.d.ts +4 -6
- package/dist/async/retry.d.ts.map +1 -1
- package/dist/async/retry.js +1 -24
- package/dist/async/retry.js.map +1 -1
- package/dist/async/sleep.cjs +1 -1
- package/dist/async/sleep.cjs.map +1 -1
- package/dist/async/sleep.js +1 -15
- package/dist/async/sleep.js.map +1 -1
- package/dist/async/taskPool.cjs +1 -1
- package/dist/async/taskPool.cjs.map +1 -1
- package/dist/async/taskPool.js +1 -50
- package/dist/async/taskPool.js.map +1 -1
- package/dist/async/waitFor.cjs +1 -1
- package/dist/async/waitFor.cjs.map +1 -1
- package/dist/async/waitFor.js +1 -12
- package/dist/async/waitFor.js.map +1 -1
- package/dist/cache/cache.cjs +1 -1
- package/dist/cache/cache.cjs.map +1 -1
- package/dist/cache/cache.js +1 -59
- package/dist/cache/cache.js.map +1 -1
- package/dist/cache/index.js +1 -3
- package/dist/cache/memo.cjs +1 -1
- package/dist/cache/memo.cjs.map +1 -1
- package/dist/cache/memo.js +1 -37
- package/dist/cache/memo.js.map +1 -1
- package/dist/encoding/base64url.cjs +2 -0
- package/dist/encoding/base64url.cjs.map +1 -0
- package/dist/encoding/base64url.d.ts +9 -0
- package/dist/encoding/base64url.d.ts.map +1 -0
- package/dist/encoding/base64url.js +2 -0
- package/dist/encoding/base64url.js.map +1 -0
- package/dist/encoding/index.cjs +1 -0
- package/dist/encoding/index.d.ts +2 -0
- package/dist/encoding/index.d.ts.map +1 -0
- package/dist/encoding/index.js +1 -0
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.js +1 -9
- package/dist/errors.js.map +1 -1
- package/dist/function/assert.cjs +1 -1
- package/dist/function/assert.cjs.map +1 -1
- package/dist/function/assert.js +1 -7
- package/dist/function/assert.js.map +1 -1
- package/dist/function/debounce.cjs +1 -1
- package/dist/function/debounce.cjs.map +1 -1
- package/dist/function/debounce.js +1 -26
- package/dist/function/debounce.js.map +1 -1
- package/dist/function/index.cjs +1 -1
- package/dist/function/index.d.ts +1 -0
- package/dist/function/index.d.ts.map +1 -1
- package/dist/function/index.js +1 -8
- package/dist/function/once.cjs +1 -1
- package/dist/function/once.cjs.map +1 -1
- package/dist/function/once.js +1 -10
- package/dist/function/once.js.map +1 -1
- package/dist/function/pipe.cjs +1 -1
- package/dist/function/pipe.cjs.map +1 -1
- package/dist/function/pipe.js +1 -9
- package/dist/function/pipe.js.map +1 -1
- package/dist/function/runAll.cjs +1 -1
- package/dist/function/runAll.cjs.map +1 -1
- package/dist/function/runAll.js +1 -18
- package/dist/function/runAll.js.map +1 -1
- package/dist/function/tap.cjs +1 -1
- package/dist/function/tap.cjs.map +1 -1
- package/dist/function/tap.js +1 -7
- package/dist/function/tap.js.map +1 -1
- package/dist/function/tapper.cjs +2 -0
- package/dist/function/tapper.cjs.map +1 -0
- package/dist/function/tapper.d.ts +27 -0
- package/dist/function/tapper.d.ts.map +1 -0
- package/dist/function/tapper.js +2 -0
- package/dist/function/tapper.js.map +1 -0
- package/dist/function/throttle.cjs +1 -1
- package/dist/function/throttle.cjs.map +1 -1
- package/dist/function/throttle.js +1 -35
- package/dist/function/throttle.js.map +1 -1
- package/dist/guards/combinators.cjs +1 -1
- package/dist/guards/combinators.cjs.map +1 -1
- package/dist/guards/combinators.js +1 -16
- package/dist/guards/combinators.js.map +1 -1
- package/dist/guards/index.js +1 -17
- package/dist/guards/isAbortError.cjs +1 -1
- package/dist/guards/isAbortError.cjs.map +1 -1
- package/dist/guards/isAbortError.js +1 -7
- package/dist/guards/isAbortError.js.map +1 -1
- package/dist/guards/isDate.cjs +1 -1
- package/dist/guards/isDate.cjs.map +1 -1
- package/dist/guards/isDate.js +1 -7
- package/dist/guards/isDate.js.map +1 -1
- package/dist/guards/isDefined.cjs +1 -1
- package/dist/guards/isDefined.cjs.map +1 -1
- package/dist/guards/isDefined.js +1 -7
- package/dist/guards/isDefined.js.map +1 -1
- package/dist/guards/isEmpty.cjs +1 -1
- package/dist/guards/isEmpty.cjs.map +1 -1
- package/dist/guards/isEmpty.js +1 -8
- package/dist/guards/isEmpty.js.map +1 -1
- package/dist/guards/isEqual.cjs +1 -1
- package/dist/guards/isEqual.cjs.map +1 -1
- package/dist/guards/isEqual.js +1 -33
- package/dist/guards/isEqual.js.map +1 -1
- package/dist/guards/isError.cjs +1 -1
- package/dist/guards/isError.cjs.map +1 -1
- package/dist/guards/isError.js +1 -7
- package/dist/guards/isError.js.map +1 -1
- package/dist/guards/isFunction.cjs +1 -1
- package/dist/guards/isFunction.cjs.map +1 -1
- package/dist/guards/isFunction.js +1 -7
- package/dist/guards/isFunction.js.map +1 -1
- package/dist/guards/isMatch.cjs +1 -1
- package/dist/guards/isMatch.cjs.map +1 -1
- package/dist/guards/isMatch.js +1 -22
- package/dist/guards/isMatch.js.map +1 -1
- package/dist/guards/isNil.cjs +1 -1
- package/dist/guards/isNil.cjs.map +1 -1
- package/dist/guards/isNil.js +1 -7
- package/dist/guards/isNil.js.map +1 -1
- package/dist/guards/isNumber.cjs +1 -1
- package/dist/guards/isNumber.cjs.map +1 -1
- package/dist/guards/isNumber.js +1 -7
- package/dist/guards/isNumber.js.map +1 -1
- package/dist/guards/isPlainObject.cjs +1 -1
- package/dist/guards/isPlainObject.cjs.map +1 -1
- package/dist/guards/isPlainObject.js +1 -9
- package/dist/guards/isPlainObject.js.map +1 -1
- package/dist/guards/isPrimitive.cjs +1 -1
- package/dist/guards/isPrimitive.cjs.map +1 -1
- package/dist/guards/isPrimitive.js +1 -7
- package/dist/guards/isPrimitive.js.map +1 -1
- package/dist/guards/isPromise.cjs +1 -1
- package/dist/guards/isPromise.cjs.map +1 -1
- package/dist/guards/isPromise.js +1 -7
- package/dist/guards/isPromise.js.map +1 -1
- package/dist/guards/isRegex.cjs +1 -1
- package/dist/guards/isRegex.cjs.map +1 -1
- package/dist/guards/isRegex.js +1 -7
- package/dist/guards/isRegex.js.map +1 -1
- package/dist/guards/shallowEqual.cjs +1 -1
- package/dist/guards/shallowEqual.cjs.map +1 -1
- package/dist/guards/shallowEqual.js +1 -19
- package/dist/guards/shallowEqual.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -35
- package/dist/math/allocate.cjs +1 -1
- package/dist/math/allocate.cjs.map +1 -1
- package/dist/math/allocate.js +1 -18
- package/dist/math/allocate.js.map +1 -1
- package/dist/math/average.cjs +1 -1
- package/dist/math/average.cjs.map +1 -1
- package/dist/math/average.js +1 -8
- package/dist/math/average.js.map +1 -1
- package/dist/math/clamp.cjs +1 -1
- package/dist/math/clamp.cjs.map +1 -1
- package/dist/math/clamp.js +1 -7
- package/dist/math/clamp.js.map +1 -1
- package/dist/math/gcd.cjs +1 -1
- package/dist/math/gcd.cjs.map +1 -1
- package/dist/math/gcd.js +1 -13
- package/dist/math/gcd.js.map +1 -1
- package/dist/math/index.js +1 -16
- package/dist/math/lcm.cjs +1 -1
- package/dist/math/lcm.cjs.map +1 -1
- package/dist/math/lcm.js +1 -12
- package/dist/math/lcm.js.map +1 -1
- package/dist/math/lerp.cjs +1 -1
- package/dist/math/lerp.cjs.map +1 -1
- package/dist/math/lerp.js +1 -7
- package/dist/math/lerp.js.map +1 -1
- package/dist/math/linspace.cjs +1 -1
- package/dist/math/linspace.cjs.map +1 -1
- package/dist/math/linspace.js +1 -11
- package/dist/math/linspace.js.map +1 -1
- package/dist/math/median.cjs +1 -1
- package/dist/math/median.cjs.map +1 -1
- package/dist/math/median.js +1 -11
- package/dist/math/median.js.map +1 -1
- package/dist/math/mod.cjs +1 -1
- package/dist/math/mod.cjs.map +1 -1
- package/dist/math/mod.js +1 -8
- package/dist/math/mod.js.map +1 -1
- package/dist/math/normalize.cjs +1 -1
- package/dist/math/normalize.cjs.map +1 -1
- package/dist/math/normalize.js +1 -8
- package/dist/math/normalize.js.map +1 -1
- package/dist/math/range.cjs +1 -1
- package/dist/math/range.cjs.map +1 -1
- package/dist/math/range.js +1 -25
- package/dist/math/range.js.map +1 -1
- package/dist/math/round.cjs +1 -1
- package/dist/math/round.cjs.map +1 -1
- package/dist/math/round.js +1 -9
- package/dist/math/round.js.map +1 -1
- package/dist/math/standardDeviation.cjs +1 -1
- package/dist/math/standardDeviation.cjs.map +1 -1
- package/dist/math/standardDeviation.js +1 -8
- package/dist/math/standardDeviation.js.map +1 -1
- package/dist/math/sum.cjs +1 -1
- package/dist/math/sum.cjs.map +1 -1
- package/dist/math/sum.js +1 -11
- package/dist/math/sum.js.map +1 -1
- package/dist/math/variance.cjs +1 -1
- package/dist/math/variance.cjs.map +1 -1
- package/dist/math/variance.js +1 -10
- package/dist/math/variance.js.map +1 -1
- package/dist/object/defaults.cjs +1 -1
- package/dist/object/defaults.cjs.map +1 -1
- package/dist/object/defaults.js +1 -11
- package/dist/object/defaults.js.map +1 -1
- package/dist/object/diff.cjs +1 -1
- package/dist/object/diff.cjs.map +1 -1
- package/dist/object/diff.js +1 -26
- package/dist/object/diff.js.map +1 -1
- package/dist/object/filterValues.cjs +1 -1
- package/dist/object/filterValues.cjs.map +1 -1
- package/dist/object/filterValues.js +1 -10
- package/dist/object/filterValues.js.map +1 -1
- package/dist/object/flattenPaths.cjs +1 -1
- package/dist/object/flattenPaths.cjs.map +1 -1
- package/dist/object/flattenPaths.js +1 -30
- package/dist/object/flattenPaths.js.map +1 -1
- package/dist/object/getPath.cjs +1 -1
- package/dist/object/getPath.cjs.map +1 -1
- package/dist/object/getPath.js +1 -25
- package/dist/object/getPath.js.map +1 -1
- package/dist/object/hash.cjs +1 -1
- package/dist/object/hash.cjs.map +1 -1
- package/dist/object/hash.js +1 -27
- package/dist/object/hash.js.map +1 -1
- package/dist/object/index.js +1 -15
- package/dist/object/invert.cjs +1 -1
- package/dist/object/invert.cjs.map +1 -1
- package/dist/object/invert.js +1 -10
- package/dist/object/invert.js.map +1 -1
- package/dist/object/mapKeys.cjs +1 -1
- package/dist/object/mapKeys.cjs.map +1 -1
- package/dist/object/mapKeys.js +1 -14
- package/dist/object/mapKeys.js.map +1 -1
- package/dist/object/mapValues.cjs +1 -1
- package/dist/object/mapValues.cjs.map +1 -1
- package/dist/object/mapValues.js +1 -10
- package/dist/object/mapValues.js.map +1 -1
- package/dist/object/merge.cjs +1 -1
- package/dist/object/merge.cjs.map +1 -1
- package/dist/object/merge.js +1 -25
- package/dist/object/merge.js.map +1 -1
- package/dist/object/omit.cjs +1 -1
- package/dist/object/omit.cjs.map +1 -1
- package/dist/object/omit.js +1 -10
- package/dist/object/omit.js.map +1 -1
- package/dist/object/pick.cjs +1 -1
- package/dist/object/pick.cjs.map +1 -1
- package/dist/object/pick.js +1 -10
- package/dist/object/pick.js.map +1 -1
- package/dist/object/prune.cjs +1 -1
- package/dist/object/prune.cjs.map +1 -1
- package/dist/object/prune.js +1 -33
- package/dist/object/prune.js.map +1 -1
- package/dist/object/tryParseJson.cjs +1 -1
- package/dist/object/tryParseJson.cjs.map +1 -1
- package/dist/object/tryParseJson.js +1 -17
- package/dist/object/tryParseJson.js.map +1 -1
- package/dist/random/_index.cjs +1 -1
- package/dist/random/_index.cjs.map +1 -1
- package/dist/random/_index.js +1 -8
- package/dist/random/_index.js.map +1 -1
- package/dist/random/draw.cjs +1 -1
- package/dist/random/draw.cjs.map +1 -1
- package/dist/random/draw.js +1 -20
- package/dist/random/draw.js.map +1 -1
- package/dist/random/index.js +1 -5
- package/dist/random/random.cjs +1 -1
- package/dist/random/random.cjs.map +1 -1
- package/dist/random/random.js +1 -9
- package/dist/random/random.js.map +1 -1
- package/dist/random/shuffle.cjs +1 -1
- package/dist/random/shuffle.cjs.map +1 -1
- package/dist/random/shuffle.js +1 -13
- package/dist/random/shuffle.js.map +1 -1
- package/dist/random/source.cjs +1 -1
- package/dist/random/source.cjs.map +1 -1
- package/dist/random/source.js +1 -9
- package/dist/random/source.js.map +1 -1
- package/dist/string/_caseUtils.cjs +1 -1
- package/dist/string/_caseUtils.cjs.map +1 -1
- package/dist/string/_caseUtils.js +1 -12
- package/dist/string/_caseUtils.js.map +1 -1
- package/dist/string/camelCase.cjs +1 -1
- package/dist/string/camelCase.cjs.map +1 -1
- package/dist/string/camelCase.js +1 -8
- package/dist/string/camelCase.js.map +1 -1
- package/dist/string/escape.cjs +1 -1
- package/dist/string/escape.cjs.map +1 -1
- package/dist/string/escape.js +1 -14
- package/dist/string/escape.js.map +1 -1
- package/dist/string/index.js +1 -12
- package/dist/string/kebabCase.cjs +1 -1
- package/dist/string/kebabCase.cjs.map +1 -1
- package/dist/string/kebabCase.js +1 -8
- package/dist/string/kebabCase.js.map +1 -1
- package/dist/string/padCenter.cjs +1 -1
- package/dist/string/padCenter.cjs.map +1 -1
- package/dist/string/padCenter.js +1 -9
- package/dist/string/padCenter.js.map +1 -1
- package/dist/string/pascalCase.cjs +1 -1
- package/dist/string/pascalCase.cjs.map +1 -1
- package/dist/string/pascalCase.js +1 -8
- package/dist/string/pascalCase.js.map +1 -1
- package/dist/string/similarity.cjs +1 -1
- package/dist/string/similarity.cjs.map +1 -1
- package/dist/string/similarity.js +1 -22
- package/dist/string/similarity.js.map +1 -1
- package/dist/string/snakeCase.cjs +1 -1
- package/dist/string/snakeCase.cjs.map +1 -1
- package/dist/string/snakeCase.js +1 -8
- package/dist/string/snakeCase.js.map +1 -1
- package/dist/string/titleCase.cjs +1 -1
- package/dist/string/titleCase.cjs.map +1 -1
- package/dist/string/titleCase.js +1 -8
- package/dist/string/titleCase.js.map +1 -1
- package/dist/string/truncate.cjs +1 -1
- package/dist/string/truncate.cjs.map +1 -1
- package/dist/string/truncate.js +1 -15
- package/dist/string/truncate.js.map +1 -1
- package/dist/string/unescape.cjs +1 -1
- package/dist/string/unescape.cjs.map +1 -1
- package/dist/string/unescape.js +1 -14
- package/dist/string/unescape.js.map +1 -1
- package/dist/string/words.cjs +1 -1
- package/dist/string/words.cjs.map +1 -1
- package/dist/string/words.js +1 -9
- package/dist/string/words.js.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +13 -5
package/dist/cache/cache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","names":[],"sources":["../../src/cache/cache.ts"],"sourcesContent":["export type CacheOptions = {\n capacity?: number;\n now?: () => number;\n ttlMs?: number;\n};\n\ntype Entry<T> = {\n expiresAt: number | undefined;\n value: T;\n};\n\nexport interface Cache<K, T> {\n clear(): void;\n delete(key: K): boolean;\n entries(): ReadonlyArray<readonly [K, T]>;\n get(key: K): T | undefined;\n getOrLoad(key: K, load: () => Promise<T>): Promise<T>;\n set(key: K, value: T, options?: { ttlMs?: number }): void;\n readonly size: number;\n}\n\nexport function cache<K, T>({ capacity = Infinity, now = Date.now, ttlMs }: CacheOptions = {}): Cache<K, T> {\n if (capacity !== Infinity && (!Number.isInteger(capacity) || capacity < 1)) {\n throw new RangeError(`cache: capacity must be a positive integer or Infinity, got ${capacity}`);\n }\n\n const entries = new Map<K, Entry<T>>();\n const pending = new Map<K, Promise<T>>();\n const revisions = new Map<K, number>();\n let generation = 0;\n\n const advanceRevision = (key: K): number => {\n const revision = (revisions.get(key) ?? 0) + 1;\n\n revisions.set(key, revision);\n\n return revision;\n };\n\n const expiresAt = (duration: number | undefined): number | undefined => {\n if (duration === undefined || duration === Infinity) return undefined;\n\n if (!Number.isFinite(duration) || duration < 0) {\n throw new RangeError(`cache: ttlMs must be a non-negative finite number or Infinity, got ${duration}`);\n }\n\n return now() + duration;\n };\n\n const read = (key: K): T | undefined => {\n const entry = entries.get(key);\n\n if (!entry) return undefined;\n\n if (entry.expiresAt !== undefined && entry.expiresAt <= now()) {\n entries.delete(key);\n\n return undefined;\n }\n\n return entry.value;\n };\n\n const trim = (): void => {\n for (const [key, entry] of entries) {\n if (entry.expiresAt !== undefined && entry.expiresAt <= now()) entries.delete(key);\n }\n\n while (entries.size > capacity) {\n const oldest = entries.keys().next().value;\n\n if (oldest === undefined) return;\n\n entries.delete(oldest);\n }\n };\n\n const set = (key: K, value: T, options: { ttlMs?: number } = {}): void => {\n advanceRevision(key);\n entries.delete(key);\n entries.set(key, { expiresAt: expiresAt(options.ttlMs ?? ttlMs), value });\n trim();\n };\n\n const getOrLoad = (key: K, load: () => Promise<T>): Promise<T> => {\n const cached = read(key);\n\n if (cached !== undefined || entries.has(key)) return Promise.resolve(cached as T);\n\n const existing = pending.get(key);\n\n if (existing) return existing;\n\n const capturedGeneration = generation;\n const capturedRevision = advanceRevision(key);\n const result = load().then(\n (value) => {\n if (pending.get(key) === result) pending.delete(key);\n\n if (generation === capturedGeneration && revisions.get(key) === capturedRevision) {\n set(key, value);\n }\n\n return value;\n },\n (error: unknown) => {\n if (pending.get(key) === result) pending.delete(key);\n\n throw error;\n },\n );\n\n pending.set(key, result);\n\n return result;\n };\n\n return {\n clear: () => {\n generation++;\n entries.clear();\n pending.clear();\n revisions.clear();\n },\n delete: (key) => {\n pending.delete(key);\n advanceRevision(key);\n\n return entries.delete(key);\n },\n entries: () => {\n trim();\n return [...entries].map(([key, entry]) => [key, entry.value] as const);\n },\n get: read,\n getOrLoad,\n set,\n get size() {\n return entries.size;\n },\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"cache.js","names":[],"sources":["../../src/cache/cache.ts"],"sourcesContent":["export type CacheOptions = {\n capacity?: number;\n now?: () => number;\n ttlMs?: number;\n};\n\ntype Entry<T> = {\n expiresAt: number | undefined;\n value: T;\n};\n\nexport interface Cache<K, T> {\n clear(): void;\n delete(key: K): boolean;\n entries(): ReadonlyArray<readonly [K, T]>;\n get(key: K): T | undefined;\n getOrLoad(key: K, load: () => Promise<T>): Promise<T>;\n set(key: K, value: T, options?: { ttlMs?: number }): void;\n readonly size: number;\n}\n\nexport function cache<K, T>({ capacity = Infinity, now = Date.now, ttlMs }: CacheOptions = {}): Cache<K, T> {\n if (capacity !== Infinity && (!Number.isInteger(capacity) || capacity < 1)) {\n throw new RangeError(`cache: capacity must be a positive integer or Infinity, got ${capacity}`);\n }\n\n const entries = new Map<K, Entry<T>>();\n const pending = new Map<K, Promise<T>>();\n const revisions = new Map<K, number>();\n let generation = 0;\n\n const advanceRevision = (key: K): number => {\n const revision = (revisions.get(key) ?? 0) + 1;\n\n revisions.set(key, revision);\n\n return revision;\n };\n\n const expiresAt = (duration: number | undefined): number | undefined => {\n if (duration === undefined || duration === Infinity) return undefined;\n\n if (!Number.isFinite(duration) || duration < 0) {\n throw new RangeError(`cache: ttlMs must be a non-negative finite number or Infinity, got ${duration}`);\n }\n\n return now() + duration;\n };\n\n const read = (key: K): T | undefined => {\n const entry = entries.get(key);\n\n if (!entry) return undefined;\n\n if (entry.expiresAt !== undefined && entry.expiresAt <= now()) {\n entries.delete(key);\n\n return undefined;\n }\n\n return entry.value;\n };\n\n const trim = (): void => {\n for (const [key, entry] of entries) {\n if (entry.expiresAt !== undefined && entry.expiresAt <= now()) entries.delete(key);\n }\n\n while (entries.size > capacity) {\n const oldest = entries.keys().next().value;\n\n if (oldest === undefined) return;\n\n entries.delete(oldest);\n }\n };\n\n const set = (key: K, value: T, options: { ttlMs?: number } = {}): void => {\n advanceRevision(key);\n entries.delete(key);\n entries.set(key, { expiresAt: expiresAt(options.ttlMs ?? ttlMs), value });\n trim();\n };\n\n const getOrLoad = (key: K, load: () => Promise<T>): Promise<T> => {\n const cached = read(key);\n\n if (cached !== undefined || entries.has(key)) return Promise.resolve(cached as T);\n\n const existing = pending.get(key);\n\n if (existing) return existing;\n\n const capturedGeneration = generation;\n const capturedRevision = advanceRevision(key);\n const result = load().then(\n (value) => {\n if (pending.get(key) === result) pending.delete(key);\n\n if (generation === capturedGeneration && revisions.get(key) === capturedRevision) {\n set(key, value);\n }\n\n return value;\n },\n (error: unknown) => {\n if (pending.get(key) === result) pending.delete(key);\n\n throw error;\n },\n );\n\n pending.set(key, result);\n\n return result;\n };\n\n return {\n clear: () => {\n generation++;\n entries.clear();\n pending.clear();\n revisions.clear();\n },\n delete: (key) => {\n pending.delete(key);\n advanceRevision(key);\n\n return entries.delete(key);\n },\n entries: () => {\n trim();\n return [...entries].map(([key, entry]) => [key, entry.value] as const);\n },\n get: read,\n getOrLoad,\n set,\n get size() {\n return entries.size;\n },\n };\n}\n"],"mappings":"AAqBA,SAAgB,MAAY,CAAE,WAAW,IAAU,MAAM,KAAK,IAAK,SAAwB,CAAC,EAAgB,CAC1G,GAAI,IAAa,MAAa,CAAC,OAAO,UAAU,CAAQ,GAAK,EAAW,GACtE,MAAU,WAAW,+DAA+D,GAAU,EAGhG,IAAM,EAAU,IAAI,IACd,EAAU,IAAI,IACd,EAAY,IAAI,IAClB,EAAa,EAEX,gBAAmB,GAAmB,CAC1C,IAAM,GAAY,EAAU,IAAI,CAAG,GAAK,GAAK,EAI7C,OAFA,EAAU,IAAI,EAAK,CAAQ,EAEpB,CACT,EAEM,UAAa,GAAqD,CAClE,OAAa,IAAA,IAAa,IAAa,IAE3C,IAAI,CAAC,OAAO,SAAS,CAAQ,GAAK,EAAW,EAC3C,MAAU,WAAW,sEAAsE,GAAU,EAGvG,OAAO,EAAI,EAAI,CAHwF,CAIzG,EAEM,KAAQ,GAA0B,CACtC,IAAM,EAAQ,EAAQ,IAAI,CAAG,EAExB,KAEL,IAAI,EAAM,YAAc,IAAA,IAAa,EAAM,WAAa,EAAI,EAAG,CAC7D,EAAQ,OAAO,CAAG,EAElB,MACF,CAEA,OAAO,EAAM,KAFb,CAGF,EAEM,SAAmB,CACvB,IAAK,GAAM,CAAC,EAAK,KAAU,EACrB,EAAM,YAAc,IAAA,IAAa,EAAM,WAAa,EAAI,GAAG,EAAQ,OAAO,CAAG,EAGnF,KAAO,EAAQ,KAAO,GAAU,CAC9B,IAAM,EAAS,EAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,MAErC,GAAI,IAAW,IAAA,GAAW,OAE1B,EAAQ,OAAO,CAAM,CACvB,CACF,EAEM,KAAO,EAAQ,EAAU,EAA8B,CAAC,IAAY,CACxE,gBAAgB,CAAG,EACnB,EAAQ,OAAO,CAAG,EAClB,EAAQ,IAAI,EAAK,CAAE,UAAW,UAAU,EAAQ,OAAS,CAAK,EAAG,OAAM,CAAC,EACxE,KAAK,CACP,EAEM,WAAa,EAAQ,IAAuC,CAChE,IAAM,EAAS,KAAK,CAAG,EAEvB,GAAI,IAAW,IAAA,IAAa,EAAQ,IAAI,CAAG,EAAG,OAAO,QAAQ,QAAQ,CAAW,EAEhF,IAAM,EAAW,EAAQ,IAAI,CAAG,EAEhC,GAAI,EAAU,OAAO,EAErB,IAAM,EAAqB,EACrB,EAAmB,gBAAgB,CAAG,EACtC,EAAS,EAAK,CAAC,CAAC,KACnB,IACK,EAAQ,IAAI,CAAG,IAAM,GAAQ,EAAQ,OAAO,CAAG,EAE/C,IAAe,GAAsB,EAAU,IAAI,CAAG,IAAM,GAC9D,IAAI,EAAK,CAAK,EAGT,GAER,GAAmB,CAGlB,MAFI,EAAQ,IAAI,CAAG,IAAM,GAAQ,EAAQ,OAAO,CAAG,EAE7C,CACR,CACF,EAIA,OAFA,EAAQ,IAAI,EAAK,CAAM,EAEhB,CACT,EAEA,MAAO,CACL,UAAa,CACX,IACA,EAAQ,MAAM,EACd,EAAQ,MAAM,EACd,EAAU,MAAM,CAClB,EACA,OAAS,IACP,EAAQ,OAAO,CAAG,EAClB,gBAAgB,CAAG,EAEZ,EAAQ,OAAO,CAAG,GAE3B,aACE,KAAK,EACE,CAAC,GAAG,CAAO,CAAC,CAAC,KAAK,CAAC,EAAK,KAAW,CAAC,EAAK,EAAM,KAAK,CAAU,GAEvE,IAAK,KACL,UACA,IACA,IAAI,MAAO,CACT,OAAO,EAAQ,IACjB,CACF,CACF"}
|
package/dist/cache/index.js
CHANGED
package/dist/cache/memo.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../_common/_lruMap.cjs"),t=require("../errors.cjs");var n=`\0undefined\0`,r=`\0NaN\0`,i=`\0+Infinity\0`,a=`\0-Infinity\0`,o=`\0function\0`,s=0,c=new WeakMap;function
|
|
1
|
+
const e=require("../_common/_lruMap.cjs"),t=require("../errors.cjs");var n=`\0undefined\0`,r=`\0NaN\0`,i=`\0+Infinity\0`,a=`\0-Infinity\0`,o=`\0function\0`,s=0,c=new WeakMap;function idForFunction(e){let t=c.get(e);return t===void 0&&(t=s++,c.set(e,t)),t}var defaultKey=e=>{try{return JSON.stringify(e,(e,t)=>t===void 0?n:typeof t==`number`&&Number.isNaN(t)?r:t===1/0?i:t===-1/0?a:typeof t==`function`?`${o}${idForFunction(t)}`:t)}catch(e){let n=e instanceof Error&&e.message?` Reason: ${e.message}`:``;throw new t.ArsenalSerializationError(`[arsenal/memo] Failed to serialize memo arguments. Provide options.key for non-serializable arguments.${n}`,{cause:e})}};function memo(t,{key:n,maxSize:r=1/0}={}){if(r!==1/0&&(!Number.isInteger(r)||r<1))throw RangeError(`memo: maxSize must be a positive integer or Infinity, got ${r}`);let i=new e.LruMap(r),resolveKey=(...e)=>n?n(...e):defaultKey(e),memoized=(...e)=>{let n=resolveKey(...e);if(i.has(n)){let e=i.get(n);return i.set(n,e),e}let r=t(...e);return i.set(n,r),r},a=Object.assign(memoized,{clear:()=>i.clear(),invalidate:(...e)=>{i.delete(resolveKey(...e))}});return Object.defineProperty(a,"size",{get:()=>i.size}),a}exports.memo=memo;
|
|
2
2
|
//# sourceMappingURL=memo.cjs.map
|
package/dist/cache/memo.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memo.cjs","names":[],"sources":["../../src/cache/memo.ts"],"sourcesContent":["import { LruMap } from '../_common/_lruMap';\nimport { ArsenalSerializationError } from '../errors';\nimport type { Fn } from '../types';\n\nexport type MemoOptions<T extends Fn> = {\n key?: (...args: Parameters<T>) => PropertyKey;\n maxSize?: number;\n};\n\nexport type Memoized<T extends Fn> = ((...args: Parameters<T>) => ReturnType<T>) & {\n clear(): void;\n invalidate(...args: Parameters<T>): void;\n readonly size: number;\n};\n\nconst UNDEFINED_SENTINEL = '\\x00undefined\\x00';\nconst NAN_SENTINEL = '\\x00NaN\\x00';\nconst POSITIVE_INFINITY_SENTINEL = '\\x00+Infinity\\x00';\nconst NEGATIVE_INFINITY_SENTINEL = '\\x00-Infinity\\x00';\nconst FUNCTION_SENTINEL = '\\x00function\\x00';\n\nlet functionIdCounter = 0;\nconst functionIds = new WeakMap<Fn, number>();\n\n/** Returns a stable per-identity id for a function so distinct functions never collide as cache keys. */\nfunction idForFunction(fn: Fn): number {\n let id = functionIds.get(fn);\n\n if (id === undefined) {\n id = functionIdCounter++;\n functionIds.set(fn, id);\n }\n\n return id;\n}\n\nconst defaultKey = (args: unknown[]): string => {\n try {\n return JSON.stringify(args, (_, value) => {\n if (value === undefined) return UNDEFINED_SENTINEL;\n\n if (typeof value === 'number' && Number.isNaN(value)) return NAN_SENTINEL;\n\n if (value === Number.POSITIVE_INFINITY) return POSITIVE_INFINITY_SENTINEL;\n\n if (value === Number.NEGATIVE_INFINITY) return NEGATIVE_INFINITY_SENTINEL;\n\n if (typeof value === 'function') return `${FUNCTION_SENTINEL}${idForFunction(value as Fn)}`;\n\n return value;\n });\n } catch (error) {\n const reason = error instanceof Error && error.message ? ` Reason: ${error.message}` : '';\n\n throw new ArsenalSerializationError(\n `[arsenal/memo] Failed to serialize memo arguments. Provide options.key for non-serializable arguments.${reason}`,\n { cause: error },\n );\n }\n};\n\n/** Excludes async functions at the type level so callers cannot accidentally memoize a Promise. */\ntype SyncFn<T extends Fn> = ReturnType<T> extends Promise<unknown> ? never : T;\n\n/**\n * Memoizes a **sync** function with optional LRU eviction by cache size.\n * The returned function exposes `.clear()` and `.invalidate(...args)` methods.\n *\n * **Do not pass async functions.** `memo` caches the raw `Promise` object, not\n * the resolved value — subsequent calls return the same stale Promise. Use\n * `cache.getOrLoad` for async caching with TTL and load deduplication.\n *\n * @example\n * ```ts\n * const add = (x: number, y: number) => x + y;\n * const memoAdd = memo(add, { maxSize: 100 });\n *\n * memoAdd(1, 2); // 3 (computed)\n * memoAdd(1, 2); // 3 (from cache)\n * memoAdd.invalidate(1, 2); // remove specific entry\n * memoAdd.clear(); // wipe entire cache\n * ```\n *\n * @param fn - The sync function to memoize. Must not return a Promise.\n * @param [options.maxSize] - Maximum cache size. Oldest entries evicted when exceeded (LRU). Default: `Infinity`.\n * @param [options.key] - Custom cache key function. Defaults to `JSON.stringify(args)`.\n *\n * @throws {RangeError} If `maxSize` is not a positive integer or `Infinity`.\n */\nexport function memo<T extends Fn>(fn: SyncFn<T>, { key, maxSize = Infinity }: MemoOptions<T> = {}): Memoized<T> {\n if (maxSize !== Infinity && (!Number.isInteger(maxSize) || maxSize < 1)) {\n throw new RangeError(`memo: maxSize must be a positive integer or Infinity, got ${maxSize}`);\n }\n\n const cache = new LruMap<PropertyKey, ReturnType<T>>(maxSize);\n\n const resolveKey = (...args: Parameters<T>): PropertyKey => (key ? key(...args) : defaultKey(args));\n\n const memoized = (...args: Parameters<T>): ReturnType<T> => {\n const cacheKey = resolveKey(...args);\n\n if (cache.has(cacheKey)) {\n const cached = cache.get(cacheKey)!;\n\n cache.set(cacheKey, cached);\n\n return cached;\n }\n\n const value = fn(...args) as ReturnType<T>;\n\n cache.set(cacheKey, value);\n\n return value;\n };\n\n const result = Object.assign(memoized, {\n clear: () => cache.clear(),\n invalidate: (...args: Parameters<T>): void => {\n cache.delete(resolveKey(...args));\n },\n });\n\n Object.defineProperty(result, 'size', { get: () => cache.size });\n\n return result as Memoized<T>;\n}\n"],"mappings":"qEAeA,IAAM,EAAqB,gBACrB,EAAe,UACf,EAA6B,gBAC7B,EAA6B,gBAC7B,EAAoB,eAEtB,EAAoB,EAClB,EAAc,IAAI,QAGxB,SAAS,
|
|
1
|
+
{"version":3,"file":"memo.cjs","names":[],"sources":["../../src/cache/memo.ts"],"sourcesContent":["import { LruMap } from '../_common/_lruMap';\nimport { ArsenalSerializationError } from '../errors';\nimport type { Fn } from '../types';\n\nexport type MemoOptions<T extends Fn> = {\n key?: (...args: Parameters<T>) => PropertyKey;\n maxSize?: number;\n};\n\nexport type Memoized<T extends Fn> = ((...args: Parameters<T>) => ReturnType<T>) & {\n clear(): void;\n invalidate(...args: Parameters<T>): void;\n readonly size: number;\n};\n\nconst UNDEFINED_SENTINEL = '\\x00undefined\\x00';\nconst NAN_SENTINEL = '\\x00NaN\\x00';\nconst POSITIVE_INFINITY_SENTINEL = '\\x00+Infinity\\x00';\nconst NEGATIVE_INFINITY_SENTINEL = '\\x00-Infinity\\x00';\nconst FUNCTION_SENTINEL = '\\x00function\\x00';\n\nlet functionIdCounter = 0;\nconst functionIds = new WeakMap<Fn, number>();\n\n/** Returns a stable per-identity id for a function so distinct functions never collide as cache keys. */\nfunction idForFunction(fn: Fn): number {\n let id = functionIds.get(fn);\n\n if (id === undefined) {\n id = functionIdCounter++;\n functionIds.set(fn, id);\n }\n\n return id;\n}\n\nconst defaultKey = (args: unknown[]): string => {\n try {\n return JSON.stringify(args, (_, value) => {\n if (value === undefined) return UNDEFINED_SENTINEL;\n\n if (typeof value === 'number' && Number.isNaN(value)) return NAN_SENTINEL;\n\n if (value === Number.POSITIVE_INFINITY) return POSITIVE_INFINITY_SENTINEL;\n\n if (value === Number.NEGATIVE_INFINITY) return NEGATIVE_INFINITY_SENTINEL;\n\n if (typeof value === 'function') return `${FUNCTION_SENTINEL}${idForFunction(value as Fn)}`;\n\n return value;\n });\n } catch (error) {\n const reason = error instanceof Error && error.message ? ` Reason: ${error.message}` : '';\n\n throw new ArsenalSerializationError(\n `[arsenal/memo] Failed to serialize memo arguments. Provide options.key for non-serializable arguments.${reason}`,\n { cause: error },\n );\n }\n};\n\n/** Excludes async functions at the type level so callers cannot accidentally memoize a Promise. */\ntype SyncFn<T extends Fn> = ReturnType<T> extends Promise<unknown> ? never : T;\n\n/**\n * Memoizes a **sync** function with optional LRU eviction by cache size.\n * The returned function exposes `.clear()` and `.invalidate(...args)` methods.\n *\n * **Do not pass async functions.** `memo` caches the raw `Promise` object, not\n * the resolved value — subsequent calls return the same stale Promise. Use\n * `cache.getOrLoad` for async caching with TTL and load deduplication.\n *\n * @example\n * ```ts\n * const add = (x: number, y: number) => x + y;\n * const memoAdd = memo(add, { maxSize: 100 });\n *\n * memoAdd(1, 2); // 3 (computed)\n * memoAdd(1, 2); // 3 (from cache)\n * memoAdd.invalidate(1, 2); // remove specific entry\n * memoAdd.clear(); // wipe entire cache\n * ```\n *\n * @param fn - The sync function to memoize. Must not return a Promise.\n * @param [options.maxSize] - Maximum cache size. Oldest entries evicted when exceeded (LRU). Default: `Infinity`.\n * @param [options.key] - Custom cache key function. Defaults to `JSON.stringify(args)`.\n *\n * @throws {RangeError} If `maxSize` is not a positive integer or `Infinity`.\n */\nexport function memo<T extends Fn>(fn: SyncFn<T>, { key, maxSize = Infinity }: MemoOptions<T> = {}): Memoized<T> {\n if (maxSize !== Infinity && (!Number.isInteger(maxSize) || maxSize < 1)) {\n throw new RangeError(`memo: maxSize must be a positive integer or Infinity, got ${maxSize}`);\n }\n\n const cache = new LruMap<PropertyKey, ReturnType<T>>(maxSize);\n\n const resolveKey = (...args: Parameters<T>): PropertyKey => (key ? key(...args) : defaultKey(args));\n\n const memoized = (...args: Parameters<T>): ReturnType<T> => {\n const cacheKey = resolveKey(...args);\n\n if (cache.has(cacheKey)) {\n const cached = cache.get(cacheKey)!;\n\n cache.set(cacheKey, cached);\n\n return cached;\n }\n\n const value = fn(...args) as ReturnType<T>;\n\n cache.set(cacheKey, value);\n\n return value;\n };\n\n const result = Object.assign(memoized, {\n clear: () => cache.clear(),\n invalidate: (...args: Parameters<T>): void => {\n cache.delete(resolveKey(...args));\n },\n });\n\n Object.defineProperty(result, 'size', { get: () => cache.size });\n\n return result as Memoized<T>;\n}\n"],"mappings":"qEAeA,IAAM,EAAqB,gBACrB,EAAe,UACf,EAA6B,gBAC7B,EAA6B,gBAC7B,EAAoB,eAEtB,EAAoB,EAClB,EAAc,IAAI,QAGxB,SAAS,cAAc,EAAgB,CACrC,IAAI,EAAK,EAAY,IAAI,CAAE,EAO3B,OALI,IAAO,IAAA,KACT,EAAK,IACL,EAAY,IAAI,EAAI,CAAE,GAGjB,CACT,CAEA,IAAM,WAAc,GAA4B,CAC9C,GAAI,CACF,OAAO,KAAK,UAAU,GAAO,EAAG,IAC1B,IAAU,IAAA,GAAkB,EAE5B,OAAO,GAAU,UAAY,OAAO,MAAM,CAAK,EAAU,EAEzD,IAAU,IAAiC,EAE3C,IAAU,KAAiC,EAE3C,OAAO,GAAU,WAAmB,GAAG,IAAoB,cAAc,CAAW,IAEjF,CACR,CACH,OAAS,EAAO,CACd,IAAM,EAAS,aAAiB,OAAS,EAAM,QAAU,YAAY,EAAM,UAAY,GAEvF,MAAM,IAAI,EAAA,0BACR,yGAAyG,IACzG,CAAE,MAAO,CAAM,CACjB,CACF,CACF,EA8BA,SAAgB,KAAmB,EAAe,CAAE,MAAK,UAAU,KAA6B,CAAC,EAAgB,CAC/G,GAAI,IAAY,MAAa,CAAC,OAAO,UAAU,CAAO,GAAK,EAAU,GACnE,MAAU,WAAW,6DAA6D,GAAS,EAG7F,IAAM,EAAQ,IAAI,EAAA,OAAmC,CAAO,EAEtD,YAAc,GAAG,IAAsC,EAAM,EAAI,GAAG,CAAI,EAAI,WAAW,CAAI,EAE3F,UAAY,GAAG,IAAuC,CAC1D,IAAM,EAAW,WAAW,GAAG,CAAI,EAEnC,GAAI,EAAM,IAAI,CAAQ,EAAG,CACvB,IAAM,EAAS,EAAM,IAAI,CAAQ,EAIjC,OAFA,EAAM,IAAI,EAAU,CAAM,EAEnB,CACT,CAEA,IAAM,EAAQ,EAAG,GAAG,CAAI,EAIxB,OAFA,EAAM,IAAI,EAAU,CAAK,EAElB,CACT,EAEM,EAAS,OAAO,OAAO,SAAU,CACrC,UAAa,EAAM,MAAM,EACzB,YAAa,GAAG,IAA8B,CAC5C,EAAM,OAAO,WAAW,GAAG,CAAI,CAAC,CAClC,CACF,CAAC,EAID,OAFA,OAAO,eAAe,EAAQ,OAAQ,CAAE,QAAW,EAAM,IAAK,CAAC,EAExD,CACT"}
|
package/dist/cache/memo.js
CHANGED
|
@@ -1,38 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ArsenalSerializationError as t } from "../errors.js";
|
|
3
|
-
//#region src/cache/memo.ts
|
|
4
|
-
var n = "\0undefined\0", r = "\0NaN\0", i = "\0+Infinity\0", a = "\0-Infinity\0", o = "\0function\0", s = 0, c = /* @__PURE__ */ new WeakMap();
|
|
5
|
-
function l(e) {
|
|
6
|
-
let t = c.get(e);
|
|
7
|
-
return t === void 0 && (t = s++, c.set(e, t)), t;
|
|
8
|
-
}
|
|
9
|
-
var u = (e) => {
|
|
10
|
-
try {
|
|
11
|
-
return JSON.stringify(e, (e, t) => t === void 0 ? n : typeof t == "number" && Number.isNaN(t) ? r : t === Infinity ? i : t === -Infinity ? a : typeof t == "function" ? `${o}${l(t)}` : t);
|
|
12
|
-
} catch (e) {
|
|
13
|
-
let n = e instanceof Error && e.message ? ` Reason: ${e.message}` : "";
|
|
14
|
-
throw new t(`[arsenal/memo] Failed to serialize memo arguments. Provide options.key for non-serializable arguments.${n}`, { cause: e });
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
function d(t, { key: n, maxSize: r = Infinity } = {}) {
|
|
18
|
-
if (r !== Infinity && (!Number.isInteger(r) || r < 1)) throw RangeError(`memo: maxSize must be a positive integer or Infinity, got ${r}`);
|
|
19
|
-
let i = new e(r), a = (...e) => n ? n(...e) : u(e), o = Object.assign((...e) => {
|
|
20
|
-
let n = a(...e);
|
|
21
|
-
if (i.has(n)) {
|
|
22
|
-
let e = i.get(n);
|
|
23
|
-
return i.set(n, e), e;
|
|
24
|
-
}
|
|
25
|
-
let r = t(...e);
|
|
26
|
-
return i.set(n, r), r;
|
|
27
|
-
}, {
|
|
28
|
-
clear: () => i.clear(),
|
|
29
|
-
invalidate: (...e) => {
|
|
30
|
-
i.delete(a(...e));
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
return Object.defineProperty(o, "size", { get: () => i.size }), o;
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
export { d as memo };
|
|
37
|
-
|
|
1
|
+
import{LruMap as e}from"../_common/_lruMap.js";import{ArsenalSerializationError as t}from"../errors.js";var n=`\0undefined\0`,r=`\0NaN\0`,i=`\0+Infinity\0`,a=`\0-Infinity\0`,o=`\0function\0`,s=0,c=new WeakMap;function idForFunction(e){let t=c.get(e);return t===void 0&&(t=s++,c.set(e,t)),t}var defaultKey=e=>{try{return JSON.stringify(e,(e,t)=>t===void 0?n:typeof t==`number`&&Number.isNaN(t)?r:t===1/0?i:t===-1/0?a:typeof t==`function`?`${o}${idForFunction(t)}`:t)}catch(e){let n=e instanceof Error&&e.message?` Reason: ${e.message}`:``;throw new t(`[arsenal/memo] Failed to serialize memo arguments. Provide options.key for non-serializable arguments.${n}`,{cause:e})}};function memo(t,{key:n,maxSize:r=1/0}={}){if(r!==1/0&&(!Number.isInteger(r)||r<1))throw RangeError(`memo: maxSize must be a positive integer or Infinity, got ${r}`);let i=new e(r),resolveKey=(...e)=>n?n(...e):defaultKey(e),memoized=(...e)=>{let n=resolveKey(...e);if(i.has(n)){let e=i.get(n);return i.set(n,e),e}let r=t(...e);return i.set(n,r),r},a=Object.assign(memoized,{clear:()=>i.clear(),invalidate:(...e)=>{i.delete(resolveKey(...e))}});return Object.defineProperty(a,"size",{get:()=>i.size}),a}export{memo};
|
|
38
2
|
//# sourceMappingURL=memo.js.map
|
package/dist/cache/memo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memo.js","names":[],"sources":["../../src/cache/memo.ts"],"sourcesContent":["import { LruMap } from '../_common/_lruMap';\nimport { ArsenalSerializationError } from '../errors';\nimport type { Fn } from '../types';\n\nexport type MemoOptions<T extends Fn> = {\n key?: (...args: Parameters<T>) => PropertyKey;\n maxSize?: number;\n};\n\nexport type Memoized<T extends Fn> = ((...args: Parameters<T>) => ReturnType<T>) & {\n clear(): void;\n invalidate(...args: Parameters<T>): void;\n readonly size: number;\n};\n\nconst UNDEFINED_SENTINEL = '\\x00undefined\\x00';\nconst NAN_SENTINEL = '\\x00NaN\\x00';\nconst POSITIVE_INFINITY_SENTINEL = '\\x00+Infinity\\x00';\nconst NEGATIVE_INFINITY_SENTINEL = '\\x00-Infinity\\x00';\nconst FUNCTION_SENTINEL = '\\x00function\\x00';\n\nlet functionIdCounter = 0;\nconst functionIds = new WeakMap<Fn, number>();\n\n/** Returns a stable per-identity id for a function so distinct functions never collide as cache keys. */\nfunction idForFunction(fn: Fn): number {\n let id = functionIds.get(fn);\n\n if (id === undefined) {\n id = functionIdCounter++;\n functionIds.set(fn, id);\n }\n\n return id;\n}\n\nconst defaultKey = (args: unknown[]): string => {\n try {\n return JSON.stringify(args, (_, value) => {\n if (value === undefined) return UNDEFINED_SENTINEL;\n\n if (typeof value === 'number' && Number.isNaN(value)) return NAN_SENTINEL;\n\n if (value === Number.POSITIVE_INFINITY) return POSITIVE_INFINITY_SENTINEL;\n\n if (value === Number.NEGATIVE_INFINITY) return NEGATIVE_INFINITY_SENTINEL;\n\n if (typeof value === 'function') return `${FUNCTION_SENTINEL}${idForFunction(value as Fn)}`;\n\n return value;\n });\n } catch (error) {\n const reason = error instanceof Error && error.message ? ` Reason: ${error.message}` : '';\n\n throw new ArsenalSerializationError(\n `[arsenal/memo] Failed to serialize memo arguments. Provide options.key for non-serializable arguments.${reason}`,\n { cause: error },\n );\n }\n};\n\n/** Excludes async functions at the type level so callers cannot accidentally memoize a Promise. */\ntype SyncFn<T extends Fn> = ReturnType<T> extends Promise<unknown> ? never : T;\n\n/**\n * Memoizes a **sync** function with optional LRU eviction by cache size.\n * The returned function exposes `.clear()` and `.invalidate(...args)` methods.\n *\n * **Do not pass async functions.** `memo` caches the raw `Promise` object, not\n * the resolved value — subsequent calls return the same stale Promise. Use\n * `cache.getOrLoad` for async caching with TTL and load deduplication.\n *\n * @example\n * ```ts\n * const add = (x: number, y: number) => x + y;\n * const memoAdd = memo(add, { maxSize: 100 });\n *\n * memoAdd(1, 2); // 3 (computed)\n * memoAdd(1, 2); // 3 (from cache)\n * memoAdd.invalidate(1, 2); // remove specific entry\n * memoAdd.clear(); // wipe entire cache\n * ```\n *\n * @param fn - The sync function to memoize. Must not return a Promise.\n * @param [options.maxSize] - Maximum cache size. Oldest entries evicted when exceeded (LRU). Default: `Infinity`.\n * @param [options.key] - Custom cache key function. Defaults to `JSON.stringify(args)`.\n *\n * @throws {RangeError} If `maxSize` is not a positive integer or `Infinity`.\n */\nexport function memo<T extends Fn>(fn: SyncFn<T>, { key, maxSize = Infinity }: MemoOptions<T> = {}): Memoized<T> {\n if (maxSize !== Infinity && (!Number.isInteger(maxSize) || maxSize < 1)) {\n throw new RangeError(`memo: maxSize must be a positive integer or Infinity, got ${maxSize}`);\n }\n\n const cache = new LruMap<PropertyKey, ReturnType<T>>(maxSize);\n\n const resolveKey = (...args: Parameters<T>): PropertyKey => (key ? key(...args) : defaultKey(args));\n\n const memoized = (...args: Parameters<T>): ReturnType<T> => {\n const cacheKey = resolveKey(...args);\n\n if (cache.has(cacheKey)) {\n const cached = cache.get(cacheKey)!;\n\n cache.set(cacheKey, cached);\n\n return cached;\n }\n\n const value = fn(...args) as ReturnType<T>;\n\n cache.set(cacheKey, value);\n\n return value;\n };\n\n const result = Object.assign(memoized, {\n clear: () => cache.clear(),\n invalidate: (...args: Parameters<T>): void => {\n cache.delete(resolveKey(...args));\n },\n });\n\n Object.defineProperty(result, 'size', { get: () => cache.size });\n\n return result as Memoized<T>;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"memo.js","names":[],"sources":["../../src/cache/memo.ts"],"sourcesContent":["import { LruMap } from '../_common/_lruMap';\nimport { ArsenalSerializationError } from '../errors';\nimport type { Fn } from '../types';\n\nexport type MemoOptions<T extends Fn> = {\n key?: (...args: Parameters<T>) => PropertyKey;\n maxSize?: number;\n};\n\nexport type Memoized<T extends Fn> = ((...args: Parameters<T>) => ReturnType<T>) & {\n clear(): void;\n invalidate(...args: Parameters<T>): void;\n readonly size: number;\n};\n\nconst UNDEFINED_SENTINEL = '\\x00undefined\\x00';\nconst NAN_SENTINEL = '\\x00NaN\\x00';\nconst POSITIVE_INFINITY_SENTINEL = '\\x00+Infinity\\x00';\nconst NEGATIVE_INFINITY_SENTINEL = '\\x00-Infinity\\x00';\nconst FUNCTION_SENTINEL = '\\x00function\\x00';\n\nlet functionIdCounter = 0;\nconst functionIds = new WeakMap<Fn, number>();\n\n/** Returns a stable per-identity id for a function so distinct functions never collide as cache keys. */\nfunction idForFunction(fn: Fn): number {\n let id = functionIds.get(fn);\n\n if (id === undefined) {\n id = functionIdCounter++;\n functionIds.set(fn, id);\n }\n\n return id;\n}\n\nconst defaultKey = (args: unknown[]): string => {\n try {\n return JSON.stringify(args, (_, value) => {\n if (value === undefined) return UNDEFINED_SENTINEL;\n\n if (typeof value === 'number' && Number.isNaN(value)) return NAN_SENTINEL;\n\n if (value === Number.POSITIVE_INFINITY) return POSITIVE_INFINITY_SENTINEL;\n\n if (value === Number.NEGATIVE_INFINITY) return NEGATIVE_INFINITY_SENTINEL;\n\n if (typeof value === 'function') return `${FUNCTION_SENTINEL}${idForFunction(value as Fn)}`;\n\n return value;\n });\n } catch (error) {\n const reason = error instanceof Error && error.message ? ` Reason: ${error.message}` : '';\n\n throw new ArsenalSerializationError(\n `[arsenal/memo] Failed to serialize memo arguments. Provide options.key for non-serializable arguments.${reason}`,\n { cause: error },\n );\n }\n};\n\n/** Excludes async functions at the type level so callers cannot accidentally memoize a Promise. */\ntype SyncFn<T extends Fn> = ReturnType<T> extends Promise<unknown> ? never : T;\n\n/**\n * Memoizes a **sync** function with optional LRU eviction by cache size.\n * The returned function exposes `.clear()` and `.invalidate(...args)` methods.\n *\n * **Do not pass async functions.** `memo` caches the raw `Promise` object, not\n * the resolved value — subsequent calls return the same stale Promise. Use\n * `cache.getOrLoad` for async caching with TTL and load deduplication.\n *\n * @example\n * ```ts\n * const add = (x: number, y: number) => x + y;\n * const memoAdd = memo(add, { maxSize: 100 });\n *\n * memoAdd(1, 2); // 3 (computed)\n * memoAdd(1, 2); // 3 (from cache)\n * memoAdd.invalidate(1, 2); // remove specific entry\n * memoAdd.clear(); // wipe entire cache\n * ```\n *\n * @param fn - The sync function to memoize. Must not return a Promise.\n * @param [options.maxSize] - Maximum cache size. Oldest entries evicted when exceeded (LRU). Default: `Infinity`.\n * @param [options.key] - Custom cache key function. Defaults to `JSON.stringify(args)`.\n *\n * @throws {RangeError} If `maxSize` is not a positive integer or `Infinity`.\n */\nexport function memo<T extends Fn>(fn: SyncFn<T>, { key, maxSize = Infinity }: MemoOptions<T> = {}): Memoized<T> {\n if (maxSize !== Infinity && (!Number.isInteger(maxSize) || maxSize < 1)) {\n throw new RangeError(`memo: maxSize must be a positive integer or Infinity, got ${maxSize}`);\n }\n\n const cache = new LruMap<PropertyKey, ReturnType<T>>(maxSize);\n\n const resolveKey = (...args: Parameters<T>): PropertyKey => (key ? key(...args) : defaultKey(args));\n\n const memoized = (...args: Parameters<T>): ReturnType<T> => {\n const cacheKey = resolveKey(...args);\n\n if (cache.has(cacheKey)) {\n const cached = cache.get(cacheKey)!;\n\n cache.set(cacheKey, cached);\n\n return cached;\n }\n\n const value = fn(...args) as ReturnType<T>;\n\n cache.set(cacheKey, value);\n\n return value;\n };\n\n const result = Object.assign(memoized, {\n clear: () => cache.clear(),\n invalidate: (...args: Parameters<T>): void => {\n cache.delete(resolveKey(...args));\n },\n });\n\n Object.defineProperty(result, 'size', { get: () => cache.size });\n\n return result as Memoized<T>;\n}\n"],"mappings":"wGAeA,IAAM,EAAqB,gBACrB,EAAe,UACf,EAA6B,gBAC7B,EAA6B,gBAC7B,EAAoB,eAEtB,EAAoB,EAClB,EAAc,IAAI,QAGxB,SAAS,cAAc,EAAgB,CACrC,IAAI,EAAK,EAAY,IAAI,CAAE,EAO3B,OALI,IAAO,IAAA,KACT,EAAK,IACL,EAAY,IAAI,EAAI,CAAE,GAGjB,CACT,CAEA,IAAM,WAAc,GAA4B,CAC9C,GAAI,CACF,OAAO,KAAK,UAAU,GAAO,EAAG,IAC1B,IAAU,IAAA,GAAkB,EAE5B,OAAO,GAAU,UAAY,OAAO,MAAM,CAAK,EAAU,EAEzD,IAAU,IAAiC,EAE3C,IAAU,KAAiC,EAE3C,OAAO,GAAU,WAAmB,GAAG,IAAoB,cAAc,CAAW,IAEjF,CACR,CACH,OAAS,EAAO,CACd,IAAM,EAAS,aAAiB,OAAS,EAAM,QAAU,YAAY,EAAM,UAAY,GAEvF,MAAM,IAAI,EACR,yGAAyG,IACzG,CAAE,MAAO,CAAM,CACjB,CACF,CACF,EA8BA,SAAgB,KAAmB,EAAe,CAAE,MAAK,UAAU,KAA6B,CAAC,EAAgB,CAC/G,GAAI,IAAY,MAAa,CAAC,OAAO,UAAU,CAAO,GAAK,EAAU,GACnE,MAAU,WAAW,6DAA6D,GAAS,EAG7F,IAAM,EAAQ,IAAI,EAAmC,CAAO,EAEtD,YAAc,GAAG,IAAsC,EAAM,EAAI,GAAG,CAAI,EAAI,WAAW,CAAI,EAE3F,UAAY,GAAG,IAAuC,CAC1D,IAAM,EAAW,WAAW,GAAG,CAAI,EAEnC,GAAI,EAAM,IAAI,CAAQ,EAAG,CACvB,IAAM,EAAS,EAAM,IAAI,CAAQ,EAIjC,OAFA,EAAM,IAAI,EAAU,CAAM,EAEnB,CACT,CAEA,IAAM,EAAQ,EAAG,GAAG,CAAI,EAIxB,OAFA,EAAM,IAAI,EAAU,CAAK,EAElB,CACT,EAEM,EAAS,OAAO,OAAO,SAAU,CACrC,UAAa,EAAM,MAAM,EACzB,YAAa,GAAG,IAA8B,CAC5C,EAAM,OAAO,WAAW,GAAG,CAAI,CAAC,CAClC,CACF,CAAC,EAID,OAFA,OAAO,eAAe,EAAQ,OAAQ,CAAE,QAAW,EAAM,IAAK,CAAC,EAExD,CACT"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`,t=new Map([...e].map((e,t)=>[e,t]));function bytesToBase64Url(t){let n=``;for(let r=0;r<t.length;r+=3){let i=t[r],a=t[r+1],o=t[r+2];n+=e[i>>2],n+=e[(i&3)<<4|(a??0)>>4],a!==void 0&&(n+=e[(a&15)<<2|(o??0)>>6]),o!==void 0&&(n+=e[o&63])}return n}function base64UrlToBytes(e){let n=[],r=0,i=0;for(let a of e){let e=t.get(a);if(e===void 0)throw Error(`Invalid base64url character "${a}"`);r=r<<6|e,i+=6,i>=8&&(i-=8,n.push(r>>i&255))}return new Uint8Array(n)}var n=new TextEncoder,r=new TextDecoder;function textToBase64Url(e){return bytesToBase64Url(n.encode(e))}function base64UrlToText(e){return r.decode(base64UrlToBytes(e))}function utf8Bytes(e){return n.encode(e).length}exports.base64UrlToBytes=base64UrlToBytes,exports.base64UrlToText=base64UrlToText,exports.bytesToBase64Url=bytesToBase64Url,exports.textToBase64Url=textToBase64Url,exports.utf8Bytes=utf8Bytes;
|
|
2
|
+
//# sourceMappingURL=base64url.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64url.cjs","names":[],"sources":["../../src/encoding/base64url.ts"],"sourcesContent":["const ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';\nconst LOOKUP = new Map([...ALPHABET].map((char, index) => [char, index]));\n\n/** Environment-independent base64url encoding (no `btoa`/`Buffer` dependency). */\nexport function bytesToBase64Url(bytes: Uint8Array): string {\n let output = '';\n for (let index = 0; index < bytes.length; index += 3) {\n const a = bytes[index]!;\n const b = bytes[index + 1];\n const c = bytes[index + 2];\n output += ALPHABET[a >> 2]!;\n output += ALPHABET[((a & 0b11) << 4) | ((b ?? 0) >> 4)]!;\n if (b !== undefined) output += ALPHABET[((b & 0b1111) << 2) | ((c ?? 0) >> 6)]!;\n if (c !== undefined) output += ALPHABET[c & 0b111111]!;\n }\n return output;\n}\n\n/** Decodes base64url text. Throws on characters outside the base64url alphabet. */\nexport function base64UrlToBytes(text: string): Uint8Array {\n const bytes: number[] = [];\n let buffer = 0;\n let bits = 0;\n for (const char of text) {\n const value = LOOKUP.get(char);\n if (value === undefined) throw new Error(`Invalid base64url character \"${char}\"`);\n buffer = (buffer << 6) | value;\n bits += 6;\n if (bits >= 8) {\n bits -= 8;\n bytes.push((buffer >> bits) & 0xff);\n }\n }\n return new Uint8Array(bytes);\n}\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\nexport function textToBase64Url(text: string): string {\n return bytesToBase64Url(encoder.encode(text));\n}\n\nexport function base64UrlToText(text: string): string {\n return decoder.decode(base64UrlToBytes(text));\n}\n\n/** Byte length of a UTF-8 string — used for `maxMessageBytes` checks. */\nexport function utf8Bytes(text: string): number {\n return encoder.encode(text).length;\n}\n"],"mappings":"AAAA,IAAM,EAAW,mEACX,EAAS,IAAI,IAAI,CAAC,GAAG,CAAQ,CAAC,CAAC,KAAK,EAAM,IAAU,CAAC,EAAM,CAAK,CAAC,CAAC,EAGxE,SAAgB,iBAAiB,EAA2B,CAC1D,IAAI,EAAS,GACb,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAM,OAAQ,GAAS,EAAG,CACpD,IAAM,EAAI,EAAM,GACV,EAAI,EAAM,EAAQ,GAClB,EAAI,EAAM,EAAQ,GACxB,GAAU,EAAS,GAAK,GACxB,GAAU,GAAW,EAAI,IAAS,GAAO,GAAK,IAAM,GAChD,IAAM,IAAA,KAAW,GAAU,GAAW,EAAI,KAAW,GAAO,GAAK,IAAM,IACvE,IAAM,IAAA,KAAW,GAAU,EAAS,EAAI,IAC9C,CACA,OAAO,CACT,CAGA,SAAgB,iBAAiB,EAA0B,CACzD,IAAM,EAAkB,CAAC,EACrB,EAAS,EACT,EAAO,EACX,IAAK,IAAM,KAAQ,EAAM,CACvB,IAAM,EAAQ,EAAO,IAAI,CAAI,EAC7B,GAAI,IAAU,IAAA,GAAW,MAAU,MAAM,gCAAgC,EAAK,EAAE,EAChF,EAAU,GAAU,EAAK,EACzB,GAAQ,EACJ,GAAQ,IACV,GAAQ,EACR,EAAM,KAAM,GAAU,EAAQ,GAAI,EAEtC,CACA,OAAO,IAAI,WAAW,CAAK,CAC7B,CAEA,IAAM,EAAU,IAAI,YACd,EAAU,IAAI,YAEpB,SAAgB,gBAAgB,EAAsB,CACpD,OAAO,iBAAiB,EAAQ,OAAO,CAAI,CAAC,CAC9C,CAEA,SAAgB,gBAAgB,EAAsB,CACpD,OAAO,EAAQ,OAAO,iBAAiB,CAAI,CAAC,CAC9C,CAGA,SAAgB,UAAU,EAAsB,CAC9C,OAAO,EAAQ,OAAO,CAAI,CAAC,CAAC,MAC9B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Environment-independent base64url encoding (no `btoa`/`Buffer` dependency). */
|
|
2
|
+
export declare function bytesToBase64Url(bytes: Uint8Array): string;
|
|
3
|
+
/** Decodes base64url text. Throws on characters outside the base64url alphabet. */
|
|
4
|
+
export declare function base64UrlToBytes(text: string): Uint8Array;
|
|
5
|
+
export declare function textToBase64Url(text: string): string;
|
|
6
|
+
export declare function base64UrlToText(text: string): string;
|
|
7
|
+
/** Byte length of a UTF-8 string — used for `maxMessageBytes` checks. */
|
|
8
|
+
export declare function utf8Bytes(text: string): number;
|
|
9
|
+
//# sourceMappingURL=base64url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64url.d.ts","sourceRoot":"","sources":["../../src/encoding/base64url.ts"],"names":[],"mappings":"AAGA,kFAAkF;AAClF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAY1D;AAED,mFAAmF;AACnF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAezD;AAKD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,yEAAyE;AACzE,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`,t=new Map([...e].map((e,t)=>[e,t]));function bytesToBase64Url(t){let n=``;for(let r=0;r<t.length;r+=3){let i=t[r],a=t[r+1],o=t[r+2];n+=e[i>>2],n+=e[(i&3)<<4|(a??0)>>4],a!==void 0&&(n+=e[(a&15)<<2|(o??0)>>6]),o!==void 0&&(n+=e[o&63])}return n}function base64UrlToBytes(e){let n=[],r=0,i=0;for(let a of e){let e=t.get(a);if(e===void 0)throw Error(`Invalid base64url character "${a}"`);r=r<<6|e,i+=6,i>=8&&(i-=8,n.push(r>>i&255))}return new Uint8Array(n)}var n=new TextEncoder,r=new TextDecoder;function textToBase64Url(e){return bytesToBase64Url(n.encode(e))}function base64UrlToText(e){return r.decode(base64UrlToBytes(e))}function utf8Bytes(e){return n.encode(e).length}export{base64UrlToBytes,base64UrlToText,bytesToBase64Url,textToBase64Url,utf8Bytes};
|
|
2
|
+
//# sourceMappingURL=base64url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64url.js","names":[],"sources":["../../src/encoding/base64url.ts"],"sourcesContent":["const ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';\nconst LOOKUP = new Map([...ALPHABET].map((char, index) => [char, index]));\n\n/** Environment-independent base64url encoding (no `btoa`/`Buffer` dependency). */\nexport function bytesToBase64Url(bytes: Uint8Array): string {\n let output = '';\n for (let index = 0; index < bytes.length; index += 3) {\n const a = bytes[index]!;\n const b = bytes[index + 1];\n const c = bytes[index + 2];\n output += ALPHABET[a >> 2]!;\n output += ALPHABET[((a & 0b11) << 4) | ((b ?? 0) >> 4)]!;\n if (b !== undefined) output += ALPHABET[((b & 0b1111) << 2) | ((c ?? 0) >> 6)]!;\n if (c !== undefined) output += ALPHABET[c & 0b111111]!;\n }\n return output;\n}\n\n/** Decodes base64url text. Throws on characters outside the base64url alphabet. */\nexport function base64UrlToBytes(text: string): Uint8Array {\n const bytes: number[] = [];\n let buffer = 0;\n let bits = 0;\n for (const char of text) {\n const value = LOOKUP.get(char);\n if (value === undefined) throw new Error(`Invalid base64url character \"${char}\"`);\n buffer = (buffer << 6) | value;\n bits += 6;\n if (bits >= 8) {\n bits -= 8;\n bytes.push((buffer >> bits) & 0xff);\n }\n }\n return new Uint8Array(bytes);\n}\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\nexport function textToBase64Url(text: string): string {\n return bytesToBase64Url(encoder.encode(text));\n}\n\nexport function base64UrlToText(text: string): string {\n return decoder.decode(base64UrlToBytes(text));\n}\n\n/** Byte length of a UTF-8 string — used for `maxMessageBytes` checks. */\nexport function utf8Bytes(text: string): number {\n return encoder.encode(text).length;\n}\n"],"mappings":"AAAA,IAAM,EAAW,mEACX,EAAS,IAAI,IAAI,CAAC,GAAG,CAAQ,CAAC,CAAC,KAAK,EAAM,IAAU,CAAC,EAAM,CAAK,CAAC,CAAC,EAGxE,SAAgB,iBAAiB,EAA2B,CAC1D,IAAI,EAAS,GACb,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAM,OAAQ,GAAS,EAAG,CACpD,IAAM,EAAI,EAAM,GACV,EAAI,EAAM,EAAQ,GAClB,EAAI,EAAM,EAAQ,GACxB,GAAU,EAAS,GAAK,GACxB,GAAU,GAAW,EAAI,IAAS,GAAO,GAAK,IAAM,GAChD,IAAM,IAAA,KAAW,GAAU,GAAW,EAAI,KAAW,GAAO,GAAK,IAAM,IACvE,IAAM,IAAA,KAAW,GAAU,EAAS,EAAI,IAC9C,CACA,OAAO,CACT,CAGA,SAAgB,iBAAiB,EAA0B,CACzD,IAAM,EAAkB,CAAC,EACrB,EAAS,EACT,EAAO,EACX,IAAK,IAAM,KAAQ,EAAM,CACvB,IAAM,EAAQ,EAAO,IAAI,CAAI,EAC7B,GAAI,IAAU,IAAA,GAAW,MAAU,MAAM,gCAAgC,EAAK,EAAE,EAChF,EAAU,GAAU,EAAK,EACzB,GAAQ,EACJ,GAAQ,IACV,GAAQ,EACR,EAAM,KAAM,GAAU,EAAQ,GAAI,EAEtC,CACA,OAAO,IAAI,WAAW,CAAK,CAC7B,CAEA,IAAM,EAAU,IAAI,YACd,EAAU,IAAI,YAEpB,SAAgB,gBAAgB,EAAsB,CACpD,OAAO,iBAAiB,EAAQ,OAAO,CAAI,CAAC,CAC9C,CAEA,SAAgB,gBAAgB,EAAsB,CACpD,OAAO,EAAQ,OAAO,iBAAiB,CAAI,CAAC,CAC9C,CAGA,SAAgB,UAAU,EAAsB,CAC9C,OAAO,EAAQ,OAAO,CAAI,CAAC,CAAC,MAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./base64url.cjs");exports.base64UrlToBytes=e.base64UrlToBytes,exports.base64UrlToText=e.base64UrlToText,exports.bytesToBase64Url=e.bytesToBase64Url,exports.textToBase64Url=e.textToBase64Url,exports.utf8Bytes=e.utf8Bytes;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/encoding/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{base64UrlToBytes as e,base64UrlToText as t,bytesToBase64Url as n,textToBase64Url as r,utf8Bytes as i}from"./base64url.js";export{e as base64UrlToBytes,t as base64UrlToText,n as bytesToBase64Url,r as textToBase64Url,i as utf8Bytes};
|
package/dist/errors.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ArsenalError=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},ArsenalSerializationError=class extends ArsenalError{};exports.ArsenalError=ArsenalError,exports.ArsenalSerializationError=ArsenalSerializationError;
|
|
2
2
|
//# sourceMappingURL=errors.cjs.map
|
package/dist/errors.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/** Base class for all arsenal errors. Use `instanceof ArsenalError` to catch any arsenal-originated error. */\nexport class ArsenalError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when converting a value to or from its serialized form fails — e.g. `memo`'s default\n * cache key (`JSON.stringify`) encountering a circular reference, or `hash` encountering an\n * unsupported class instance with `{ onClassInstance: 'throw' }`.\n */\nexport class ArsenalSerializationError extends ArsenalError {}\n"],"mappings":"AACA,IAAa,
|
|
1
|
+
{"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/** Base class for all arsenal errors. Use `instanceof ArsenalError` to catch any arsenal-originated error. */\nexport class ArsenalError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when converting a value to or from its serialized form fails — e.g. `memo`'s default\n * cache key (`JSON.stringify`) encountering a circular reference, or `hash` encountering an\n * unsupported class instance with `{ onClassInstance: 'throw' }`.\n */\nexport class ArsenalSerializationError extends ArsenalError {}\n"],"mappings":"AACA,IAAa,aAAb,cAAkC,KAAM,CACtC,YAAY,EAAiB,EAAqB,CAChD,MAAM,EAAS,CAAI,EACnB,KAAK,KAAO,WAAW,KACvB,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CACF,EAOa,0BAAb,cAA+C,YAAa,CAAC"}
|
package/dist/errors.js
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
var e = class extends Error {
|
|
3
|
-
constructor(e, t) {
|
|
4
|
-
super(e, t), this.name = new.target.name, Object.setPrototypeOf(this, new.target.prototype);
|
|
5
|
-
}
|
|
6
|
-
}, t = class extends e {};
|
|
7
|
-
//#endregion
|
|
8
|
-
export { e as ArsenalError, t as ArsenalSerializationError };
|
|
9
|
-
|
|
1
|
+
var ArsenalError=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},ArsenalSerializationError=class extends ArsenalError{};export{ArsenalError,ArsenalSerializationError};
|
|
10
2
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/** Base class for all arsenal errors. Use `instanceof ArsenalError` to catch any arsenal-originated error. */\nexport class ArsenalError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when converting a value to or from its serialized form fails — e.g. `memo`'s default\n * cache key (`JSON.stringify`) encountering a circular reference, or `hash` encountering an\n * unsupported class instance with `{ onClassInstance: 'throw' }`.\n */\nexport class ArsenalSerializationError extends ArsenalError {}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/** Base class for all arsenal errors. Use `instanceof ArsenalError` to catch any arsenal-originated error. */\nexport class ArsenalError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Thrown when converting a value to or from its serialized form fails — e.g. `memo`'s default\n * cache key (`JSON.stringify`) encountering a circular reference, or `hash` encountering an\n * unsupported class instance with `{ onClassInstance: 'throw' }`.\n */\nexport class ArsenalSerializationError extends ArsenalError {}\n"],"mappings":"AACA,IAAa,aAAb,cAAkC,KAAM,CACtC,YAAY,EAAiB,EAAqB,CAChD,MAAM,EAAS,CAAI,EACnB,KAAK,KAAO,WAAW,KACvB,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CACF,EAOa,0BAAb,cAA+C,YAAa,CAAC"}
|
package/dist/function/assert.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
function assert(e,t,n){if(!e)throw new((n?.type)??Error)(t??`Assertion failed`)}exports.assert=assert;
|
|
2
2
|
//# sourceMappingURL=assert.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.cjs","names":[],"sources":["../../src/function/assert.ts"],"sourcesContent":["/**\n * Asserts that a condition is true. Throws with `message` if false.\n *\n * @example\n * ```ts\n * assert(Array.isArray(x));\n * assert(x > 0, 'x must be positive');\n * assert(n >= 1, 'must be at least 1', { type: RangeError });\n * ```\n *\n * @param condition - The boolean condition to assert.\n * @param [message] - Error message (default: `'Assertion failed'`).\n * @param [options.type] - Error class to throw (default: `Error`).\n * @throws {Error} If `condition` is false.\n */\nexport function assert(condition: unknown, message?: string, options?: { type?: ErrorConstructor }): asserts condition {\n if (!condition) throw new (options?.type ?? Error)(message ?? 'Assertion failed');\n}\n"],"mappings":"AAeA,SAAgB,
|
|
1
|
+
{"version":3,"file":"assert.cjs","names":[],"sources":["../../src/function/assert.ts"],"sourcesContent":["/**\n * Asserts that a condition is true. Throws with `message` if false.\n *\n * @example\n * ```ts\n * assert(Array.isArray(x));\n * assert(x > 0, 'x must be positive');\n * assert(n >= 1, 'must be at least 1', { type: RangeError });\n * ```\n *\n * @param condition - The boolean condition to assert.\n * @param [message] - Error message (default: `'Assertion failed'`).\n * @param [options.type] - Error class to throw (default: `Error`).\n * @throws {Error} If `condition` is false.\n */\nexport function assert(condition: unknown, message?: string, options?: { type?: ErrorConstructor }): asserts condition {\n if (!condition) throw new (options?.type ?? Error)(message ?? 'Assertion failed');\n}\n"],"mappings":"AAeA,SAAgB,OAAO,EAAoB,EAAkB,EAA0D,CACrH,GAAI,CAAC,EAAW,MAAM,KAAK,GAAS,OAAQ,OAAO,GAAW,kBAAkB,CAClF"}
|
package/dist/function/assert.js
CHANGED
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
function e(e, t, n) {
|
|
3
|
-
if (!e) throw new ((n?.type) ?? Error)(t ?? "Assertion failed");
|
|
4
|
-
}
|
|
5
|
-
//#endregion
|
|
6
|
-
export { e as assert };
|
|
7
|
-
|
|
1
|
+
function assert(e,t,n){if(!e)throw new((n?.type)??Error)(t??`Assertion failed`)}export{assert};
|
|
8
2
|
//# sourceMappingURL=assert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.js","names":[],"sources":["../../src/function/assert.ts"],"sourcesContent":["/**\n * Asserts that a condition is true. Throws with `message` if false.\n *\n * @example\n * ```ts\n * assert(Array.isArray(x));\n * assert(x > 0, 'x must be positive');\n * assert(n >= 1, 'must be at least 1', { type: RangeError });\n * ```\n *\n * @param condition - The boolean condition to assert.\n * @param [message] - Error message (default: `'Assertion failed'`).\n * @param [options.type] - Error class to throw (default: `Error`).\n * @throws {Error} If `condition` is false.\n */\nexport function assert(condition: unknown, message?: string, options?: { type?: ErrorConstructor }): asserts condition {\n if (!condition) throw new (options?.type ?? Error)(message ?? 'Assertion failed');\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"assert.js","names":[],"sources":["../../src/function/assert.ts"],"sourcesContent":["/**\n * Asserts that a condition is true. Throws with `message` if false.\n *\n * @example\n * ```ts\n * assert(Array.isArray(x));\n * assert(x > 0, 'x must be positive');\n * assert(n >= 1, 'must be at least 1', { type: RangeError });\n * ```\n *\n * @param condition - The boolean condition to assert.\n * @param [message] - Error message (default: `'Assertion failed'`).\n * @param [options.type] - Error class to throw (default: `Error`).\n * @throws {Error} If `condition` is false.\n */\nexport function assert(condition: unknown, message?: string, options?: { type?: ErrorConstructor }): asserts condition {\n if (!condition) throw new (options?.type ?? Error)(message ?? 'Assertion failed');\n}\n"],"mappings":"AAeA,SAAgB,OAAO,EAAoB,EAAkB,EAA0D,CACrH,GAAI,CAAC,EAAW,MAAM,KAAK,GAAS,OAAQ,OAAO,GAAW,kBAAkB,CAClF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require("../_dev.cjs");function
|
|
1
|
+
require("../_dev.cjs");function debounce(e,t=300,n={leading:!1,trailing:!0}){let r=n.leading??!1,i=n.trailing??!0,a,o,s,c=!1,clearTimer=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},invokeTrailing=()=>{if(clearTimer(),c=!1,!o)return;let t=o;return o=void 0,s=e(...t),s};return Object.assign((...n)=>(o=n,r&&!c&&(c=!0,s=e(...n),o=void 0,!i)?(a=setTimeout(()=>{a=void 0,c=!1},t),s):r&&!i&&c?s:(clearTimer(),a=setTimeout(invokeTrailing,t),s)),{cancel:()=>{clearTimer(),o=void 0,c=!1},flush:()=>invokeTrailing(),pending:()=>a!==void 0})}exports.debounce=debounce;
|
|
2
2
|
//# sourceMappingURL=debounce.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debounce.cjs","names":[],"sources":["../../src/function/debounce.ts"],"sourcesContent":["import { warn } from '../_dev';\nimport type { Fn } from '../types';\n\nexport type DebounceOptions = {\n /** Invoke on the leading edge of the delay window. Default: `false`. */\n leading?: boolean;\n /** Invoke on the trailing edge of the delay window. Default: `true`. */\n trailing?: boolean;\n};\n\nexport type Debounced<T extends Fn> = ((...args: Parameters<T>) => ReturnType<T> | undefined) & {\n cancel(): void;\n flush(): ReturnType<T> | undefined;\n pending(): boolean;\n};\n\n/**\n * Debounces a function. By default only the trailing edge fires (after input settles).\n * Pass `{ leading: true }` to fire immediately on the first call instead.\n * Pass `{ leading: true, trailing: true }` to fire on both edges.\n *\n * Use `flush()` to invoke immediately, `cancel()` to clear, and `pending()` to check\n * whether an invocation is scheduled.\n *\n * @example\n * ```ts\n * // Trailing (default) — fires after input settles\n * const save = debounce(persist, 500);\n *\n * // Leading — fires on the first keystroke, then silences during the window\n * const submit = debounce(sendRequest, 500, { leading: true, trailing: false });\n * ```\n */\nexport function debounce<T extends Fn>(\n fn: T,\n delay = 300,\n options: DebounceOptions = { leading: false, trailing: true },\n): Debounced<T> {\n const leading = options.leading ?? false;\n const trailing = options.trailing ?? true;\n\n if (!leading && !trailing) {\n warn('debounce: both `leading` and `trailing` are false — the wrapped function will never be invoked.');\n }\n\n let timerId: ReturnType<typeof setTimeout> | undefined;\n let lastArgs: Parameters<T> | undefined;\n let lastResult: ReturnType<T> | undefined;\n let leadingFired = false;\n\n const clearTimer = () => {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n timerId = undefined;\n }\n };\n\n const invokeTrailing = () => {\n clearTimer();\n leadingFired = false;\n\n if (!lastArgs) return undefined;\n\n const args = lastArgs;\n\n lastArgs = undefined;\n lastResult = fn(...args) as ReturnType<T>;\n\n return lastResult;\n };\n\n return Object.assign(\n (...args: Parameters<T>): ReturnType<T> | undefined => {\n lastArgs = args;\n\n if (leading && !leadingFired) {\n leadingFired = true;\n lastResult = fn(...args) as ReturnType<T>;\n // Clear args regardless of `trailing` — the leading call already consumed this\n // invocation. The trailing timer below only re-invokes `fn` if a *further* call\n // arrives during the cooldown window and repopulates `lastArgs`.\n lastArgs = undefined;\n\n if (!trailing) {\n // Leading-only: start cooldown — no trailing call needed\n timerId = setTimeout(() => {\n timerId = undefined;\n leadingFired = false;\n }, delay);\n\n return lastResult;\n }\n }\n\n // When leading-only, ignore calls within the cooldown window\n if (leading && !trailing && leadingFired) return lastResult;\n\n clearTimer();\n timerId = setTimeout(invokeTrailing, delay);\n\n return lastResult;\n },\n {\n cancel: () => {\n clearTimer();\n lastArgs = undefined;\n leadingFired = false;\n },\n flush: (): ReturnType<T> | undefined => invokeTrailing(),\n pending: () => timerId !== undefined,\n },\n );\n}\n"],"mappings":"uBAiCA,SAAgB,
|
|
1
|
+
{"version":3,"file":"debounce.cjs","names":[],"sources":["../../src/function/debounce.ts"],"sourcesContent":["import { warn } from '../_dev';\nimport type { Fn } from '../types';\n\nexport type DebounceOptions = {\n /** Invoke on the leading edge of the delay window. Default: `false`. */\n leading?: boolean;\n /** Invoke on the trailing edge of the delay window. Default: `true`. */\n trailing?: boolean;\n};\n\nexport type Debounced<T extends Fn> = ((...args: Parameters<T>) => ReturnType<T> | undefined) & {\n cancel(): void;\n flush(): ReturnType<T> | undefined;\n pending(): boolean;\n};\n\n/**\n * Debounces a function. By default only the trailing edge fires (after input settles).\n * Pass `{ leading: true }` to fire immediately on the first call instead.\n * Pass `{ leading: true, trailing: true }` to fire on both edges.\n *\n * Use `flush()` to invoke immediately, `cancel()` to clear, and `pending()` to check\n * whether an invocation is scheduled.\n *\n * @example\n * ```ts\n * // Trailing (default) — fires after input settles\n * const save = debounce(persist, 500);\n *\n * // Leading — fires on the first keystroke, then silences during the window\n * const submit = debounce(sendRequest, 500, { leading: true, trailing: false });\n * ```\n */\nexport function debounce<T extends Fn>(\n fn: T,\n delay = 300,\n options: DebounceOptions = { leading: false, trailing: true },\n): Debounced<T> {\n const leading = options.leading ?? false;\n const trailing = options.trailing ?? true;\n\n if (!leading && !trailing) {\n warn('debounce: both `leading` and `trailing` are false — the wrapped function will never be invoked.');\n }\n\n let timerId: ReturnType<typeof setTimeout> | undefined;\n let lastArgs: Parameters<T> | undefined;\n let lastResult: ReturnType<T> | undefined;\n let leadingFired = false;\n\n const clearTimer = () => {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n timerId = undefined;\n }\n };\n\n const invokeTrailing = () => {\n clearTimer();\n leadingFired = false;\n\n if (!lastArgs) return undefined;\n\n const args = lastArgs;\n\n lastArgs = undefined;\n lastResult = fn(...args) as ReturnType<T>;\n\n return lastResult;\n };\n\n return Object.assign(\n (...args: Parameters<T>): ReturnType<T> | undefined => {\n lastArgs = args;\n\n if (leading && !leadingFired) {\n leadingFired = true;\n lastResult = fn(...args) as ReturnType<T>;\n // Clear args regardless of `trailing` — the leading call already consumed this\n // invocation. The trailing timer below only re-invokes `fn` if a *further* call\n // arrives during the cooldown window and repopulates `lastArgs`.\n lastArgs = undefined;\n\n if (!trailing) {\n // Leading-only: start cooldown — no trailing call needed\n timerId = setTimeout(() => {\n timerId = undefined;\n leadingFired = false;\n }, delay);\n\n return lastResult;\n }\n }\n\n // When leading-only, ignore calls within the cooldown window\n if (leading && !trailing && leadingFired) return lastResult;\n\n clearTimer();\n timerId = setTimeout(invokeTrailing, delay);\n\n return lastResult;\n },\n {\n cancel: () => {\n clearTimer();\n lastArgs = undefined;\n leadingFired = false;\n },\n flush: (): ReturnType<T> | undefined => invokeTrailing(),\n pending: () => timerId !== undefined,\n },\n );\n}\n"],"mappings":"uBAiCA,SAAgB,SACd,EACA,EAAQ,IACR,EAA2B,CAAE,QAAS,GAAO,SAAU,EAAK,EAC9C,CACd,IAAM,EAAU,EAAQ,SAAW,GAC7B,EAAW,EAAQ,UAAY,GAMjC,EACA,EACA,EACA,EAAe,GAEb,eAAmB,CACnB,IAAY,IAAA,KACd,aAAa,CAAO,EACpB,EAAU,IAAA,GAEd,EAEM,mBAAuB,CAI3B,GAHA,WAAW,EACX,EAAe,GAEX,CAAC,EAAU,OAEf,IAAM,EAAO,EAKb,MAHA,GAAW,IAAA,GACX,EAAa,EAAG,GAAG,CAAI,EAEhB,CACT,EAEA,OAAO,OAAO,QACX,GAAG,KACF,EAAW,EAEP,GAAW,CAAC,IACd,EAAe,GACf,EAAa,EAAG,GAAG,CAAI,EAIvB,EAAW,IAAA,GAEP,CAAC,IAEH,EAAU,eAAiB,CACzB,EAAU,IAAA,GACV,EAAe,EACjB,EAAG,CAAK,EAED,GAKP,GAAW,CAAC,GAAY,EAAqB,GAEjD,WAAW,EACX,EAAU,WAAW,eAAgB,CAAK,EAEnC,IAET,CACE,WAAc,CACZ,WAAW,EACX,EAAW,IAAA,GACX,EAAe,EACjB,EACA,UAAwC,eAAe,EACvD,YAAe,IAAY,IAAA,EAC7B,CACF,CACF"}
|
|
@@ -1,27 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
//#region src/function/debounce.ts
|
|
3
|
-
function e(e, t = 300, n = {
|
|
4
|
-
leading: !1,
|
|
5
|
-
trailing: !0
|
|
6
|
-
}) {
|
|
7
|
-
let r = n.leading ?? !1, i = n.trailing ?? !0, a, o, s, c = !1, l = () => {
|
|
8
|
-
a !== void 0 && (clearTimeout(a), a = void 0);
|
|
9
|
-
}, u = () => {
|
|
10
|
-
if (l(), c = !1, !o) return;
|
|
11
|
-
let t = o;
|
|
12
|
-
return o = void 0, s = e(...t), s;
|
|
13
|
-
};
|
|
14
|
-
return Object.assign((...n) => (o = n, r && !c && (c = !0, s = e(...n), o = void 0, !i) ? (a = setTimeout(() => {
|
|
15
|
-
a = void 0, c = !1;
|
|
16
|
-
}, t), s) : r && !i && c ? s : (l(), a = setTimeout(u, t), s)), {
|
|
17
|
-
cancel: () => {
|
|
18
|
-
l(), o = void 0, c = !1;
|
|
19
|
-
},
|
|
20
|
-
flush: () => u(),
|
|
21
|
-
pending: () => a !== void 0
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
//#endregion
|
|
25
|
-
export { e as debounce };
|
|
26
|
-
|
|
1
|
+
import"../_dev.js";function debounce(e,t=300,n={leading:!1,trailing:!0}){let r=n.leading??!1,i=n.trailing??!0,a,o,s,c=!1,clearTimer=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},invokeTrailing=()=>{if(clearTimer(),c=!1,!o)return;let t=o;return o=void 0,s=e(...t),s};return Object.assign((...n)=>(o=n,r&&!c&&(c=!0,s=e(...n),o=void 0,!i)?(a=setTimeout(()=>{a=void 0,c=!1},t),s):r&&!i&&c?s:(clearTimer(),a=setTimeout(invokeTrailing,t),s)),{cancel:()=>{clearTimer(),o=void 0,c=!1},flush:()=>invokeTrailing(),pending:()=>a!==void 0})}export{debounce};
|
|
27
2
|
//# sourceMappingURL=debounce.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debounce.js","names":[],"sources":["../../src/function/debounce.ts"],"sourcesContent":["import { warn } from '../_dev';\nimport type { Fn } from '../types';\n\nexport type DebounceOptions = {\n /** Invoke on the leading edge of the delay window. Default: `false`. */\n leading?: boolean;\n /** Invoke on the trailing edge of the delay window. Default: `true`. */\n trailing?: boolean;\n};\n\nexport type Debounced<T extends Fn> = ((...args: Parameters<T>) => ReturnType<T> | undefined) & {\n cancel(): void;\n flush(): ReturnType<T> | undefined;\n pending(): boolean;\n};\n\n/**\n * Debounces a function. By default only the trailing edge fires (after input settles).\n * Pass `{ leading: true }` to fire immediately on the first call instead.\n * Pass `{ leading: true, trailing: true }` to fire on both edges.\n *\n * Use `flush()` to invoke immediately, `cancel()` to clear, and `pending()` to check\n * whether an invocation is scheduled.\n *\n * @example\n * ```ts\n * // Trailing (default) — fires after input settles\n * const save = debounce(persist, 500);\n *\n * // Leading — fires on the first keystroke, then silences during the window\n * const submit = debounce(sendRequest, 500, { leading: true, trailing: false });\n * ```\n */\nexport function debounce<T extends Fn>(\n fn: T,\n delay = 300,\n options: DebounceOptions = { leading: false, trailing: true },\n): Debounced<T> {\n const leading = options.leading ?? false;\n const trailing = options.trailing ?? true;\n\n if (!leading && !trailing) {\n warn('debounce: both `leading` and `trailing` are false — the wrapped function will never be invoked.');\n }\n\n let timerId: ReturnType<typeof setTimeout> | undefined;\n let lastArgs: Parameters<T> | undefined;\n let lastResult: ReturnType<T> | undefined;\n let leadingFired = false;\n\n const clearTimer = () => {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n timerId = undefined;\n }\n };\n\n const invokeTrailing = () => {\n clearTimer();\n leadingFired = false;\n\n if (!lastArgs) return undefined;\n\n const args = lastArgs;\n\n lastArgs = undefined;\n lastResult = fn(...args) as ReturnType<T>;\n\n return lastResult;\n };\n\n return Object.assign(\n (...args: Parameters<T>): ReturnType<T> | undefined => {\n lastArgs = args;\n\n if (leading && !leadingFired) {\n leadingFired = true;\n lastResult = fn(...args) as ReturnType<T>;\n // Clear args regardless of `trailing` — the leading call already consumed this\n // invocation. The trailing timer below only re-invokes `fn` if a *further* call\n // arrives during the cooldown window and repopulates `lastArgs`.\n lastArgs = undefined;\n\n if (!trailing) {\n // Leading-only: start cooldown — no trailing call needed\n timerId = setTimeout(() => {\n timerId = undefined;\n leadingFired = false;\n }, delay);\n\n return lastResult;\n }\n }\n\n // When leading-only, ignore calls within the cooldown window\n if (leading && !trailing && leadingFired) return lastResult;\n\n clearTimer();\n timerId = setTimeout(invokeTrailing, delay);\n\n return lastResult;\n },\n {\n cancel: () => {\n clearTimer();\n lastArgs = undefined;\n leadingFired = false;\n },\n flush: (): ReturnType<T> | undefined => invokeTrailing(),\n pending: () => timerId !== undefined,\n },\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"debounce.js","names":[],"sources":["../../src/function/debounce.ts"],"sourcesContent":["import { warn } from '../_dev';\nimport type { Fn } from '../types';\n\nexport type DebounceOptions = {\n /** Invoke on the leading edge of the delay window. Default: `false`. */\n leading?: boolean;\n /** Invoke on the trailing edge of the delay window. Default: `true`. */\n trailing?: boolean;\n};\n\nexport type Debounced<T extends Fn> = ((...args: Parameters<T>) => ReturnType<T> | undefined) & {\n cancel(): void;\n flush(): ReturnType<T> | undefined;\n pending(): boolean;\n};\n\n/**\n * Debounces a function. By default only the trailing edge fires (after input settles).\n * Pass `{ leading: true }` to fire immediately on the first call instead.\n * Pass `{ leading: true, trailing: true }` to fire on both edges.\n *\n * Use `flush()` to invoke immediately, `cancel()` to clear, and `pending()` to check\n * whether an invocation is scheduled.\n *\n * @example\n * ```ts\n * // Trailing (default) — fires after input settles\n * const save = debounce(persist, 500);\n *\n * // Leading — fires on the first keystroke, then silences during the window\n * const submit = debounce(sendRequest, 500, { leading: true, trailing: false });\n * ```\n */\nexport function debounce<T extends Fn>(\n fn: T,\n delay = 300,\n options: DebounceOptions = { leading: false, trailing: true },\n): Debounced<T> {\n const leading = options.leading ?? false;\n const trailing = options.trailing ?? true;\n\n if (!leading && !trailing) {\n warn('debounce: both `leading` and `trailing` are false — the wrapped function will never be invoked.');\n }\n\n let timerId: ReturnType<typeof setTimeout> | undefined;\n let lastArgs: Parameters<T> | undefined;\n let lastResult: ReturnType<T> | undefined;\n let leadingFired = false;\n\n const clearTimer = () => {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n timerId = undefined;\n }\n };\n\n const invokeTrailing = () => {\n clearTimer();\n leadingFired = false;\n\n if (!lastArgs) return undefined;\n\n const args = lastArgs;\n\n lastArgs = undefined;\n lastResult = fn(...args) as ReturnType<T>;\n\n return lastResult;\n };\n\n return Object.assign(\n (...args: Parameters<T>): ReturnType<T> | undefined => {\n lastArgs = args;\n\n if (leading && !leadingFired) {\n leadingFired = true;\n lastResult = fn(...args) as ReturnType<T>;\n // Clear args regardless of `trailing` — the leading call already consumed this\n // invocation. The trailing timer below only re-invokes `fn` if a *further* call\n // arrives during the cooldown window and repopulates `lastArgs`.\n lastArgs = undefined;\n\n if (!trailing) {\n // Leading-only: start cooldown — no trailing call needed\n timerId = setTimeout(() => {\n timerId = undefined;\n leadingFired = false;\n }, delay);\n\n return lastResult;\n }\n }\n\n // When leading-only, ignore calls within the cooldown window\n if (leading && !trailing && leadingFired) return lastResult;\n\n clearTimer();\n timerId = setTimeout(invokeTrailing, delay);\n\n return lastResult;\n },\n {\n cancel: () => {\n clearTimer();\n lastArgs = undefined;\n leadingFired = false;\n },\n flush: (): ReturnType<T> | undefined => invokeTrailing(),\n pending: () => timerId !== undefined,\n },\n );\n}\n"],"mappings":"mBAiCA,SAAgB,SACd,EACA,EAAQ,IACR,EAA2B,CAAE,QAAS,GAAO,SAAU,EAAK,EAC9C,CACd,IAAM,EAAU,EAAQ,SAAW,GAC7B,EAAW,EAAQ,UAAY,GAMjC,EACA,EACA,EACA,EAAe,GAEb,eAAmB,CACnB,IAAY,IAAA,KACd,aAAa,CAAO,EACpB,EAAU,IAAA,GAEd,EAEM,mBAAuB,CAI3B,GAHA,WAAW,EACX,EAAe,GAEX,CAAC,EAAU,OAEf,IAAM,EAAO,EAKb,MAHA,GAAW,IAAA,GACX,EAAa,EAAG,GAAG,CAAI,EAEhB,CACT,EAEA,OAAO,OAAO,QACX,GAAG,KACF,EAAW,EAEP,GAAW,CAAC,IACd,EAAe,GACf,EAAa,EAAG,GAAG,CAAI,EAIvB,EAAW,IAAA,GAEP,CAAC,IAEH,EAAU,eAAiB,CACzB,EAAU,IAAA,GACV,EAAe,EACjB,EAAG,CAAK,EAED,GAKP,GAAW,CAAC,GAAY,EAAqB,GAEjD,WAAW,EACX,EAAU,WAAW,eAAgB,CAAK,EAEnC,IAET,CACE,WAAc,CACZ,WAAW,EACX,EAAW,IAAA,GACX,EAAe,EACjB,EACA,UAAwC,eAAe,EACvD,YAAe,IAAY,IAAA,EAC7B,CACF,CACF"}
|
package/dist/function/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./assert.cjs"),t=require("./debounce.cjs"),n=require("./once.cjs"),r=require("./pipe.cjs"),i=require("./runAll.cjs"),a=require("./tap.cjs"),o=require("./throttle.cjs");exports.assert=e.assert,exports.debounce=t.debounce,exports.once=n.once,exports.pipe=r.pipe,exports.runAll=i.runAll,exports.tap=a.tap,exports.
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./assert.cjs"),t=require("./debounce.cjs"),n=require("./once.cjs"),r=require("./pipe.cjs"),i=require("./runAll.cjs"),a=require("./tap.cjs"),o=require("./tapper.cjs"),s=require("./throttle.cjs");exports.assert=e.assert,exports.debounce=t.debounce,exports.once=n.once,exports.pipe=r.pipe,exports.runAll=i.runAll,exports.tap=a.tap,exports.tapper=o.tapper,exports.throttle=s.throttle;
|
package/dist/function/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/function/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/function/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
|
package/dist/function/index.js
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { debounce as t } from "./debounce.js";
|
|
3
|
-
import { once as n } from "./once.js";
|
|
4
|
-
import { pipe as r } from "./pipe.js";
|
|
5
|
-
import { runAll as i } from "./runAll.js";
|
|
6
|
-
import { tap as a } from "./tap.js";
|
|
7
|
-
import { throttle as o } from "./throttle.js";
|
|
8
|
-
export { e as assert, t as debounce, n as once, r as pipe, i as runAll, a as tap, o as throttle };
|
|
1
|
+
import{assert as e}from"./assert.js";import{debounce as t}from"./debounce.js";import{once as n}from"./once.js";import{pipe as r}from"./pipe.js";import{runAll as i}from"./runAll.js";import{tap as a}from"./tap.js";import{tapper as o}from"./tapper.js";import{throttle as s}from"./throttle.js";export{e as assert,t as debounce,n as once,r as pipe,i as runAll,a as tap,o as tapper,s as throttle};
|
package/dist/function/once.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var once=e=>{let t,n=!1,wrappedFn=((...r)=>(n||=(t=e(...r),!0),t));return wrappedFn.reset=()=>{t=void 0,n=!1},wrappedFn};exports.once=once;
|
|
2
2
|
//# sourceMappingURL=once.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"once.cjs","names":[],"sources":["../../src/function/once.ts"],"sourcesContent":["import type { Fn } from '../types';\n\n/**\n * A wrapped function that executes `fn` at most once and exposes a `.reset()` method\n * to allow re-invocation.\n */\nexport type Once<T extends Fn> = T & { reset: () => void };\n\n/**\n * Create a function that runs once and returns the first result.\n *\n * If the first call throws, it does not count as \"called\" — the thrown error propagates to\n * that caller, and the next call will invoke `fn` again (rather than caching the failure).\n *\n * @example\n * ```ts\n * const onceRandom = once(() => Math.random())\n * onceRandom() // 0.3\n * onceRandom() // 0.3\n *\n * onceRandom.reset() // clears the cached result — allows one more invocation\n *\n * onceRandom() // 0.2\n * onceRandom() // 0.2\n * ```\n *\n * @param fn - The function to wrap.\n *\n * @returns A `Once<T>` — the wrapped function with a `.reset()` method to clear the cached result.\n */\nexport const once = <T extends Fn>(fn: T): Once<T> => {\n let result: ReturnType<T> | undefined;\n let called = false;\n\n const wrappedFn = ((...args: Parameters<T>): ReturnType<T> => {\n if (!called) {\n result = fn(...args) as ReturnType<T>;\n called = true;\n }\n\n return result as ReturnType<T>;\n }) as Once<T>;\n\n wrappedFn.reset = () => {\n result = undefined;\n called = false;\n };\n\n return wrappedFn;\n};\n"],"mappings":"AA8BA,IAAa,
|
|
1
|
+
{"version":3,"file":"once.cjs","names":[],"sources":["../../src/function/once.ts"],"sourcesContent":["import type { Fn } from '../types';\n\n/**\n * A wrapped function that executes `fn` at most once and exposes a `.reset()` method\n * to allow re-invocation.\n */\nexport type Once<T extends Fn> = T & { reset: () => void };\n\n/**\n * Create a function that runs once and returns the first result.\n *\n * If the first call throws, it does not count as \"called\" — the thrown error propagates to\n * that caller, and the next call will invoke `fn` again (rather than caching the failure).\n *\n * @example\n * ```ts\n * const onceRandom = once(() => Math.random())\n * onceRandom() // 0.3\n * onceRandom() // 0.3\n *\n * onceRandom.reset() // clears the cached result — allows one more invocation\n *\n * onceRandom() // 0.2\n * onceRandom() // 0.2\n * ```\n *\n * @param fn - The function to wrap.\n *\n * @returns A `Once<T>` — the wrapped function with a `.reset()` method to clear the cached result.\n */\nexport const once = <T extends Fn>(fn: T): Once<T> => {\n let result: ReturnType<T> | undefined;\n let called = false;\n\n const wrappedFn = ((...args: Parameters<T>): ReturnType<T> => {\n if (!called) {\n result = fn(...args) as ReturnType<T>;\n called = true;\n }\n\n return result as ReturnType<T>;\n }) as Once<T>;\n\n wrappedFn.reset = () => {\n result = undefined;\n called = false;\n };\n\n return wrappedFn;\n};\n"],"mappings":"AA8BA,IAAa,KAAsB,GAAmB,CACpD,IAAI,EACA,EAAS,GAEP,YAAc,GAAG,KACrB,AAEE,KADA,EAAS,EAAG,GAAG,CAAI,EACV,IAGJ,IAQT,MALA,WAAU,UAAc,CACtB,EAAS,IAAA,GACT,EAAS,EACX,EAEO,SACT"}
|
package/dist/function/once.js
CHANGED
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
var e = (e) => {
|
|
3
|
-
let t, n = !1, r = ((...r) => (n ||= (t = e(...r), !0), t));
|
|
4
|
-
return r.reset = () => {
|
|
5
|
-
t = void 0, n = !1;
|
|
6
|
-
}, r;
|
|
7
|
-
};
|
|
8
|
-
//#endregion
|
|
9
|
-
export { e as once };
|
|
10
|
-
|
|
1
|
+
var once=e=>{let t,n=!1,wrappedFn=((...r)=>(n||=(t=e(...r),!0),t));return wrappedFn.reset=()=>{t=void 0,n=!1},wrappedFn};export{once};
|
|
11
2
|
//# sourceMappingURL=once.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"once.js","names":[],"sources":["../../src/function/once.ts"],"sourcesContent":["import type { Fn } from '../types';\n\n/**\n * A wrapped function that executes `fn` at most once and exposes a `.reset()` method\n * to allow re-invocation.\n */\nexport type Once<T extends Fn> = T & { reset: () => void };\n\n/**\n * Create a function that runs once and returns the first result.\n *\n * If the first call throws, it does not count as \"called\" — the thrown error propagates to\n * that caller, and the next call will invoke `fn` again (rather than caching the failure).\n *\n * @example\n * ```ts\n * const onceRandom = once(() => Math.random())\n * onceRandom() // 0.3\n * onceRandom() // 0.3\n *\n * onceRandom.reset() // clears the cached result — allows one more invocation\n *\n * onceRandom() // 0.2\n * onceRandom() // 0.2\n * ```\n *\n * @param fn - The function to wrap.\n *\n * @returns A `Once<T>` — the wrapped function with a `.reset()` method to clear the cached result.\n */\nexport const once = <T extends Fn>(fn: T): Once<T> => {\n let result: ReturnType<T> | undefined;\n let called = false;\n\n const wrappedFn = ((...args: Parameters<T>): ReturnType<T> => {\n if (!called) {\n result = fn(...args) as ReturnType<T>;\n called = true;\n }\n\n return result as ReturnType<T>;\n }) as Once<T>;\n\n wrappedFn.reset = () => {\n result = undefined;\n called = false;\n };\n\n return wrappedFn;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"once.js","names":[],"sources":["../../src/function/once.ts"],"sourcesContent":["import type { Fn } from '../types';\n\n/**\n * A wrapped function that executes `fn` at most once and exposes a `.reset()` method\n * to allow re-invocation.\n */\nexport type Once<T extends Fn> = T & { reset: () => void };\n\n/**\n * Create a function that runs once and returns the first result.\n *\n * If the first call throws, it does not count as \"called\" — the thrown error propagates to\n * that caller, and the next call will invoke `fn` again (rather than caching the failure).\n *\n * @example\n * ```ts\n * const onceRandom = once(() => Math.random())\n * onceRandom() // 0.3\n * onceRandom() // 0.3\n *\n * onceRandom.reset() // clears the cached result — allows one more invocation\n *\n * onceRandom() // 0.2\n * onceRandom() // 0.2\n * ```\n *\n * @param fn - The function to wrap.\n *\n * @returns A `Once<T>` — the wrapped function with a `.reset()` method to clear the cached result.\n */\nexport const once = <T extends Fn>(fn: T): Once<T> => {\n let result: ReturnType<T> | undefined;\n let called = false;\n\n const wrappedFn = ((...args: Parameters<T>): ReturnType<T> => {\n if (!called) {\n result = fn(...args) as ReturnType<T>;\n called = true;\n }\n\n return result as ReturnType<T>;\n }) as Once<T>;\n\n wrappedFn.reset = () => {\n result = undefined;\n called = false;\n };\n\n return wrappedFn;\n};\n"],"mappings":"AA8BA,IAAa,KAAsB,GAAmB,CACpD,IAAI,EACA,EAAS,GAEP,YAAc,GAAG,KACrB,AAEE,KADA,EAAS,EAAG,GAAG,CAAI,EACV,IAGJ,IAQT,MALA,WAAU,UAAc,CACtB,EAAS,IAAA,GACT,EAAS,EACX,EAEO,SACT"}
|
package/dist/function/pipe.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
function pipe(...e){if(e.length===0)return e=>e;let[t,...n]=e;return(...e)=>n.reduce((e,t)=>t(e),t(...e))}exports.pipe=pipe;
|
|
2
2
|
//# sourceMappingURL=pipe.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipe.cjs","names":[],"sources":["../../src/function/pipe.ts"],"sourcesContent":["import type { Fn } from '../types';\n\ntype FirstParameters<T extends readonly Fn[]> = T extends [infer First extends Fn, ...unknown[]]\n ? Parameters<First>\n : never;\ntype LastReturnType<T extends readonly Fn[]> = T extends [...unknown[], infer Last extends Fn]\n ? ReturnType<Last>\n : never;\n\n/**\n * Pipes multiple functions into a single function. It starts from the leftmost function and proceeds to the right.\n *\n * The TypeScript overload captures the input type from the first function and the output type from the last.\n * Intermediate steps are typed as `unknown` at the call site — TypeScript cannot infer a safe chain across\n * heterogeneous function signatures without explicit overloads for every arity.\n *\n * `pipe()` with no arguments returns an identity function `<T>(x: T) => T`.\n *\n * @example\n * ```ts\n * const add = (x: number) => x + 2;\n * const multiply = (x: number) => x * 3;\n * const subtract = (x: number) => x - 4;\n * const pipedFn = pipe(subtract, multiply, add);\n *\n * pipedFn(5); // ((5-4) * 3) + 2 = 5\n *\n * // Zero-arg identity\n * pipe()(42); // 42\n * ```\n *\n * @param fns - List of functions to be piped.\n * @returns A new function that is the pipe of the input functions.\n */\nexport function pipe(): <T>(x: T) => T;\nexport function pipe<T extends readonly [Fn, ...Fn[]]>(...fns: T): (...args: FirstParameters<T>) => LastReturnType<T>;\nexport function pipe(...fns: Fn[]): Fn {\n if (fns.length === 0) return <T>(x: T): T => x;\n\n const [firstFn, ...restFns] = fns;\n\n return (...args: never[]) =>\n restFns.reduce<unknown>((prev, fn) => (fn as (x: unknown) => unknown)(prev), firstFn(...args));\n}\n"],"mappings":"AAoCA,SAAgB,
|
|
1
|
+
{"version":3,"file":"pipe.cjs","names":[],"sources":["../../src/function/pipe.ts"],"sourcesContent":["import type { Fn } from '../types';\n\ntype FirstParameters<T extends readonly Fn[]> = T extends [infer First extends Fn, ...unknown[]]\n ? Parameters<First>\n : never;\ntype LastReturnType<T extends readonly Fn[]> = T extends [...unknown[], infer Last extends Fn]\n ? ReturnType<Last>\n : never;\n\n/**\n * Pipes multiple functions into a single function. It starts from the leftmost function and proceeds to the right.\n *\n * The TypeScript overload captures the input type from the first function and the output type from the last.\n * Intermediate steps are typed as `unknown` at the call site — TypeScript cannot infer a safe chain across\n * heterogeneous function signatures without explicit overloads for every arity.\n *\n * `pipe()` with no arguments returns an identity function `<T>(x: T) => T`.\n *\n * @example\n * ```ts\n * const add = (x: number) => x + 2;\n * const multiply = (x: number) => x * 3;\n * const subtract = (x: number) => x - 4;\n * const pipedFn = pipe(subtract, multiply, add);\n *\n * pipedFn(5); // ((5-4) * 3) + 2 = 5\n *\n * // Zero-arg identity\n * pipe()(42); // 42\n * ```\n *\n * @param fns - List of functions to be piped.\n * @returns A new function that is the pipe of the input functions.\n */\nexport function pipe(): <T>(x: T) => T;\nexport function pipe<T extends readonly [Fn, ...Fn[]]>(...fns: T): (...args: FirstParameters<T>) => LastReturnType<T>;\nexport function pipe(...fns: Fn[]): Fn {\n if (fns.length === 0) return <T>(x: T): T => x;\n\n const [firstFn, ...restFns] = fns;\n\n return (...args: never[]) =>\n restFns.reduce<unknown>((prev, fn) => (fn as (x: unknown) => unknown)(prev), firstFn(...args));\n}\n"],"mappings":"AAoCA,SAAgB,KAAK,GAAG,EAAe,CACrC,GAAI,EAAI,SAAW,EAAG,MAAW,IAAY,EAE7C,GAAM,CAAC,EAAS,GAAG,GAAW,EAE9B,OAAQ,GAAG,IACT,EAAQ,QAAiB,EAAM,IAAQ,EAA+B,CAAI,EAAG,EAAQ,GAAG,CAAI,CAAC,CACjG"}
|
package/dist/function/pipe.js
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
function e(...e) {
|
|
3
|
-
if (e.length === 0) return (e) => e;
|
|
4
|
-
let [t, ...n] = e;
|
|
5
|
-
return (...e) => n.reduce((e, t) => t(e), t(...e));
|
|
6
|
-
}
|
|
7
|
-
//#endregion
|
|
8
|
-
export { e as pipe };
|
|
9
|
-
|
|
1
|
+
function pipe(...e){if(e.length===0)return e=>e;let[t,...n]=e;return(...e)=>n.reduce((e,t)=>t(e),t(...e))}export{pipe};
|
|
10
2
|
//# sourceMappingURL=pipe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipe.js","names":[],"sources":["../../src/function/pipe.ts"],"sourcesContent":["import type { Fn } from '../types';\n\ntype FirstParameters<T extends readonly Fn[]> = T extends [infer First extends Fn, ...unknown[]]\n ? Parameters<First>\n : never;\ntype LastReturnType<T extends readonly Fn[]> = T extends [...unknown[], infer Last extends Fn]\n ? ReturnType<Last>\n : never;\n\n/**\n * Pipes multiple functions into a single function. It starts from the leftmost function and proceeds to the right.\n *\n * The TypeScript overload captures the input type from the first function and the output type from the last.\n * Intermediate steps are typed as `unknown` at the call site — TypeScript cannot infer a safe chain across\n * heterogeneous function signatures without explicit overloads for every arity.\n *\n * `pipe()` with no arguments returns an identity function `<T>(x: T) => T`.\n *\n * @example\n * ```ts\n * const add = (x: number) => x + 2;\n * const multiply = (x: number) => x * 3;\n * const subtract = (x: number) => x - 4;\n * const pipedFn = pipe(subtract, multiply, add);\n *\n * pipedFn(5); // ((5-4) * 3) + 2 = 5\n *\n * // Zero-arg identity\n * pipe()(42); // 42\n * ```\n *\n * @param fns - List of functions to be piped.\n * @returns A new function that is the pipe of the input functions.\n */\nexport function pipe(): <T>(x: T) => T;\nexport function pipe<T extends readonly [Fn, ...Fn[]]>(...fns: T): (...args: FirstParameters<T>) => LastReturnType<T>;\nexport function pipe(...fns: Fn[]): Fn {\n if (fns.length === 0) return <T>(x: T): T => x;\n\n const [firstFn, ...restFns] = fns;\n\n return (...args: never[]) =>\n restFns.reduce<unknown>((prev, fn) => (fn as (x: unknown) => unknown)(prev), firstFn(...args));\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"pipe.js","names":[],"sources":["../../src/function/pipe.ts"],"sourcesContent":["import type { Fn } from '../types';\n\ntype FirstParameters<T extends readonly Fn[]> = T extends [infer First extends Fn, ...unknown[]]\n ? Parameters<First>\n : never;\ntype LastReturnType<T extends readonly Fn[]> = T extends [...unknown[], infer Last extends Fn]\n ? ReturnType<Last>\n : never;\n\n/**\n * Pipes multiple functions into a single function. It starts from the leftmost function and proceeds to the right.\n *\n * The TypeScript overload captures the input type from the first function and the output type from the last.\n * Intermediate steps are typed as `unknown` at the call site — TypeScript cannot infer a safe chain across\n * heterogeneous function signatures without explicit overloads for every arity.\n *\n * `pipe()` with no arguments returns an identity function `<T>(x: T) => T`.\n *\n * @example\n * ```ts\n * const add = (x: number) => x + 2;\n * const multiply = (x: number) => x * 3;\n * const subtract = (x: number) => x - 4;\n * const pipedFn = pipe(subtract, multiply, add);\n *\n * pipedFn(5); // ((5-4) * 3) + 2 = 5\n *\n * // Zero-arg identity\n * pipe()(42); // 42\n * ```\n *\n * @param fns - List of functions to be piped.\n * @returns A new function that is the pipe of the input functions.\n */\nexport function pipe(): <T>(x: T) => T;\nexport function pipe<T extends readonly [Fn, ...Fn[]]>(...fns: T): (...args: FirstParameters<T>) => LastReturnType<T>;\nexport function pipe(...fns: Fn[]): Fn {\n if (fns.length === 0) return <T>(x: T): T => x;\n\n const [firstFn, ...restFns] = fns;\n\n return (...args: never[]) =>\n restFns.reduce<unknown>((prev, fn) => (fn as (x: unknown) => unknown)(prev), firstFn(...args));\n}\n"],"mappings":"AAoCA,SAAgB,KAAK,GAAG,EAAe,CACrC,GAAI,EAAI,SAAW,EAAG,MAAW,IAAY,EAE7C,GAAM,CAAC,EAAS,GAAG,GAAW,EAE9B,OAAQ,GAAG,IACT,EAAQ,QAAiB,EAAM,IAAQ,EAA+B,CAAI,EAAG,EAAQ,GAAG,CAAI,CAAC,CACjG"}
|
package/dist/function/runAll.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
function runAll(e,t){let n=[],r=e.length;if(t?.reverse)for(let t=r-1;t>=0;t--)try{e[t]?.()}catch(e){n.push(e)}else for(let t of e)try{t()}catch(e){n.push(e)}if(n.length>0)throw AggregateError(n,`One or more callbacks failed`)}exports.runAll=runAll;
|
|
2
2
|
//# sourceMappingURL=runAll.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runAll.cjs","names":[],"sources":["../../src/function/runAll.ts"],"sourcesContent":["/**\n * Runs all functions in `fns`, collecting any thrown errors.\n * - With `reverse: true`, iterates in LIFO order (useful for cleanup/teardown stacks).\n * - Throws an `AggregateError` containing all failures if any function throws.\n *\n * @example\n * ```ts\n * const cleanups = [() => a.dispose(), () => b.dispose()];\n * runAll(cleanups, { reverse: true });\n * ```\n */\nexport function runAll(fns: readonly (() => void)[], opts?: { reverse?: boolean }): void {\n const errors: unknown[] = [];\n const len = fns.length;\n\n if (opts?.reverse) {\n for (let i = len - 1; i >= 0; i--) {\n try {\n fns[i]?.();\n } catch (err) {\n errors.push(err);\n }\n }\n } else {\n for (const fn of fns) {\n try {\n fn();\n } catch (err) {\n errors.push(err);\n }\n }\n }\n\n if (errors.length > 0) {\n throw new AggregateError(errors, 'One or more callbacks failed');\n }\n}\n"],"mappings":"AAWA,SAAgB,
|
|
1
|
+
{"version":3,"file":"runAll.cjs","names":[],"sources":["../../src/function/runAll.ts"],"sourcesContent":["/**\n * Runs all functions in `fns`, collecting any thrown errors.\n * - With `reverse: true`, iterates in LIFO order (useful for cleanup/teardown stacks).\n * - Throws an `AggregateError` containing all failures if any function throws.\n *\n * @example\n * ```ts\n * const cleanups = [() => a.dispose(), () => b.dispose()];\n * runAll(cleanups, { reverse: true });\n * ```\n */\nexport function runAll(fns: readonly (() => void)[], opts?: { reverse?: boolean }): void {\n const errors: unknown[] = [];\n const len = fns.length;\n\n if (opts?.reverse) {\n for (let i = len - 1; i >= 0; i--) {\n try {\n fns[i]?.();\n } catch (err) {\n errors.push(err);\n }\n }\n } else {\n for (const fn of fns) {\n try {\n fn();\n } catch (err) {\n errors.push(err);\n }\n }\n }\n\n if (errors.length > 0) {\n throw new AggregateError(errors, 'One or more callbacks failed');\n }\n}\n"],"mappings":"AAWA,SAAgB,OAAO,EAA8B,EAAoC,CACvF,IAAM,EAAoB,CAAC,EACrB,EAAM,EAAI,OAEhB,GAAI,GAAM,QACR,IAAK,IAAI,EAAI,EAAM,EAAG,GAAK,EAAG,IAC5B,GAAI,CACF,EAAI,EAAE,GAAG,CACX,OAAS,EAAK,CACZ,EAAO,KAAK,CAAG,CACjB,MAGF,IAAK,IAAM,KAAM,EACf,GAAI,CACF,EAAG,CACL,OAAS,EAAK,CACZ,EAAO,KAAK,CAAG,CACjB,CAIJ,GAAI,EAAO,OAAS,EAClB,MAAU,eAAe,EAAQ,8BAA8B,CAEnE"}
|
package/dist/function/runAll.js
CHANGED
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
function e(e, t) {
|
|
3
|
-
let n = [], r = e.length;
|
|
4
|
-
if (t?.reverse) for (let t = r - 1; t >= 0; t--) try {
|
|
5
|
-
e[t]?.();
|
|
6
|
-
} catch (e) {
|
|
7
|
-
n.push(e);
|
|
8
|
-
}
|
|
9
|
-
else for (let t of e) try {
|
|
10
|
-
t();
|
|
11
|
-
} catch (e) {
|
|
12
|
-
n.push(e);
|
|
13
|
-
}
|
|
14
|
-
if (n.length > 0) throw AggregateError(n, "One or more callbacks failed");
|
|
15
|
-
}
|
|
16
|
-
//#endregion
|
|
17
|
-
export { e as runAll };
|
|
18
|
-
|
|
1
|
+
function runAll(e,t){let n=[],r=e.length;if(t?.reverse)for(let t=r-1;t>=0;t--)try{e[t]?.()}catch(e){n.push(e)}else for(let t of e)try{t()}catch(e){n.push(e)}if(n.length>0)throw AggregateError(n,`One or more callbacks failed`)}export{runAll};
|
|
19
2
|
//# sourceMappingURL=runAll.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runAll.js","names":[],"sources":["../../src/function/runAll.ts"],"sourcesContent":["/**\n * Runs all functions in `fns`, collecting any thrown errors.\n * - With `reverse: true`, iterates in LIFO order (useful for cleanup/teardown stacks).\n * - Throws an `AggregateError` containing all failures if any function throws.\n *\n * @example\n * ```ts\n * const cleanups = [() => a.dispose(), () => b.dispose()];\n * runAll(cleanups, { reverse: true });\n * ```\n */\nexport function runAll(fns: readonly (() => void)[], opts?: { reverse?: boolean }): void {\n const errors: unknown[] = [];\n const len = fns.length;\n\n if (opts?.reverse) {\n for (let i = len - 1; i >= 0; i--) {\n try {\n fns[i]?.();\n } catch (err) {\n errors.push(err);\n }\n }\n } else {\n for (const fn of fns) {\n try {\n fn();\n } catch (err) {\n errors.push(err);\n }\n }\n }\n\n if (errors.length > 0) {\n throw new AggregateError(errors, 'One or more callbacks failed');\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"runAll.js","names":[],"sources":["../../src/function/runAll.ts"],"sourcesContent":["/**\n * Runs all functions in `fns`, collecting any thrown errors.\n * - With `reverse: true`, iterates in LIFO order (useful for cleanup/teardown stacks).\n * - Throws an `AggregateError` containing all failures if any function throws.\n *\n * @example\n * ```ts\n * const cleanups = [() => a.dispose(), () => b.dispose()];\n * runAll(cleanups, { reverse: true });\n * ```\n */\nexport function runAll(fns: readonly (() => void)[], opts?: { reverse?: boolean }): void {\n const errors: unknown[] = [];\n const len = fns.length;\n\n if (opts?.reverse) {\n for (let i = len - 1; i >= 0; i--) {\n try {\n fns[i]?.();\n } catch (err) {\n errors.push(err);\n }\n }\n } else {\n for (const fn of fns) {\n try {\n fn();\n } catch (err) {\n errors.push(err);\n }\n }\n }\n\n if (errors.length > 0) {\n throw new AggregateError(errors, 'One or more callbacks failed');\n }\n}\n"],"mappings":"AAWA,SAAgB,OAAO,EAA8B,EAAoC,CACvF,IAAM,EAAoB,CAAC,EACrB,EAAM,EAAI,OAEhB,GAAI,GAAM,QACR,IAAK,IAAI,EAAI,EAAM,EAAG,GAAK,EAAG,IAC5B,GAAI,CACF,EAAI,EAAE,GAAG,CACX,OAAS,EAAK,CACZ,EAAO,KAAK,CAAG,CACjB,MAGF,IAAK,IAAM,KAAM,EACf,GAAI,CACF,EAAG,CACL,OAAS,EAAK,CACZ,EAAO,KAAK,CAAG,CACjB,CAIJ,GAAI,EAAO,OAAS,EAClB,MAAU,eAAe,EAAQ,8BAA8B,CAEnE"}
|
package/dist/function/tap.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
function tap(e,t){return t(e),e}exports.tap=tap;
|
|
2
2
|
//# sourceMappingURL=tap.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tap.cjs","names":[],"sources":["../../src/function/tap.ts"],"sourcesContent":["/**\n * Executes a side-effect callback and returns the original value.\n */\nexport function tap<T>(value: T, callback: (value: T) => void): T {\n callback(value);\n\n return value;\n}\n"],"mappings":"AAGA,SAAgB,
|
|
1
|
+
{"version":3,"file":"tap.cjs","names":[],"sources":["../../src/function/tap.ts"],"sourcesContent":["/**\n * Executes a side-effect callback and returns the original value.\n */\nexport function tap<T>(value: T, callback: (value: T) => void): T {\n callback(value);\n\n return value;\n}\n"],"mappings":"AAGA,SAAgB,IAAO,EAAU,EAAiC,CAGhE,OAFA,EAAS,CAAK,EAEP,CACT"}
|