@vielzeug/arsenal 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -0
- package/dist/_common/_abortable.d.ts +5 -0
- package/dist/_common/_abortable.d.ts.map +1 -0
- package/dist/_common/_lruMap.cjs +2 -0
- package/dist/_common/_lruMap.cjs.map +1 -0
- package/dist/_common/_lruMap.d.ts +20 -0
- package/dist/_common/_lruMap.d.ts.map +1 -0
- package/dist/_common/_lruMap.js +18 -0
- package/dist/_common/_lruMap.js.map +1 -0
- package/dist/_common/_secureRandomIndex.cjs +2 -0
- package/dist/_common/_secureRandomIndex.cjs.map +1 -0
- package/dist/_common/_secureRandomIndex.d.ts +2 -0
- package/dist/_common/_secureRandomIndex.d.ts.map +1 -0
- package/dist/_common/_secureRandomIndex.js +9 -0
- package/dist/_common/_secureRandomIndex.js.map +1 -0
- package/dist/_common/_selectorSet.cjs +2 -0
- package/dist/_common/_selectorSet.cjs.map +1 -0
- package/dist/_common/_selectorSet.d.ts +2 -0
- package/dist/_common/_selectorSet.d.ts.map +1 -0
- package/dist/_common/_selectorSet.js +16 -0
- package/dist/_common/_selectorSet.js.map +1 -0
- package/dist/_common/unsafePaths.cjs +2 -0
- package/dist/_common/unsafePaths.cjs.map +1 -0
- package/dist/_common/unsafePaths.d.ts +25 -0
- package/dist/_common/unsafePaths.d.ts.map +1 -0
- package/dist/_common/unsafePaths.js +13 -0
- package/dist/_common/unsafePaths.js.map +1 -0
- package/dist/_dev.cjs +2 -0
- package/dist/_dev.cjs.map +1 -0
- package/dist/_dev.d.ts +2 -0
- package/dist/_dev.d.ts.map +1 -0
- package/dist/_dev.js +9 -0
- package/dist/_dev.js.map +1 -0
- package/dist/array/chunk.cjs +2 -0
- package/dist/array/chunk.cjs.map +1 -0
- package/dist/array/chunk.d.ts +19 -0
- package/dist/array/chunk.d.ts.map +1 -0
- package/dist/array/chunk.js +12 -0
- package/dist/array/chunk.js.map +1 -0
- package/dist/array/compact.cjs +2 -0
- package/dist/array/compact.cjs.map +1 -0
- package/dist/array/compact.d.ts +7 -0
- package/dist/array/compact.d.ts.map +1 -0
- package/dist/array/compact.js +8 -0
- package/dist/array/compact.js.map +1 -0
- package/dist/array/compare.cjs +2 -0
- package/dist/array/compare.cjs.map +1 -0
- package/dist/array/compare.d.ts +31 -0
- package/dist/array/compare.d.ts.map +1 -0
- package/dist/array/compare.js +20 -0
- package/dist/array/compare.js.map +1 -0
- package/dist/array/compareBy.cjs +2 -0
- package/dist/array/compareBy.cjs.map +1 -0
- package/dist/array/compareBy.d.ts +24 -0
- package/dist/array/compareBy.d.ts.map +1 -0
- package/dist/array/compareBy.js +16 -0
- package/dist/array/compareBy.js.map +1 -0
- package/dist/array/contains.cjs +2 -0
- package/dist/array/contains.cjs.map +1 -0
- package/dist/array/contains.d.ts +17 -0
- package/dist/array/contains.d.ts.map +1 -0
- package/dist/array/contains.js +9 -0
- package/dist/array/contains.js.map +1 -0
- package/dist/array/countBy.cjs +2 -0
- package/dist/array/countBy.cjs.map +1 -0
- package/dist/array/countBy.d.ts +8 -0
- package/dist/array/countBy.d.ts.map +1 -0
- package/dist/array/countBy.js +14 -0
- package/dist/array/countBy.js.map +1 -0
- package/dist/array/difference.cjs +2 -0
- package/dist/array/difference.cjs.map +1 -0
- package/dist/array/difference.d.ts +6 -0
- package/dist/array/difference.d.ts.map +1 -0
- package/dist/array/difference.js +14 -0
- package/dist/array/difference.js.map +1 -0
- package/dist/array/drop.cjs +2 -0
- package/dist/array/drop.cjs.map +1 -0
- package/dist/array/drop.d.ts +5 -0
- package/dist/array/drop.d.ts.map +1 -0
- package/dist/array/drop.js +9 -0
- package/dist/array/drop.js.map +1 -0
- package/dist/array/dropLast.cjs +2 -0
- package/dist/array/dropLast.cjs.map +1 -0
- package/dist/array/dropLast.d.ts +5 -0
- package/dist/array/dropLast.d.ts.map +1 -0
- package/dist/array/dropLast.js +9 -0
- package/dist/array/dropLast.js.map +1 -0
- package/dist/array/filterMap.cjs +2 -0
- package/dist/array/filterMap.cjs.map +1 -0
- package/dist/array/filterMap.d.ts +5 -0
- package/dist/array/filterMap.d.ts.map +1 -0
- package/dist/array/filterMap.js +13 -0
- package/dist/array/filterMap.js.map +1 -0
- package/dist/array/first.cjs +2 -0
- package/dist/array/first.cjs.map +1 -0
- package/dist/array/first.d.ts +5 -0
- package/dist/array/first.d.ts.map +1 -0
- package/dist/array/first.js +8 -0
- package/dist/array/first.js.map +1 -0
- package/dist/array/flatten.cjs +2 -0
- package/dist/array/flatten.cjs.map +1 -0
- package/dist/array/flatten.d.ts +5 -0
- package/dist/array/flatten.d.ts.map +1 -0
- package/dist/array/flatten.js +11 -0
- package/dist/array/flatten.js.map +1 -0
- package/dist/array/groupBy.cjs +2 -0
- package/dist/array/groupBy.cjs.map +1 -0
- package/dist/array/groupBy.d.ts +7 -0
- package/dist/array/groupBy.d.ts.map +1 -0
- package/dist/array/groupBy.js +14 -0
- package/dist/array/groupBy.js.map +1 -0
- package/dist/array/index.d.ts +29 -0
- package/dist/array/index.d.ts.map +1 -0
- package/dist/array/indexBy.cjs +2 -0
- package/dist/array/indexBy.cjs.map +1 -0
- package/dist/array/indexBy.d.ts +7 -0
- package/dist/array/indexBy.d.ts.map +1 -0
- package/dist/array/indexBy.js +14 -0
- package/dist/array/indexBy.js.map +1 -0
- package/dist/array/intersection.cjs +2 -0
- package/dist/array/intersection.cjs.map +1 -0
- package/dist/array/intersection.d.ts +6 -0
- package/dist/array/intersection.d.ts.map +1 -0
- package/dist/array/intersection.js +14 -0
- package/dist/array/intersection.js.map +1 -0
- package/dist/array/last.cjs +2 -0
- package/dist/array/last.cjs.map +1 -0
- package/dist/array/last.d.ts +5 -0
- package/dist/array/last.d.ts.map +1 -0
- package/dist/array/last.js +8 -0
- package/dist/array/last.js.map +1 -0
- package/dist/array/partition.cjs +2 -0
- package/dist/array/partition.cjs.map +1 -0
- package/dist/array/partition.d.ts +5 -0
- package/dist/array/partition.d.ts.map +1 -0
- package/dist/array/partition.js +10 -0
- package/dist/array/partition.js.map +1 -0
- package/dist/array/replace.cjs +2 -0
- package/dist/array/replace.cjs.map +1 -0
- package/dist/array/replace.d.ts +18 -0
- package/dist/array/replace.d.ts.map +1 -0
- package/dist/array/replace.js +13 -0
- package/dist/array/replace.js.map +1 -0
- package/dist/array/rotate.cjs +2 -0
- package/dist/array/rotate.cjs.map +1 -0
- package/dist/array/rotate.d.ts +20 -0
- package/dist/array/rotate.d.ts.map +1 -0
- package/dist/array/rotate.js +10 -0
- package/dist/array/rotate.js.map +1 -0
- package/dist/array/search.cjs +2 -0
- package/dist/array/search.cjs.map +1 -0
- package/dist/array/search.d.ts +85 -0
- package/dist/array/search.d.ts.map +1 -0
- package/dist/array/search.js +47 -0
- package/dist/array/search.js.map +1 -0
- package/dist/array/sort.cjs +2 -0
- package/dist/array/sort.cjs.map +1 -0
- package/dist/array/sort.d.ts +26 -0
- package/dist/array/sort.d.ts.map +1 -0
- package/dist/array/sort.js +16 -0
- package/dist/array/sort.js.map +1 -0
- package/dist/array/take.cjs +2 -0
- package/dist/array/take.cjs.map +1 -0
- package/dist/array/take.d.ts +5 -0
- package/dist/array/take.d.ts.map +1 -0
- package/dist/array/take.js +9 -0
- package/dist/array/take.js.map +1 -0
- package/dist/array/takeLast.cjs +2 -0
- package/dist/array/takeLast.cjs.map +1 -0
- package/dist/array/takeLast.d.ts +5 -0
- package/dist/array/takeLast.d.ts.map +1 -0
- package/dist/array/takeLast.js +9 -0
- package/dist/array/takeLast.js.map +1 -0
- package/dist/array/toggle.cjs +2 -0
- package/dist/array/toggle.cjs.map +1 -0
- package/dist/array/toggle.d.ts +29 -0
- package/dist/array/toggle.d.ts.map +1 -0
- package/dist/array/toggle.js +9 -0
- package/dist/array/toggle.js.map +1 -0
- package/dist/array/union.cjs +2 -0
- package/dist/array/union.cjs.map +1 -0
- package/dist/array/union.d.ts +6 -0
- package/dist/array/union.d.ts.map +1 -0
- package/dist/array/union.js +9 -0
- package/dist/array/union.js.map +1 -0
- package/dist/array/uniq.cjs +2 -0
- package/dist/array/uniq.cjs.map +1 -0
- package/dist/array/uniq.d.ts +18 -0
- package/dist/array/uniq.d.ts.map +1 -0
- package/dist/array/uniq.js +9 -0
- package/dist/array/uniq.js.map +1 -0
- package/dist/array/unzip.cjs +2 -0
- package/dist/array/unzip.cjs.map +1 -0
- package/dist/array/unzip.d.ts +7 -0
- package/dist/array/unzip.d.ts.map +1 -0
- package/dist/array/unzip.js +11 -0
- package/dist/array/unzip.js.map +1 -0
- package/dist/array/zip.cjs +2 -0
- package/dist/array/zip.cjs.map +1 -0
- package/dist/array/zip.d.ts +7 -0
- package/dist/array/zip.d.ts.map +1 -0
- package/dist/array/zip.js +11 -0
- package/dist/array/zip.js.map +1 -0
- package/dist/arsenal.cjs +2 -0
- package/dist/arsenal.cjs.map +1 -0
- package/dist/arsenal.iife.js +2 -0
- package/dist/arsenal.iife.js.map +1 -0
- package/dist/arsenal.js +2 -0
- package/dist/arsenal.js.map +1 -0
- package/dist/async/abortError.cjs +2 -0
- package/dist/async/abortError.cjs.map +1 -0
- package/dist/async/abortError.d.ts +23 -0
- package/dist/async/abortError.d.ts.map +1 -0
- package/dist/async/abortError.js +8 -0
- package/dist/async/abortError.js.map +1 -0
- package/dist/async/attempt.cjs +2 -0
- package/dist/async/attempt.cjs.map +1 -0
- package/dist/async/attempt.d.ts +58 -0
- package/dist/async/attempt.d.ts.map +1 -0
- package/dist/async/attempt.js +31 -0
- package/dist/async/attempt.js.map +1 -0
- package/dist/async/backoff.cjs +2 -0
- package/dist/async/backoff.cjs.map +1 -0
- package/dist/async/backoff.d.ts +20 -0
- package/dist/async/backoff.d.ts.map +1 -0
- package/dist/async/backoff.js +9 -0
- package/dist/async/backoff.js.map +1 -0
- package/dist/async/index.d.ts +9 -0
- package/dist/async/index.d.ts.map +1 -0
- package/dist/async/parallel.cjs +2 -0
- package/dist/async/parallel.cjs.map +1 -0
- package/dist/async/parallel.d.ts +42 -0
- package/dist/async/parallel.d.ts.map +1 -0
- package/dist/async/parallel.js +26 -0
- package/dist/async/parallel.js.map +1 -0
- package/dist/async/queue.cjs +2 -0
- package/dist/async/queue.cjs.map +1 -0
- package/dist/async/queue.d.ts +42 -0
- package/dist/async/queue.d.ts.map +1 -0
- package/dist/async/queue.js +72 -0
- package/dist/async/queue.js.map +1 -0
- package/dist/async/retry.cjs +2 -0
- package/dist/async/retry.cjs.map +1 -0
- package/dist/async/retry.d.ts +46 -0
- package/dist/async/retry.d.ts.map +1 -0
- package/dist/async/retry.js +26 -0
- package/dist/async/retry.js.map +1 -0
- package/dist/async/sleep.cjs +2 -0
- package/dist/async/sleep.cjs.map +1 -0
- package/dist/async/sleep.d.ts +21 -0
- package/dist/async/sleep.d.ts.map +1 -0
- package/dist/async/sleep.js +16 -0
- package/dist/async/sleep.js.map +1 -0
- package/dist/async/waitFor.cjs +2 -0
- package/dist/async/waitFor.cjs.map +1 -0
- package/dist/async/waitFor.d.ts +34 -0
- package/dist/async/waitFor.d.ts.map +1 -0
- package/dist/async/waitFor.js +13 -0
- package/dist/async/waitFor.js.map +1 -0
- package/dist/cache/index.d.ts +3 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/memo.cjs +2 -0
- package/dist/cache/memo.cjs.map +1 -0
- package/dist/cache/memo.d.ts +40 -0
- package/dist/cache/memo.d.ts.map +1 -0
- package/dist/cache/memo.js +37 -0
- package/dist/cache/memo.js.map +1 -0
- package/dist/cache/stash.cjs +2 -0
- package/dist/cache/stash.cjs.map +1 -0
- package/dist/cache/stash.d.ts +111 -0
- package/dist/cache/stash.d.ts.map +1 -0
- package/dist/cache/stash.js +92 -0
- package/dist/cache/stash.js.map +1 -0
- package/dist/errors.cjs +2 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.ts +20 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +13 -0
- package/dist/errors.js.map +1 -0
- package/dist/function/assert.cjs +2 -0
- package/dist/function/assert.cjs.map +1 -0
- package/dist/function/assert.d.ts +19 -0
- package/dist/function/assert.d.ts.map +1 -0
- package/dist/function/assert.js +8 -0
- package/dist/function/assert.js.map +1 -0
- package/dist/function/constant.cjs +2 -0
- package/dist/function/constant.cjs.map +1 -0
- package/dist/function/constant.d.ts +5 -0
- package/dist/function/constant.d.ts.map +1 -0
- package/dist/function/constant.js +8 -0
- package/dist/function/constant.js.map +1 -0
- package/dist/function/debounce.cjs +2 -0
- package/dist/function/debounce.cjs.map +1 -0
- package/dist/function/debounce.d.ts +31 -0
- package/dist/function/debounce.d.ts.map +1 -0
- package/dist/function/debounce.js +29 -0
- package/dist/function/debounce.js.map +1 -0
- package/dist/function/identity.cjs +2 -0
- package/dist/function/identity.cjs.map +1 -0
- package/dist/function/identity.d.ts +5 -0
- package/dist/function/identity.d.ts.map +1 -0
- package/dist/function/identity.js +8 -0
- package/dist/function/identity.js.map +1 -0
- package/dist/function/index.d.ts +10 -0
- package/dist/function/index.d.ts.map +1 -0
- package/dist/function/once.cjs +2 -0
- package/dist/function/once.cjs.map +1 -0
- package/dist/function/once.d.ts +32 -0
- package/dist/function/once.d.ts.map +1 -0
- package/dist/function/once.js +11 -0
- package/dist/function/once.js.map +1 -0
- package/dist/function/pipe.cjs +2 -0
- package/dist/function/pipe.cjs.map +1 -0
- package/dist/function/pipe.d.ts +32 -0
- package/dist/function/pipe.d.ts.map +1 -0
- package/dist/function/pipe.js +10 -0
- package/dist/function/pipe.js.map +1 -0
- package/dist/function/runAll.cjs +2 -0
- package/dist/function/runAll.cjs.map +1 -0
- package/dist/function/runAll.d.ts +15 -0
- package/dist/function/runAll.d.ts.map +1 -0
- package/dist/function/runAll.js +19 -0
- package/dist/function/runAll.js.map +1 -0
- package/dist/function/tap.cjs +2 -0
- package/dist/function/tap.cjs.map +1 -0
- package/dist/function/tap.d.ts +5 -0
- package/dist/function/tap.d.ts.map +1 -0
- package/dist/function/tap.js +8 -0
- package/dist/function/tap.js.map +1 -0
- package/dist/function/throttle.cjs +2 -0
- package/dist/function/throttle.cjs.map +1 -0
- package/dist/function/throttle.d.ts +23 -0
- package/dist/function/throttle.d.ts.map +1 -0
- package/dist/function/throttle.js +36 -0
- package/dist/function/throttle.js.map +1 -0
- package/dist/guards/combinators.cjs +2 -0
- package/dist/guards/combinators.cjs.map +1 -0
- package/dist/guards/combinators.d.ts +49 -0
- package/dist/guards/combinators.d.ts.map +1 -0
- package/dist/guards/combinators.js +17 -0
- package/dist/guards/combinators.js.map +1 -0
- package/dist/guards/index.d.ts +20 -0
- package/dist/guards/index.d.ts.map +1 -0
- package/dist/guards/isAbortError.cjs +2 -0
- package/dist/guards/isAbortError.cjs.map +1 -0
- package/dist/guards/isAbortError.d.ts +19 -0
- package/dist/guards/isAbortError.d.ts.map +1 -0
- package/dist/guards/isAbortError.js +8 -0
- package/dist/guards/isAbortError.js.map +1 -0
- package/dist/guards/isArray.cjs +2 -0
- package/dist/guards/isArray.cjs.map +1 -0
- package/dist/guards/isArray.d.ts +16 -0
- package/dist/guards/isArray.d.ts.map +1 -0
- package/dist/guards/isArray.js +8 -0
- package/dist/guards/isArray.js.map +1 -0
- package/dist/guards/isBoolean.cjs +2 -0
- package/dist/guards/isBoolean.cjs.map +1 -0
- package/dist/guards/isBoolean.d.ts +23 -0
- package/dist/guards/isBoolean.d.ts.map +1 -0
- package/dist/guards/isBoolean.js +8 -0
- package/dist/guards/isBoolean.js.map +1 -0
- package/dist/guards/isDate.cjs +2 -0
- package/dist/guards/isDate.cjs.map +1 -0
- package/dist/guards/isDate.d.ts +15 -0
- package/dist/guards/isDate.d.ts.map +1 -0
- package/dist/guards/isDate.js +8 -0
- package/dist/guards/isDate.js.map +1 -0
- package/dist/guards/isDefined.cjs +2 -0
- package/dist/guards/isDefined.cjs.map +1 -0
- package/dist/guards/isDefined.d.ts +19 -0
- package/dist/guards/isDefined.d.ts.map +1 -0
- package/dist/guards/isDefined.js +8 -0
- package/dist/guards/isDefined.js.map +1 -0
- package/dist/guards/isEmpty.cjs +2 -0
- package/dist/guards/isEmpty.cjs.map +1 -0
- package/dist/guards/isEmpty.d.ts +23 -0
- package/dist/guards/isEmpty.d.ts.map +1 -0
- package/dist/guards/isEmpty.js +10 -0
- package/dist/guards/isEmpty.js.map +1 -0
- package/dist/guards/isEqual.cjs +2 -0
- package/dist/guards/isEqual.cjs.map +1 -0
- package/dist/guards/isEqual.d.ts +24 -0
- package/dist/guards/isEqual.d.ts.map +1 -0
- package/dist/guards/isEqual.js +34 -0
- package/dist/guards/isEqual.js.map +1 -0
- package/dist/guards/isError.cjs +2 -0
- package/dist/guards/isError.cjs.map +1 -0
- package/dist/guards/isError.d.ts +15 -0
- package/dist/guards/isError.d.ts.map +1 -0
- package/dist/guards/isError.js +8 -0
- package/dist/guards/isError.js.map +1 -0
- package/dist/guards/isFunction.cjs +2 -0
- package/dist/guards/isFunction.cjs.map +1 -0
- package/dist/guards/isFunction.d.ts +16 -0
- package/dist/guards/isFunction.d.ts.map +1 -0
- package/dist/guards/isFunction.js +8 -0
- package/dist/guards/isFunction.js.map +1 -0
- package/dist/guards/isMatch.cjs +2 -0
- package/dist/guards/isMatch.cjs.map +1 -0
- package/dist/guards/isMatch.d.ts +23 -0
- package/dist/guards/isMatch.d.ts.map +1 -0
- package/dist/guards/isMatch.js +23 -0
- package/dist/guards/isMatch.js.map +1 -0
- package/dist/guards/isNil.cjs +2 -0
- package/dist/guards/isNil.cjs.map +1 -0
- package/dist/guards/isNil.d.ts +17 -0
- package/dist/guards/isNil.d.ts.map +1 -0
- package/dist/guards/isNil.js +8 -0
- package/dist/guards/isNil.js.map +1 -0
- package/dist/guards/isNumber.cjs +2 -0
- package/dist/guards/isNumber.cjs.map +1 -0
- package/dist/guards/isNumber.d.ts +15 -0
- package/dist/guards/isNumber.d.ts.map +1 -0
- package/dist/guards/isNumber.js +8 -0
- package/dist/guards/isNumber.js.map +1 -0
- package/dist/guards/isPlainObject.cjs +2 -0
- package/dist/guards/isPlainObject.cjs.map +1 -0
- package/dist/guards/isPlainObject.d.ts +16 -0
- package/dist/guards/isPlainObject.d.ts.map +1 -0
- package/dist/guards/isPlainObject.js +10 -0
- package/dist/guards/isPlainObject.js.map +1 -0
- package/dist/guards/isPrimitive.cjs +2 -0
- package/dist/guards/isPrimitive.cjs.map +1 -0
- package/dist/guards/isPrimitive.d.ts +18 -0
- package/dist/guards/isPrimitive.d.ts.map +1 -0
- package/dist/guards/isPrimitive.js +9 -0
- package/dist/guards/isPrimitive.js.map +1 -0
- package/dist/guards/isPromise.cjs +2 -0
- package/dist/guards/isPromise.cjs.map +1 -0
- package/dist/guards/isPromise.d.ts +17 -0
- package/dist/guards/isPromise.d.ts.map +1 -0
- package/dist/guards/isPromise.js +8 -0
- package/dist/guards/isPromise.js.map +1 -0
- package/dist/guards/isRegex.cjs +2 -0
- package/dist/guards/isRegex.cjs.map +1 -0
- package/dist/guards/isRegex.d.ts +21 -0
- package/dist/guards/isRegex.d.ts.map +1 -0
- package/dist/guards/isRegex.js +8 -0
- package/dist/guards/isRegex.js.map +1 -0
- package/dist/guards/isString.cjs +2 -0
- package/dist/guards/isString.cjs.map +1 -0
- package/dist/guards/isString.d.ts +15 -0
- package/dist/guards/isString.d.ts.map +1 -0
- package/dist/guards/isString.js +8 -0
- package/dist/guards/isString.js.map +1 -0
- package/dist/guards/shallowEqual.cjs +2 -0
- package/dist/guards/shallowEqual.cjs.map +1 -0
- package/dist/guards/shallowEqual.d.ts +29 -0
- package/dist/guards/shallowEqual.d.ts.map +1 -0
- package/dist/guards/shallowEqual.js +20 -0
- package/dist/guards/shallowEqual.js.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +119 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +118 -0
- package/dist/math/abs.cjs +2 -0
- package/dist/math/abs.cjs.map +1 -0
- package/dist/math/abs.d.ts +17 -0
- package/dist/math/abs.d.ts.map +1 -0
- package/dist/math/abs.js +8 -0
- package/dist/math/abs.js.map +1 -0
- package/dist/math/allocate.cjs +2 -0
- package/dist/math/allocate.cjs.map +1 -0
- package/dist/math/allocate.d.ts +29 -0
- package/dist/math/allocate.d.ts.map +1 -0
- package/dist/math/allocate.js +20 -0
- package/dist/math/allocate.js.map +1 -0
- package/dist/math/average.cjs +2 -0
- package/dist/math/average.cjs.map +1 -0
- package/dist/math/average.d.ts +16 -0
- package/dist/math/average.d.ts.map +1 -0
- package/dist/math/average.js +14 -0
- package/dist/math/average.js.map +1 -0
- package/dist/math/clamp.cjs +2 -0
- package/dist/math/clamp.cjs.map +1 -0
- package/dist/math/clamp.d.ts +21 -0
- package/dist/math/clamp.d.ts.map +1 -0
- package/dist/math/clamp.js +8 -0
- package/dist/math/clamp.js.map +1 -0
- package/dist/math/gcd.cjs +2 -0
- package/dist/math/gcd.cjs.map +1 -0
- package/dist/math/gcd.d.ts +18 -0
- package/dist/math/gcd.d.ts.map +1 -0
- package/dist/math/gcd.js +13 -0
- package/dist/math/gcd.js.map +1 -0
- package/dist/math/index.d.ts +20 -0
- package/dist/math/index.d.ts.map +1 -0
- package/dist/math/lcm.cjs +2 -0
- package/dist/math/lcm.cjs.map +1 -0
- package/dist/math/lcm.d.ts +15 -0
- package/dist/math/lcm.d.ts.map +1 -0
- package/dist/math/lcm.js +9 -0
- package/dist/math/lcm.js.map +1 -0
- package/dist/math/lerp.cjs +2 -0
- package/dist/math/lerp.cjs.map +1 -0
- package/dist/math/lerp.d.ts +17 -0
- package/dist/math/lerp.d.ts.map +1 -0
- package/dist/math/lerp.js +8 -0
- package/dist/math/lerp.js.map +1 -0
- package/dist/math/linspace.cjs +2 -0
- package/dist/math/linspace.cjs.map +1 -0
- package/dist/math/linspace.d.ts +19 -0
- package/dist/math/linspace.d.ts.map +1 -0
- package/dist/math/linspace.js +11 -0
- package/dist/math/linspace.js.map +1 -0
- package/dist/math/max.cjs +2 -0
- package/dist/math/max.cjs.map +1 -0
- package/dist/math/max.d.ts +21 -0
- package/dist/math/max.d.ts.map +1 -0
- package/dist/math/max.js +12 -0
- package/dist/math/max.js.map +1 -0
- package/dist/math/median.cjs +2 -0
- package/dist/math/median.cjs.map +1 -0
- package/dist/math/median.d.ts +17 -0
- package/dist/math/median.d.ts.map +1 -0
- package/dist/math/median.js +12 -0
- package/dist/math/median.js.map +1 -0
- package/dist/math/min.cjs +2 -0
- package/dist/math/min.cjs.map +1 -0
- package/dist/math/min.d.ts +21 -0
- package/dist/math/min.d.ts.map +1 -0
- package/dist/math/min.js +12 -0
- package/dist/math/min.js.map +1 -0
- package/dist/math/mod.cjs +2 -0
- package/dist/math/mod.cjs.map +1 -0
- package/dist/math/mod.d.ts +18 -0
- package/dist/math/mod.d.ts.map +1 -0
- package/dist/math/mod.js +10 -0
- package/dist/math/mod.js.map +1 -0
- package/dist/math/normalize.cjs +2 -0
- package/dist/math/normalize.cjs.map +1 -0
- package/dist/math/normalize.d.ts +18 -0
- package/dist/math/normalize.d.ts.map +1 -0
- package/dist/math/normalize.js +9 -0
- package/dist/math/normalize.js.map +1 -0
- package/dist/math/percent.cjs +2 -0
- package/dist/math/percent.cjs.map +1 -0
- package/dist/math/percent.d.ts +19 -0
- package/dist/math/percent.d.ts.map +1 -0
- package/dist/math/percent.js +8 -0
- package/dist/math/percent.js.map +1 -0
- package/dist/math/range.cjs +2 -0
- package/dist/math/range.cjs.map +1 -0
- package/dist/math/range.d.ts +37 -0
- package/dist/math/range.d.ts.map +1 -0
- package/dist/math/range.js +27 -0
- package/dist/math/range.js.map +1 -0
- package/dist/math/round.cjs +2 -0
- package/dist/math/round.cjs.map +1 -0
- package/dist/math/round.d.ts +21 -0
- package/dist/math/round.d.ts.map +1 -0
- package/dist/math/round.js +10 -0
- package/dist/math/round.js.map +1 -0
- package/dist/math/standardDeviation.cjs +2 -0
- package/dist/math/standardDeviation.cjs.map +1 -0
- package/dist/math/standardDeviation.d.ts +16 -0
- package/dist/math/standardDeviation.d.ts.map +1 -0
- package/dist/math/standardDeviation.js +9 -0
- package/dist/math/standardDeviation.js.map +1 -0
- package/dist/math/sum.cjs +2 -0
- package/dist/math/sum.cjs.map +1 -0
- package/dist/math/sum.d.ts +19 -0
- package/dist/math/sum.d.ts.map +1 -0
- package/dist/math/sum.js +13 -0
- package/dist/math/sum.js.map +1 -0
- package/dist/math/variance.cjs +2 -0
- package/dist/math/variance.cjs.map +1 -0
- package/dist/math/variance.d.ts +17 -0
- package/dist/math/variance.d.ts.map +1 -0
- package/dist/math/variance.js +11 -0
- package/dist/math/variance.js.map +1 -0
- package/dist/object/defaults.cjs +2 -0
- package/dist/object/defaults.cjs.map +1 -0
- package/dist/object/defaults.d.ts +17 -0
- package/dist/object/defaults.d.ts.map +1 -0
- package/dist/object/defaults.js +12 -0
- package/dist/object/defaults.js.map +1 -0
- package/dist/object/diff.cjs +2 -0
- package/dist/object/diff.cjs.map +1 -0
- package/dist/object/diff.d.ts +63 -0
- package/dist/object/diff.d.ts.map +1 -0
- package/dist/object/diff.js +27 -0
- package/dist/object/diff.js.map +1 -0
- package/dist/object/filterValues.cjs +2 -0
- package/dist/object/filterValues.cjs.map +1 -0
- package/dist/object/filterValues.d.ts +16 -0
- package/dist/object/filterValues.d.ts.map +1 -0
- package/dist/object/filterValues.js +11 -0
- package/dist/object/filterValues.js.map +1 -0
- package/dist/object/flattenPaths.cjs +2 -0
- package/dist/object/flattenPaths.cjs.map +1 -0
- package/dist/object/flattenPaths.d.ts +13 -0
- package/dist/object/flattenPaths.d.ts.map +1 -0
- package/dist/object/flattenPaths.js +31 -0
- package/dist/object/flattenPaths.js.map +1 -0
- package/dist/object/getPath.cjs +2 -0
- package/dist/object/getPath.cjs.map +1 -0
- package/dist/object/getPath.d.ts +48 -0
- package/dist/object/getPath.d.ts.map +1 -0
- package/dist/object/getPath.js +27 -0
- package/dist/object/getPath.js.map +1 -0
- package/dist/object/hash.cjs +2 -0
- package/dist/object/hash.cjs.map +1 -0
- package/dist/object/hash.d.ts +12 -0
- package/dist/object/hash.d.ts.map +1 -0
- package/dist/object/hash.js +28 -0
- package/dist/object/hash.js.map +1 -0
- package/dist/object/index.d.ts +15 -0
- package/dist/object/index.d.ts.map +1 -0
- package/dist/object/invert.cjs +2 -0
- package/dist/object/invert.cjs.map +1 -0
- package/dist/object/invert.d.ts +15 -0
- package/dist/object/invert.d.ts.map +1 -0
- package/dist/object/invert.js +11 -0
- package/dist/object/invert.js.map +1 -0
- package/dist/object/mapKeys.cjs +2 -0
- package/dist/object/mapKeys.cjs.map +1 -0
- package/dist/object/mapKeys.d.ts +16 -0
- package/dist/object/mapKeys.d.ts.map +1 -0
- package/dist/object/mapKeys.js +15 -0
- package/dist/object/mapKeys.js.map +1 -0
- package/dist/object/mapValues.cjs +2 -0
- package/dist/object/mapValues.cjs.map +1 -0
- package/dist/object/mapValues.d.ts +18 -0
- package/dist/object/mapValues.d.ts.map +1 -0
- package/dist/object/mapValues.js +11 -0
- package/dist/object/mapValues.js.map +1 -0
- package/dist/object/merge.cjs +2 -0
- package/dist/object/merge.cjs.map +1 -0
- package/dist/object/merge.d.ts +41 -0
- package/dist/object/merge.d.ts.map +1 -0
- package/dist/object/merge.js +27 -0
- package/dist/object/merge.js.map +1 -0
- package/dist/object/omit.cjs +2 -0
- package/dist/object/omit.cjs.map +1 -0
- package/dist/object/omit.d.ts +16 -0
- package/dist/object/omit.d.ts.map +1 -0
- package/dist/object/omit.js +11 -0
- package/dist/object/omit.js.map +1 -0
- package/dist/object/parseJSON.cjs +2 -0
- package/dist/object/parseJSON.cjs.map +1 -0
- package/dist/object/parseJSON.d.ts +32 -0
- package/dist/object/parseJSON.d.ts.map +1 -0
- package/dist/object/parseJSON.js +16 -0
- package/dist/object/parseJSON.js.map +1 -0
- package/dist/object/pick.cjs +2 -0
- package/dist/object/pick.cjs.map +1 -0
- package/dist/object/pick.d.ts +17 -0
- package/dist/object/pick.d.ts.map +1 -0
- package/dist/object/pick.js +11 -0
- package/dist/object/pick.js.map +1 -0
- package/dist/object/prune.cjs +2 -0
- package/dist/object/prune.cjs.map +1 -0
- package/dist/object/prune.d.ts +26 -0
- package/dist/object/prune.d.ts.map +1 -0
- package/dist/object/prune.js +36 -0
- package/dist/object/prune.js.map +1 -0
- package/dist/random/draw.cjs +2 -0
- package/dist/random/draw.cjs.map +1 -0
- package/dist/random/draw.d.ts +24 -0
- package/dist/random/draw.d.ts.map +1 -0
- package/dist/random/draw.js +21 -0
- package/dist/random/draw.js.map +1 -0
- package/dist/random/index.d.ts +5 -0
- package/dist/random/index.d.ts.map +1 -0
- package/dist/random/random.cjs +2 -0
- package/dist/random/random.cjs.map +1 -0
- package/dist/random/random.d.ts +14 -0
- package/dist/random/random.d.ts.map +1 -0
- package/dist/random/random.js +11 -0
- package/dist/random/random.js.map +1 -0
- package/dist/random/shuffle.cjs +2 -0
- package/dist/random/shuffle.cjs.map +1 -0
- package/dist/random/shuffle.d.ts +12 -0
- package/dist/random/shuffle.d.ts.map +1 -0
- package/dist/random/shuffle.js +14 -0
- package/dist/random/shuffle.js.map +1 -0
- package/dist/random/uuid.cjs +2 -0
- package/dist/random/uuid.cjs.map +1 -0
- package/dist/random/uuid.d.ts +12 -0
- package/dist/random/uuid.d.ts.map +1 -0
- package/dist/random/uuid.js +8 -0
- package/dist/random/uuid.js.map +1 -0
- package/dist/string/_caseUtils.cjs +2 -0
- package/dist/string/_caseUtils.cjs.map +1 -0
- package/dist/string/_caseUtils.d.ts +9 -0
- package/dist/string/_caseUtils.d.ts.map +1 -0
- package/dist/string/_caseUtils.js +13 -0
- package/dist/string/_caseUtils.js.map +1 -0
- package/dist/string/camelCase.cjs +2 -0
- package/dist/string/camelCase.cjs.map +1 -0
- package/dist/string/camelCase.d.ts +14 -0
- package/dist/string/camelCase.d.ts.map +1 -0
- package/dist/string/camelCase.js +9 -0
- package/dist/string/camelCase.js.map +1 -0
- package/dist/string/endsWith.cjs +2 -0
- package/dist/string/endsWith.cjs.map +1 -0
- package/dist/string/endsWith.d.ts +5 -0
- package/dist/string/endsWith.d.ts.map +1 -0
- package/dist/string/endsWith.js +8 -0
- package/dist/string/endsWith.js.map +1 -0
- package/dist/string/escape.cjs +2 -0
- package/dist/string/escape.cjs.map +1 -0
- package/dist/string/escape.d.ts +5 -0
- package/dist/string/escape.d.ts.map +1 -0
- package/dist/string/escape.js +15 -0
- package/dist/string/escape.js.map +1 -0
- package/dist/string/index.d.ts +14 -0
- package/dist/string/index.d.ts.map +1 -0
- package/dist/string/kebabCase.cjs +2 -0
- package/dist/string/kebabCase.cjs.map +1 -0
- package/dist/string/kebabCase.d.ts +15 -0
- package/dist/string/kebabCase.d.ts.map +1 -0
- package/dist/string/kebabCase.js +9 -0
- package/dist/string/kebabCase.js.map +1 -0
- package/dist/string/pad.cjs +2 -0
- package/dist/string/pad.cjs.map +1 -0
- package/dist/string/pad.d.ts +5 -0
- package/dist/string/pad.d.ts.map +1 -0
- package/dist/string/pad.js +10 -0
- package/dist/string/pad.js.map +1 -0
- package/dist/string/pascalCase.cjs +2 -0
- package/dist/string/pascalCase.cjs.map +1 -0
- package/dist/string/pascalCase.d.ts +15 -0
- package/dist/string/pascalCase.d.ts.map +1 -0
- package/dist/string/pascalCase.js +9 -0
- package/dist/string/pascalCase.js.map +1 -0
- package/dist/string/similarity.cjs +2 -0
- package/dist/string/similarity.cjs.map +1 -0
- package/dist/string/similarity.d.ts +2 -0
- package/dist/string/similarity.d.ts.map +1 -0
- package/dist/string/similarity.js +24 -0
- package/dist/string/similarity.js.map +1 -0
- package/dist/string/snakeCase.cjs +2 -0
- package/dist/string/snakeCase.cjs.map +1 -0
- package/dist/string/snakeCase.d.ts +15 -0
- package/dist/string/snakeCase.d.ts.map +1 -0
- package/dist/string/snakeCase.js +9 -0
- package/dist/string/snakeCase.js.map +1 -0
- package/dist/string/startsWith.cjs +2 -0
- package/dist/string/startsWith.cjs.map +1 -0
- package/dist/string/startsWith.d.ts +5 -0
- package/dist/string/startsWith.d.ts.map +1 -0
- package/dist/string/startsWith.js +8 -0
- package/dist/string/startsWith.js.map +1 -0
- package/dist/string/titleCase.cjs +2 -0
- package/dist/string/titleCase.cjs.map +1 -0
- package/dist/string/titleCase.d.ts +5 -0
- package/dist/string/titleCase.d.ts.map +1 -0
- package/dist/string/titleCase.js +9 -0
- package/dist/string/titleCase.js.map +1 -0
- package/dist/string/truncate.cjs +2 -0
- package/dist/string/truncate.cjs.map +1 -0
- package/dist/string/truncate.d.ts +27 -0
- package/dist/string/truncate.d.ts.map +1 -0
- package/dist/string/truncate.js +17 -0
- package/dist/string/truncate.js.map +1 -0
- package/dist/string/unescape.cjs +2 -0
- package/dist/string/unescape.cjs.map +1 -0
- package/dist/string/unescape.d.ts +5 -0
- package/dist/string/unescape.d.ts.map +1 -0
- package/dist/string/unescape.js +15 -0
- package/dist/string/unescape.js.map +1 -0
- package/dist/string/words.cjs +2 -0
- package/dist/string/words.cjs.map +1 -0
- package/dist/string/words.d.ts +5 -0
- package/dist/string/words.d.ts.map +1 -0
- package/dist/string/words.js +10 -0
- package/dist/string/words.js.map +1 -0
- package/dist/types.d.ts +13 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +102 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../src/function/constant.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAE7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constant.js","names":[],"sources":["../../src/function/constant.ts"],"sourcesContent":["/**\n * Returns a function that always returns the same value.\n */\nexport function constant<T>(value: T): () => T {\n return () => value;\n}\n"],"mappings":";AAGA,SAAgB,EAAY,GAAmB;CAC7C,aAAa;AACf"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../_dev.cjs");function t(t,n=300,r={leading:!1,trailing:!0}){let i=r.leading??!1,a=r.trailing??!0;!i&&!a&&e.warn("debounce: both `leading` and `trailing` are false — the wrapped function will never be invoked.");let o,s,c,l=!1,u=()=>{o!==void 0&&(clearTimeout(o),o=void 0)},d=()=>{if(u(),l=!1,!s)return;let e=s;return s=void 0,c=t(...e),c};return Object.assign((...e)=>(s=e,i&&!l&&(l=!0,c=t(...e),s=void 0,!a)?(o=setTimeout(()=>{o=void 0,l=!1},n),c):i&&!a&&l?c:(u(),o=setTimeout(d,n),c)),{cancel:()=>{u(),s=void 0,l=!1},flush:()=>d(),pending:()=>o!==void 0})}exports.debounce=t;
|
|
2
|
+
//# sourceMappingURL=debounce.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.cjs","names":[],"sources":["../../src/function/debounce.ts"],"sourcesContent":["import type { Fn } from '../types';\n\nimport { warn } from '../_dev';\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":"+BAkCA,SAAgB,EACd,EACA,EAAQ,IACR,EAA2B,CAAE,QAAS,GAAO,SAAU,EAAK,EAC9C,CACd,IAAM,EAAU,EAAQ,SAAW,GAC7B,EAAW,EAAQ,UAAY,GAEjC,CAAC,GAAW,CAAC,GACf,EAAA,KAAK,iGAAiG,EAGxG,IAAI,EACA,EACA,EACA,EAAe,GAEb,MAAmB,CACnB,IAAY,IAAA,KACd,aAAa,CAAO,EACpB,EAAU,IAAA,GAEd,EAEM,MAAuB,CAI3B,GAHA,EAAW,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,EAAW,EACX,EAAU,WAAW,EAAgB,CAAK,EAEnC,IAET,CACE,WAAc,CACZ,EAAW,EACX,EAAW,IAAA,GACX,EAAe,EACjB,EACA,UAAwC,EAAe,EACvD,YAAe,IAAY,IAAA,EAC7B,CACF,CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Fn } from '../types';
|
|
2
|
+
export type DebounceOptions = {
|
|
3
|
+
/** Invoke on the leading edge of the delay window. Default: `false`. */
|
|
4
|
+
leading?: boolean;
|
|
5
|
+
/** Invoke on the trailing edge of the delay window. Default: `true`. */
|
|
6
|
+
trailing?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type Debounced<T extends Fn> = ((...args: Parameters<T>) => ReturnType<T> | undefined) & {
|
|
9
|
+
cancel(): void;
|
|
10
|
+
flush(): ReturnType<T> | undefined;
|
|
11
|
+
pending(): boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Debounces a function. By default only the trailing edge fires (after input settles).
|
|
15
|
+
* Pass `{ leading: true }` to fire immediately on the first call instead.
|
|
16
|
+
* Pass `{ leading: true, trailing: true }` to fire on both edges.
|
|
17
|
+
*
|
|
18
|
+
* Use `flush()` to invoke immediately, `cancel()` to clear, and `pending()` to check
|
|
19
|
+
* whether an invocation is scheduled.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* // Trailing (default) — fires after input settles
|
|
24
|
+
* const save = debounce(persist, 500);
|
|
25
|
+
*
|
|
26
|
+
* // Leading — fires on the first keystroke, then silences during the window
|
|
27
|
+
* const submit = debounce(sendRequest, 500, { leading: true, trailing: false });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function debounce<T extends Fn>(fn: T, delay?: number, options?: DebounceOptions): Debounced<T>;
|
|
31
|
+
//# sourceMappingURL=debounce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../src/function/debounce.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAInC,MAAM,MAAM,eAAe,GAAG;IAC5B,wEAAwE;IACxE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG;IAC9F,MAAM,IAAI,IAAI,CAAC;IACf,KAAK,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IACnC,OAAO,IAAI,OAAO,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,EAAE,EACnC,EAAE,EAAE,CAAC,EACL,KAAK,SAAM,EACX,OAAO,GAAE,eAAoD,GAC5D,SAAS,CAAC,CAAC,CAAC,CA2Ed"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { warn as e } from "../_dev.js";
|
|
2
|
+
//#region src/function/debounce.ts
|
|
3
|
+
function t(t, n = 300, r = {
|
|
4
|
+
leading: !1,
|
|
5
|
+
trailing: !0
|
|
6
|
+
}) {
|
|
7
|
+
let i = r.leading ?? !1, a = r.trailing ?? !0;
|
|
8
|
+
!i && !a && e("debounce: both `leading` and `trailing` are false — the wrapped function will never be invoked.");
|
|
9
|
+
let o, s, c, l = !1, u = () => {
|
|
10
|
+
o !== void 0 && (clearTimeout(o), o = void 0);
|
|
11
|
+
}, d = () => {
|
|
12
|
+
if (u(), l = !1, !s) return;
|
|
13
|
+
let e = s;
|
|
14
|
+
return s = void 0, c = t(...e), c;
|
|
15
|
+
};
|
|
16
|
+
return Object.assign((...e) => (s = e, i && !l && (l = !0, c = t(...e), s = void 0, !a) ? (o = setTimeout(() => {
|
|
17
|
+
o = void 0, l = !1;
|
|
18
|
+
}, n), c) : i && !a && l ? c : (u(), o = setTimeout(d, n), c)), {
|
|
19
|
+
cancel: () => {
|
|
20
|
+
u(), s = void 0, l = !1;
|
|
21
|
+
},
|
|
22
|
+
flush: () => d(),
|
|
23
|
+
pending: () => o !== void 0
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { t as debounce };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=debounce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounce.js","names":[],"sources":["../../src/function/debounce.ts"],"sourcesContent":["import type { Fn } from '../types';\n\nimport { warn } from '../_dev';\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":";;AAkCA,SAAgB,EACd,GACA,IAAQ,KACR,IAA2B;CAAE,SAAS;CAAO,UAAU;AAAK,GAC9C;CACd,IAAM,IAAU,EAAQ,WAAW,IAC7B,IAAW,EAAQ,YAAY;CAErC,AAAI,CAAC,KAAW,CAAC,KACf,EAAK,iGAAiG;CAGxG,IAAI,GACA,GACA,GACA,IAAe,IAEb,UAAmB;EACvB,AAAI,MAAY,KAAA,MACd,aAAa,CAAO,GACpB,IAAU,KAAA;CAEd,GAEM,UAAuB;EAI3B,IAHA,EAAW,GACX,IAAe,IAEX,CAAC,GAAU;EAEf,IAAM,IAAO;EAKb,OAHA,IAAW,KAAA,GACX,IAAa,EAAG,GAAG,CAAI,GAEhB;CACT;CAEA,OAAO,OAAO,QACX,GAAG,OACF,IAAW,GAEP,KAAW,CAAC,MACd,IAAe,IACf,IAAa,EAAG,GAAG,CAAI,GAIvB,IAAW,KAAA,GAEP,CAAC,MAEH,IAAU,iBAAiB;EAEzB,AADA,IAAU,KAAA,GACV,IAAe;CACjB,GAAG,CAAK,GAED,KAKP,KAAW,CAAC,KAAY,IAAqB,KAEjD,EAAW,GACX,IAAU,WAAW,GAAgB,CAAK,GAEnC,KAET;EACE,cAAc;GAGZ,AAFA,EAAW,GACX,IAAW,KAAA,GACX,IAAe;EACjB;EACA,aAAwC,EAAe;EACvD,eAAe,MAAY,KAAA;CAC7B,CACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.cjs","names":[],"sources":["../../src/function/identity.ts"],"sourcesContent":["/**\n * Returns the same input value.\n */\nexport function identity<T>(value: T): T {\n return value;\n}\n"],"mappings":"AAGA,SAAgB,EAAY,EAAa,CACvC,OAAO,CACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/function/identity.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","names":[],"sources":["../../src/function/identity.ts"],"sourcesContent":["/**\n * Returns the same input value.\n */\nexport function identity<T>(value: T): T {\n return value;\n}\n"],"mappings":";AAGA,SAAgB,EAAY,GAAa;CACvC,OAAO;AACT"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './assert';
|
|
2
|
+
export * from './constant';
|
|
3
|
+
export * from './debounce';
|
|
4
|
+
export * from './identity';
|
|
5
|
+
export * from './once';
|
|
6
|
+
export * from './pipe';
|
|
7
|
+
export * from './runAll';
|
|
8
|
+
export * from './tap';
|
|
9
|
+
export * from './throttle';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +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,EAAsB,GAAmB,CACpD,IAAI,EACA,EAAS,GAEP,IAAc,GAAG,KACrB,AAEE,KADA,EAAS,EAAG,GAAG,CAAI,EACV,IAGJ,IAQT,MALA,GAAU,UAAc,CACtB,EAAS,IAAA,GACT,EAAS,EACX,EAEO,CACT"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Fn } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* A wrapped function that executes `fn` at most once and exposes a `.reset()` method
|
|
4
|
+
* to allow re-invocation.
|
|
5
|
+
*/
|
|
6
|
+
export type Once<T extends Fn> = T & {
|
|
7
|
+
reset: () => void;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Create a function that runs once and returns the first result.
|
|
11
|
+
*
|
|
12
|
+
* If the first call throws, it does not count as "called" — the thrown error propagates to
|
|
13
|
+
* that caller, and the next call will invoke `fn` again (rather than caching the failure).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const onceRandom = once(() => Math.random())
|
|
18
|
+
* onceRandom() // 0.3
|
|
19
|
+
* onceRandom() // 0.3
|
|
20
|
+
*
|
|
21
|
+
* onceRandom.reset() // clears the cached result — allows one more invocation
|
|
22
|
+
*
|
|
23
|
+
* onceRandom() // 0.2
|
|
24
|
+
* onceRandom() // 0.2
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @param fn - The function to wrap.
|
|
28
|
+
*
|
|
29
|
+
* @returns A `Once<T>` — the wrapped function with a `.reset()` method to clear the cached result.
|
|
30
|
+
*/
|
|
31
|
+
export declare const once: <T extends Fn>(fn: T) => Once<T>;
|
|
32
|
+
//# sourceMappingURL=once.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"once.d.ts","sourceRoot":"","sources":["../../src/function/once.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAEnC;;;GAGG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG;IAAE,KAAK,EAAE,MAAM,IAAI,CAAA;CAAE,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,KAAG,IAAI,CAAC,CAAC,CAmBhD,CAAC"}
|
|
@@ -0,0 +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":";AA8BA,IAAa,KAAsB,MAAmB;CACpD,IAAI,GACA,IAAS,IAEP,MAAc,GAAG,OACrB,AAEE,OADA,IAAS,EAAG,GAAG,CAAI,GACV,KAGJ;CAQT,OALA,EAAU,cAAc;EAEtB,AADA,IAAS,KAAA,GACT,IAAS;CACX,GAEO;AACT"}
|
|
@@ -0,0 +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: unknown[]) => restFns.reduce((prev: unknown, fn) => fn(prev), firstFn!(...args));\n}\n"],"mappings":"AAoCA,SAAgB,EAAK,GAAG,EAAe,CACrC,GAAI,EAAI,SAAW,EAAG,MAAW,IAAY,EAE7C,GAAM,CAAC,EAAS,GAAG,GAAW,EAE9B,OAAQ,GAAG,IAAoB,EAAQ,QAAQ,EAAe,IAAO,EAAG,CAAI,EAAG,EAAS,GAAG,CAAI,CAAC,CAClG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Fn } from '../types';
|
|
2
|
+
type FirstParameters<T extends readonly Fn[]> = T extends [infer First extends Fn, ...unknown[]] ? Parameters<First> : never;
|
|
3
|
+
type LastReturnType<T extends readonly Fn[]> = T extends [...unknown[], infer Last extends Fn] ? ReturnType<Last> : never;
|
|
4
|
+
/**
|
|
5
|
+
* Pipes multiple functions into a single function. It starts from the leftmost function and proceeds to the right.
|
|
6
|
+
*
|
|
7
|
+
* The TypeScript overload captures the input type from the first function and the output type from the last.
|
|
8
|
+
* Intermediate steps are typed as `unknown` at the call site — TypeScript cannot infer a safe chain across
|
|
9
|
+
* heterogeneous function signatures without explicit overloads for every arity.
|
|
10
|
+
*
|
|
11
|
+
* `pipe()` with no arguments returns an identity function `<T>(x: T) => T`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const add = (x: number) => x + 2;
|
|
16
|
+
* const multiply = (x: number) => x * 3;
|
|
17
|
+
* const subtract = (x: number) => x - 4;
|
|
18
|
+
* const pipedFn = pipe(subtract, multiply, add);
|
|
19
|
+
*
|
|
20
|
+
* pipedFn(5); // ((5-4) * 3) + 2 = 5
|
|
21
|
+
*
|
|
22
|
+
* // Zero-arg identity
|
|
23
|
+
* pipe()(42); // 42
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @param fns - List of functions to be piped.
|
|
27
|
+
* @returns A new function that is the pipe of the input functions.
|
|
28
|
+
*/
|
|
29
|
+
export declare function pipe(): <T>(x: T) => T;
|
|
30
|
+
export declare function pipe<T extends readonly [Fn, ...Fn[]]>(...fns: T): (...args: FirstParameters<T>) => LastReturnType<T>;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=pipe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe.d.ts","sourceRoot":"","sources":["../../src/function/pipe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAEnC,KAAK,eAAe,CAAC,CAAC,SAAS,SAAS,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,SAAS,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,GAC5F,UAAU,CAAC,KAAK,CAAC,GACjB,KAAK,CAAC;AACV,KAAK,cAAc,CAAC,CAAC,SAAS,SAAS,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,OAAO,EAAE,EAAE,MAAM,IAAI,SAAS,EAAE,CAAC,GAC1F,UAAU,CAAC,IAAI,CAAC,GAChB,KAAK,CAAC;AAEV;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AACvC,wBAAgB,IAAI,CAAC,CAAC,SAAS,SAAS,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,cAAc,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +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: unknown[]) => restFns.reduce((prev: unknown, fn) => fn(prev), firstFn!(...args));\n}\n"],"mappings":";AAoCA,SAAgB,EAAK,GAAG,GAAe;CACrC,IAAI,EAAI,WAAW,GAAG,QAAW,MAAY;CAE7C,IAAM,CAAC,GAAS,GAAG,KAAW;CAE9B,QAAQ,GAAG,MAAoB,EAAQ,QAAQ,GAAe,MAAO,EAAG,CAAI,GAAG,EAAS,GAAG,CAAI,CAAC;AAClG"}
|
|
@@ -0,0 +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,EAAO,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,CAAE,CACV,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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs all functions in `fns`, collecting any thrown errors.
|
|
3
|
+
* - With `reverse: true`, iterates in LIFO order (useful for cleanup/teardown stacks).
|
|
4
|
+
* - Throws an `AggregateError` containing all failures if any function throws.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const cleanups = [() => a.dispose(), () => b.dispose()];
|
|
9
|
+
* runAll(cleanups, { reverse: true });
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function runAll(fns: readonly (() => void)[], opts?: {
|
|
13
|
+
reverse?: boolean;
|
|
14
|
+
}): void;
|
|
15
|
+
//# sourceMappingURL=runAll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runAll.d.ts","sourceRoot":"","sources":["../../src/function/runAll.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAyBvF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/function/runAll.ts
|
|
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
|
+
|
|
19
|
+
//# sourceMappingURL=runAll.js.map
|
|
@@ -0,0 +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":";AAWA,SAAgB,EAAO,GAA8B,GAAoC;CACvF,IAAM,IAAoB,CAAC,GACrB,IAAM,EAAI;CAEhB,IAAI,GAAM,SACR,KAAK,IAAI,IAAI,IAAM,GAAG,KAAK,GAAG,KAC5B,IAAI;EACF,EAAI,EAAE,CAAE;CACV,SAAS,GAAK;EACZ,EAAO,KAAK,CAAG;CACjB;MAGF,KAAK,IAAM,KAAM,GACf,IAAI;EACF,EAAG;CACL,SAAS,GAAK;EACZ,EAAO,KAAK,CAAG;CACjB;CAIJ,IAAI,EAAO,SAAS,GAClB,MAAU,eAAe,GAAQ,8BAA8B;AAEnE"}
|
|
@@ -0,0 +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,EAAO,EAAU,EAAiC,CAGhE,OAFA,EAAS,CAAK,EAEP,CACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tap.d.ts","sourceRoot":"","sources":["../../src/function/tap.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,CAAC,CAIhE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tap.js","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,EAAO,GAAU,GAAiC;CAGhE,OAFA,EAAS,CAAK,GAEP;AACT"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e,t=700,n={leading:!0,trailing:!1}){let r=n.leading??!0,i=n.trailing??!1,a,o=-1/0,s,c,l=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},u=e=>{a=setTimeout(p,e)},d=t=>{if(o=t,l(),!s)return;let n=s;return s=void 0,c=e(...n),c},f=e=>t-(e-o),p=()=>{let e=Date.now();s&&f(e)<=0?d(e):s?u(f(e)):l()};return Object.assign((...e)=>{let t=Date.now();o===-1/0&&!r&&(o=t),s=e;let n=f(t);return n<=0?d(t):(i&&!a&&u(n),c)},{cancel:()=>{l(),s=void 0,o=-1/0},flush:()=>{if(s)return d(Date.now())},pending:()=>s!==void 0||a!==void 0})}exports.throttle=e;
|
|
2
|
+
//# sourceMappingURL=throttle.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throttle.cjs","names":[],"sources":["../../src/function/throttle.ts"],"sourcesContent":["import type { Fn } from '../types';\n\nexport type ThrottleOptions = {\n leading?: boolean; // invoke at the start of the window\n trailing?: boolean; // invoke at the end with the last args\n};\n\nexport type Throttled<T extends Fn> = ((...args: Parameters<T>) => ReturnType<T> | undefined) & {\n cancel(): void;\n flush(): ReturnType<T> | undefined;\n pending(): boolean; // whether there's a pending call that flush() would execute\n};\n\n/**\n * Throttles a function. By default, only the leading edge fires.\n * Pass `{ trailing: true }` to also invoke at the end of the throttle window.\n *\n * @example\n * ```ts\n * const fn = () => { ... };\n * const t = throttle(fn, 700);\n * const withTrailing = throttle(fn, 700, { trailing: true });\n * ```\n */\nexport function throttle<T extends Fn>(\n fn: T,\n delay = 700,\n options: ThrottleOptions = { leading: true, trailing: false },\n): Throttled<T> {\n const leading = options.leading ?? true;\n const trailing = options.trailing ?? false;\n\n let timerId: ReturnType<typeof setTimeout> | undefined;\n let lastInvokeTime = -Infinity;\n let lastArgs: Parameters<T> | undefined;\n let lastResult: ReturnType<T> | undefined;\n\n const clearTimer = () => {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n timerId = undefined;\n }\n };\n\n const scheduleTimer = (delayMs: number) => {\n timerId = setTimeout(timerExpired, delayMs);\n };\n\n const invoke = (now: number) => {\n lastInvokeTime = now;\n clearTimer();\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 const remaining = (now: number) => delay - (now - lastInvokeTime);\n\n const timerExpired = () => {\n const now = Date.now();\n\n if (lastArgs && remaining(now) <= 0) {\n // trailing edge invoke\n invoke(now);\n } else if (lastArgs) {\n // reschedule until a window elapses\n scheduleTimer(remaining(now));\n } else {\n clearTimer();\n }\n };\n\n return Object.assign(\n (...args: Parameters<T>): ReturnType<T> | undefined => {\n const now = Date.now();\n\n if (lastInvokeTime === -Infinity && !leading) {\n // If leading is false, start the window now but don't invoke immediately\n lastInvokeTime = now;\n }\n\n lastArgs = args;\n\n const rem = remaining(now);\n\n if (rem <= 0) {\n // Window elapsed: invoke now\n return invoke(now);\n } else if (trailing && !timerId) {\n // Schedule trailing call if not already scheduled\n scheduleTimer(rem);\n }\n\n return lastResult;\n },\n {\n cancel: () => {\n clearTimer();\n lastArgs = undefined;\n lastInvokeTime = -Infinity;\n },\n flush: (): ReturnType<T> | undefined => {\n if (!lastArgs) return undefined;\n\n return invoke(Date.now());\n },\n // Pending if a trailing call is scheduled OR there are queued args.\n pending: () => lastArgs !== undefined || timerId !== undefined,\n },\n );\n}\n"],"mappings":"AAwBA,SAAgB,EACd,EACA,EAAQ,IACR,EAA2B,CAAE,QAAS,GAAM,SAAU,EAAM,EAC9C,CACd,IAAM,EAAU,EAAQ,SAAW,GAC7B,EAAW,EAAQ,UAAY,GAEjC,EACA,EAAiB,KACjB,EACA,EAEE,MAAmB,CACnB,IAAY,IAAA,KACd,aAAa,CAAO,EACpB,EAAU,IAAA,GAEd,EAEM,EAAiB,GAAoB,CACzC,EAAU,WAAW,EAAc,CAAO,CAC5C,EAEM,EAAU,GAAgB,CAI9B,GAHA,EAAiB,EACjB,EAAW,EAEP,CAAC,EAAU,OAEf,IAAM,EAAO,EAKb,MAHA,GAAW,IAAA,GACX,EAAa,EAAG,GAAG,CAAI,EAEhB,CACT,EAEM,EAAa,GAAgB,GAAS,EAAM,GAE5C,MAAqB,CACzB,IAAM,EAAM,KAAK,IAAI,EAEjB,GAAY,EAAU,CAAG,GAAK,EAEhC,EAAO,CAAG,EACD,EAET,EAAc,EAAU,CAAG,CAAC,EAE5B,EAAW,CAEf,EAEA,OAAO,OAAO,QACX,GAAG,IAAmD,CACrD,IAAM,EAAM,KAAK,IAAI,EAEjB,IAAmB,MAAa,CAAC,IAEnC,EAAiB,GAGnB,EAAW,EAEX,IAAM,EAAM,EAAU,CAAG,EAUzB,OARI,GAAO,EAEF,EAAO,CAAG,GACR,GAAY,CAAC,GAEtB,EAAc,CAAG,EAGZ,EACT,EACA,CACE,WAAc,CACZ,EAAW,EACX,EAAW,IAAA,GACX,EAAiB,IACnB,EACA,UAAwC,CACjC,KAEL,OAAO,EAAO,KAAK,IAAI,CAAC,CAC1B,EAEA,YAAe,IAAa,IAAA,IAAa,IAAY,IAAA,EACvD,CACF,CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Fn } from '../types';
|
|
2
|
+
export type ThrottleOptions = {
|
|
3
|
+
leading?: boolean;
|
|
4
|
+
trailing?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type Throttled<T extends Fn> = ((...args: Parameters<T>) => ReturnType<T> | undefined) & {
|
|
7
|
+
cancel(): void;
|
|
8
|
+
flush(): ReturnType<T> | undefined;
|
|
9
|
+
pending(): boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Throttles a function. By default, only the leading edge fires.
|
|
13
|
+
* Pass `{ trailing: true }` to also invoke at the end of the throttle window.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const fn = () => { ... };
|
|
18
|
+
* const t = throttle(fn, 700);
|
|
19
|
+
* const withTrailing = throttle(fn, 700, { trailing: true });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function throttle<T extends Fn>(fn: T, delay?: number, options?: ThrottleOptions): Throttled<T>;
|
|
23
|
+
//# sourceMappingURL=throttle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../../src/function/throttle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAEnC,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG;IAC9F,MAAM,IAAI,IAAI,CAAC;IACf,KAAK,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IACnC,OAAO,IAAI,OAAO,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,EAAE,EACnC,EAAE,EAAE,CAAC,EACL,KAAK,SAAM,EACX,OAAO,GAAE,eAAoD,GAC5D,SAAS,CAAC,CAAC,CAAC,CAwFd"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region src/function/throttle.ts
|
|
2
|
+
function e(e, t = 700, n = {
|
|
3
|
+
leading: !0,
|
|
4
|
+
trailing: !1
|
|
5
|
+
}) {
|
|
6
|
+
let r = n.leading ?? !0, i = n.trailing ?? !1, a, o = -Infinity, s, c, l = () => {
|
|
7
|
+
a !== void 0 && (clearTimeout(a), a = void 0);
|
|
8
|
+
}, u = (e) => {
|
|
9
|
+
a = setTimeout(p, e);
|
|
10
|
+
}, d = (t) => {
|
|
11
|
+
if (o = t, l(), !s) return;
|
|
12
|
+
let n = s;
|
|
13
|
+
return s = void 0, c = e(...n), c;
|
|
14
|
+
}, f = (e) => t - (e - o), p = () => {
|
|
15
|
+
let e = Date.now();
|
|
16
|
+
s && f(e) <= 0 ? d(e) : s ? u(f(e)) : l();
|
|
17
|
+
};
|
|
18
|
+
return Object.assign((...e) => {
|
|
19
|
+
let t = Date.now();
|
|
20
|
+
o === -Infinity && !r && (o = t), s = e;
|
|
21
|
+
let n = f(t);
|
|
22
|
+
return n <= 0 ? d(t) : (i && !a && u(n), c);
|
|
23
|
+
}, {
|
|
24
|
+
cancel: () => {
|
|
25
|
+
l(), s = void 0, o = -Infinity;
|
|
26
|
+
},
|
|
27
|
+
flush: () => {
|
|
28
|
+
if (s) return d(Date.now());
|
|
29
|
+
},
|
|
30
|
+
pending: () => s !== void 0 || a !== void 0
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { e as throttle };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=throttle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"throttle.js","names":[],"sources":["../../src/function/throttle.ts"],"sourcesContent":["import type { Fn } from '../types';\n\nexport type ThrottleOptions = {\n leading?: boolean; // invoke at the start of the window\n trailing?: boolean; // invoke at the end with the last args\n};\n\nexport type Throttled<T extends Fn> = ((...args: Parameters<T>) => ReturnType<T> | undefined) & {\n cancel(): void;\n flush(): ReturnType<T> | undefined;\n pending(): boolean; // whether there's a pending call that flush() would execute\n};\n\n/**\n * Throttles a function. By default, only the leading edge fires.\n * Pass `{ trailing: true }` to also invoke at the end of the throttle window.\n *\n * @example\n * ```ts\n * const fn = () => { ... };\n * const t = throttle(fn, 700);\n * const withTrailing = throttle(fn, 700, { trailing: true });\n * ```\n */\nexport function throttle<T extends Fn>(\n fn: T,\n delay = 700,\n options: ThrottleOptions = { leading: true, trailing: false },\n): Throttled<T> {\n const leading = options.leading ?? true;\n const trailing = options.trailing ?? false;\n\n let timerId: ReturnType<typeof setTimeout> | undefined;\n let lastInvokeTime = -Infinity;\n let lastArgs: Parameters<T> | undefined;\n let lastResult: ReturnType<T> | undefined;\n\n const clearTimer = () => {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n timerId = undefined;\n }\n };\n\n const scheduleTimer = (delayMs: number) => {\n timerId = setTimeout(timerExpired, delayMs);\n };\n\n const invoke = (now: number) => {\n lastInvokeTime = now;\n clearTimer();\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 const remaining = (now: number) => delay - (now - lastInvokeTime);\n\n const timerExpired = () => {\n const now = Date.now();\n\n if (lastArgs && remaining(now) <= 0) {\n // trailing edge invoke\n invoke(now);\n } else if (lastArgs) {\n // reschedule until a window elapses\n scheduleTimer(remaining(now));\n } else {\n clearTimer();\n }\n };\n\n return Object.assign(\n (...args: Parameters<T>): ReturnType<T> | undefined => {\n const now = Date.now();\n\n if (lastInvokeTime === -Infinity && !leading) {\n // If leading is false, start the window now but don't invoke immediately\n lastInvokeTime = now;\n }\n\n lastArgs = args;\n\n const rem = remaining(now);\n\n if (rem <= 0) {\n // Window elapsed: invoke now\n return invoke(now);\n } else if (trailing && !timerId) {\n // Schedule trailing call if not already scheduled\n scheduleTimer(rem);\n }\n\n return lastResult;\n },\n {\n cancel: () => {\n clearTimer();\n lastArgs = undefined;\n lastInvokeTime = -Infinity;\n },\n flush: (): ReturnType<T> | undefined => {\n if (!lastArgs) return undefined;\n\n return invoke(Date.now());\n },\n // Pending if a trailing call is scheduled OR there are queued args.\n pending: () => lastArgs !== undefined || timerId !== undefined,\n },\n );\n}\n"],"mappings":";AAwBA,SAAgB,EACd,GACA,IAAQ,KACR,IAA2B;CAAE,SAAS;CAAM,UAAU;AAAM,GAC9C;CACd,IAAM,IAAU,EAAQ,WAAW,IAC7B,IAAW,EAAQ,YAAY,IAEjC,GACA,IAAiB,WACjB,GACA,GAEE,UAAmB;EACvB,AAAI,MAAY,KAAA,MACd,aAAa,CAAO,GACpB,IAAU,KAAA;CAEd,GAEM,KAAiB,MAAoB;EACzC,IAAU,WAAW,GAAc,CAAO;CAC5C,GAEM,KAAU,MAAgB;EAI9B,IAHA,IAAiB,GACjB,EAAW,GAEP,CAAC,GAAU;EAEf,IAAM,IAAO;EAKb,OAHA,IAAW,KAAA,GACX,IAAa,EAAG,GAAG,CAAI,GAEhB;CACT,GAEM,KAAa,MAAgB,KAAS,IAAM,IAE5C,UAAqB;EACzB,IAAM,IAAM,KAAK,IAAI;EAErB,AAAI,KAAY,EAAU,CAAG,KAAK,IAEhC,EAAO,CAAG,IACD,IAET,EAAc,EAAU,CAAG,CAAC,IAE5B,EAAW;CAEf;CAEA,OAAO,OAAO,QACX,GAAG,MAAmD;EACrD,IAAM,IAAM,KAAK,IAAI;EAOrB,AALI,MAAmB,aAAa,CAAC,MAEnC,IAAiB,IAGnB,IAAW;EAEX,IAAM,IAAM,EAAU,CAAG;EAUzB,OARI,KAAO,IAEF,EAAO,CAAG,KACR,KAAY,CAAC,KAEtB,EAAc,CAAG,GAGZ;CACT,GACA;EACE,cAAc;GAGZ,AAFA,EAAW,GACX,IAAW,KAAA,GACX,IAAiB;EACnB;EACA,aAAwC;GACjC,OAEL,OAAO,EAAO,KAAK,IAAI,CAAC;EAC1B;EAEA,eAAe,MAAa,KAAA,KAAa,MAAY,KAAA;CACvD,CACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combinators.cjs","names":[],"sources":["../../src/guards/combinators.ts"],"sourcesContent":["import type { Predicate } from '../types';\n\n/**\n * Returns a predicate that is `true` only when every provided predicate is `true`.\n *\n * With zero predicates, returns `true` for all values (vacuous truth).\n *\n * @example\n * ```ts\n * const isPositiveEven = allOf(\n * (n) => n > 0,\n * (n) => n % 2 === 0,\n * );\n * [1, 2, 3, 4].filter(isPositiveEven); // [2, 4]\n * ```\n */\nexport function allOf<T>(...predicates: Predicate<T>[]): Predicate<T> {\n return (value) => predicates.every((predicate) => predicate(value));\n}\n\n/**\n * Returns a predicate that is `true` when at least one provided predicate is `true`.\n *\n * With zero predicates, returns `false` for all values (vacuous falsity).\n *\n * @example\n * ```ts\n * [1, 2, 3, 4].filter(anyOf((n) => n === 1, (n) => n === 3)); // [1, 3]\n * ```\n */\nexport function anyOf<T>(...predicates: Predicate<T>[]): Predicate<T> {\n return (value) => predicates.some((predicate) => predicate(value));\n}\n\n/**\n * Returns a predicate that is `true` when none of the provided predicates match.\n * With a single predicate this is equivalent to logical NOT.\n *\n * With zero predicates, returns `true` for all values (nothing fails — vacuous truth).\n *\n * @example\n * ```ts\n * [1, 2, 3, 4].filter(noneOf((n) => n % 2 === 0)); // [1, 3]\n * ```\n */\nexport function noneOf<T>(...predicates: Predicate<T>[]): Predicate<T> {\n return (value) => predicates.every((predicate) => !predicate(value));\n}\n\n/**\n * Returns a predicate that negates the given predicate.\n *\n * @example\n * ```ts\n * [1, 2, 3, 4].filter(not((n) => n % 2 === 0)); // [1, 3]\n * ```\n */\nexport function not<T>(predicate: Predicate<T>): Predicate<T> {\n return (value) => !predicate(value);\n}\n"],"mappings":"AAgBA,SAAgB,EAAS,GAAG,EAA0C,CACpE,MAAQ,IAAU,EAAW,MAAO,GAAc,EAAU,CAAK,CAAC,CACpE,CAYA,SAAgB,EAAS,GAAG,EAA0C,CACpE,MAAQ,IAAU,EAAW,KAAM,GAAc,EAAU,CAAK,CAAC,CACnE,CAaA,SAAgB,EAAU,GAAG,EAA0C,CACrE,MAAQ,IAAU,EAAW,MAAO,GAAc,CAAC,EAAU,CAAK,CAAC,CACrE,CAUA,SAAgB,EAAO,EAAuC,CAC5D,MAAQ,IAAU,CAAC,EAAU,CAAK,CACpC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Predicate } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a predicate that is `true` only when every provided predicate is `true`.
|
|
4
|
+
*
|
|
5
|
+
* With zero predicates, returns `true` for all values (vacuous truth).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const isPositiveEven = allOf(
|
|
10
|
+
* (n) => n > 0,
|
|
11
|
+
* (n) => n % 2 === 0,
|
|
12
|
+
* );
|
|
13
|
+
* [1, 2, 3, 4].filter(isPositiveEven); // [2, 4]
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function allOf<T>(...predicates: Predicate<T>[]): Predicate<T>;
|
|
17
|
+
/**
|
|
18
|
+
* Returns a predicate that is `true` when at least one provided predicate is `true`.
|
|
19
|
+
*
|
|
20
|
+
* With zero predicates, returns `false` for all values (vacuous falsity).
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* [1, 2, 3, 4].filter(anyOf((n) => n === 1, (n) => n === 3)); // [1, 3]
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function anyOf<T>(...predicates: Predicate<T>[]): Predicate<T>;
|
|
28
|
+
/**
|
|
29
|
+
* Returns a predicate that is `true` when none of the provided predicates match.
|
|
30
|
+
* With a single predicate this is equivalent to logical NOT.
|
|
31
|
+
*
|
|
32
|
+
* With zero predicates, returns `true` for all values (nothing fails — vacuous truth).
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* [1, 2, 3, 4].filter(noneOf((n) => n % 2 === 0)); // [1, 3]
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function noneOf<T>(...predicates: Predicate<T>[]): Predicate<T>;
|
|
40
|
+
/**
|
|
41
|
+
* Returns a predicate that negates the given predicate.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* [1, 2, 3, 4].filter(not((n) => n % 2 === 0)); // [1, 3]
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function not<T>(predicate: Predicate<T>): Predicate<T>;
|
|
49
|
+
//# sourceMappingURL=combinators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combinators.d.ts","sourceRoot":"","sources":["../../src/guards/combinators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAEpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAEpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAErE;AAED;;;;;;;GAOG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAE5D"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/guards/combinators.ts
|
|
2
|
+
function e(...e) {
|
|
3
|
+
return (t) => e.every((e) => e(t));
|
|
4
|
+
}
|
|
5
|
+
function t(...e) {
|
|
6
|
+
return (t) => e.some((e) => e(t));
|
|
7
|
+
}
|
|
8
|
+
function n(...e) {
|
|
9
|
+
return (t) => e.every((e) => !e(t));
|
|
10
|
+
}
|
|
11
|
+
function r(e) {
|
|
12
|
+
return (t) => !e(t);
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { e as allOf, t as anyOf, n as noneOf, r as not };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=combinators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combinators.js","names":[],"sources":["../../src/guards/combinators.ts"],"sourcesContent":["import type { Predicate } from '../types';\n\n/**\n * Returns a predicate that is `true` only when every provided predicate is `true`.\n *\n * With zero predicates, returns `true` for all values (vacuous truth).\n *\n * @example\n * ```ts\n * const isPositiveEven = allOf(\n * (n) => n > 0,\n * (n) => n % 2 === 0,\n * );\n * [1, 2, 3, 4].filter(isPositiveEven); // [2, 4]\n * ```\n */\nexport function allOf<T>(...predicates: Predicate<T>[]): Predicate<T> {\n return (value) => predicates.every((predicate) => predicate(value));\n}\n\n/**\n * Returns a predicate that is `true` when at least one provided predicate is `true`.\n *\n * With zero predicates, returns `false` for all values (vacuous falsity).\n *\n * @example\n * ```ts\n * [1, 2, 3, 4].filter(anyOf((n) => n === 1, (n) => n === 3)); // [1, 3]\n * ```\n */\nexport function anyOf<T>(...predicates: Predicate<T>[]): Predicate<T> {\n return (value) => predicates.some((predicate) => predicate(value));\n}\n\n/**\n * Returns a predicate that is `true` when none of the provided predicates match.\n * With a single predicate this is equivalent to logical NOT.\n *\n * With zero predicates, returns `true` for all values (nothing fails — vacuous truth).\n *\n * @example\n * ```ts\n * [1, 2, 3, 4].filter(noneOf((n) => n % 2 === 0)); // [1, 3]\n * ```\n */\nexport function noneOf<T>(...predicates: Predicate<T>[]): Predicate<T> {\n return (value) => predicates.every((predicate) => !predicate(value));\n}\n\n/**\n * Returns a predicate that negates the given predicate.\n *\n * @example\n * ```ts\n * [1, 2, 3, 4].filter(not((n) => n % 2 === 0)); // [1, 3]\n * ```\n */\nexport function not<T>(predicate: Predicate<T>): Predicate<T> {\n return (value) => !predicate(value);\n}\n"],"mappings":";AAgBA,SAAgB,EAAS,GAAG,GAA0C;CACpE,QAAQ,MAAU,EAAW,OAAO,MAAc,EAAU,CAAK,CAAC;AACpE;AAYA,SAAgB,EAAS,GAAG,GAA0C;CACpE,QAAQ,MAAU,EAAW,MAAM,MAAc,EAAU,CAAK,CAAC;AACnE;AAaA,SAAgB,EAAU,GAAG,GAA0C;CACrE,QAAQ,MAAU,EAAW,OAAO,MAAc,CAAC,EAAU,CAAK,CAAC;AACrE;AAUA,SAAgB,EAAO,GAAuC;CAC5D,QAAQ,MAAU,CAAC,EAAU,CAAK;AACpC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from './combinators';
|
|
2
|
+
export * from './isAbortError';
|
|
3
|
+
export * from './isArray';
|
|
4
|
+
export * from './isBoolean';
|
|
5
|
+
export * from './isDate';
|
|
6
|
+
export * from './isDefined';
|
|
7
|
+
export * from './isEmpty';
|
|
8
|
+
export * from './isEqual';
|
|
9
|
+
export * from './isError';
|
|
10
|
+
export * from './isFunction';
|
|
11
|
+
export * from './isMatch';
|
|
12
|
+
export * from './isNil';
|
|
13
|
+
export * from './isNumber';
|
|
14
|
+
export * from './isPlainObject';
|
|
15
|
+
export * from './isPrimitive';
|
|
16
|
+
export * from './isPromise';
|
|
17
|
+
export * from './isRegex';
|
|
18
|
+
export * from './isString';
|
|
19
|
+
export * from './shallowEqual';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/guards/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
|