@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":"abs.cjs","names":[],"sources":["../../src/math/abs.ts"],"sourcesContent":["/**\n * Returns the absolute value of a number.\n * Supports both regular numbers and bigint.\n *\n * @example\n * ```ts\n * abs(-5); // 5\n * abs(3); // 3\n * abs(-100n); // 100n\n * ```\n *\n * @param value - The number or bigint to get absolute value of\n * @returns Absolute value\n */\nexport function abs(value: number): number;\nexport function abs(value: bigint): bigint;\nexport function abs(value: number | bigint): number | bigint {\n if (typeof value === 'bigint') {\n return value < 0n ? -value : value;\n }\n\n return Math.abs(value);\n}\n"],"mappings":"AAgBA,SAAgB,EAAI,EAAyC,CAK3D,OAJI,OAAO,GAAU,SACZ,EAAQ,GAAK,CAAC,EAAQ,EAGxB,KAAK,IAAI,CAAK,CACvB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the absolute value of a number.
|
|
3
|
+
* Supports both regular numbers and bigint.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* abs(-5); // 5
|
|
8
|
+
* abs(3); // 3
|
|
9
|
+
* abs(-100n); // 100n
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @param value - The number or bigint to get absolute value of
|
|
13
|
+
* @returns Absolute value
|
|
14
|
+
*/
|
|
15
|
+
export declare function abs(value: number): number;
|
|
16
|
+
export declare function abs(value: bigint): bigint;
|
|
17
|
+
//# sourceMappingURL=abs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abs.d.ts","sourceRoot":"","sources":["../../src/math/abs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;AAC3C,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC"}
|
package/dist/math/abs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abs.js","names":[],"sources":["../../src/math/abs.ts"],"sourcesContent":["/**\n * Returns the absolute value of a number.\n * Supports both regular numbers and bigint.\n *\n * @example\n * ```ts\n * abs(-5); // 5\n * abs(3); // 3\n * abs(-100n); // 100n\n * ```\n *\n * @param value - The number or bigint to get absolute value of\n * @returns Absolute value\n */\nexport function abs(value: number): number;\nexport function abs(value: bigint): bigint;\nexport function abs(value: number | bigint): number | bigint {\n if (typeof value === 'bigint') {\n return value < 0n ? -value : value;\n }\n\n return Math.abs(value);\n}\n"],"mappings":";AAgBA,SAAgB,EAAI,GAAyC;CAK3D,OAJI,OAAO,KAAU,WACZ,IAAQ,KAAK,CAAC,IAAQ,IAGxB,KAAK,IAAI,CAAK;AACvB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../errors.cjs");function t(t,n){if(typeof n==`number`&&(!Number.isInteger(n)||n<1))throw new e.ArsenalValidationError(`Parts must be a positive integer, got ${n}`);let r=Array.isArray(n)?n:Array(n).fill(1);if(r.length===0)throw new e.ArsenalValidationError(`Ratios array cannot be empty`);if(r.some(e=>e<0))throw new e.ArsenalValidationError(`Ratios must be non-negative`);let i=r.reduce((e,t)=>e+t,0);if(i===0)throw new e.ArsenalValidationError(`Total ratio cannot be zero`);if(typeof t==`bigint`){let e=BigInt(i),n=Array.from({length:r.length-1},(n,i)=>t*BigInt(r[i])/e);return n.push(t-n.reduce((e,t)=>e+t,0n)),n}let a=Array.from({length:r.length-1},(e,n)=>Math.floor(t*r[n]/i));return a.push(t-a.reduce((e,t)=>e+t,0)),a}exports.allocate=t;
|
|
2
|
+
//# sourceMappingURL=allocate.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allocate.cjs","names":[],"sources":["../../src/math/allocate.ts"],"sourcesContent":["import { ArsenalValidationError } from '../errors';\n\n/**\n * Distributes an amount proportionally according to given ratios.\n * Handles rounding to ensure the sum equals the original amount exactly.\n * The indivisible remainder is allocated to the last bucket.\n * Critical for financial operations like splitting payments to avoid rounding errors.\n *\n * @example\n * ```ts\n * // Split $100 in ratio 1:2:3 (total ratio = 6)\n * allocate(100, [1, 2, 3]);\n * // [16, 33, 51] - sum is exactly 100\n *\n * // Split $100 evenly among 3 parts\n * allocate(100, 3);\n * // [33, 33, 34] - sum is exactly 100\n *\n * // Split with bigint (e.g., cents)\n * allocate(10000n, [1, 1, 1]);\n * // [3333n, 3333n, 3334n] - sum is exactly 10000n\n * ```\n *\n * @param amount - Total amount to allocate\n * @param ratios - Array of ratios for distribution or number of equal parts\n * @returns Array of allocated amounts with remainder applied to last bucket (sum equals original amount)\n * @throws {ArsenalValidationError} If ratios array is empty, contains negative values, sums to zero, or parts is not a positive integer\n */\nexport function allocate(amount: number, ratios: number[] | number): number[];\nexport function allocate(amount: bigint, ratios: number[] | number): bigint[];\nexport function allocate(amount: number | bigint, ratios: number[] | number): (number | bigint)[] {\n // If second param is a number, validate and treat it as number of equal parts\n if (typeof ratios === 'number') {\n if (!Number.isInteger(ratios) || ratios < 1) {\n throw new ArsenalValidationError(`Parts must be a positive integer, got ${ratios}`);\n }\n }\n\n const actualRatios = Array.isArray(ratios) ? ratios : Array(ratios).fill(1);\n\n if (actualRatios.length === 0) {\n throw new ArsenalValidationError('Ratios array cannot be empty');\n }\n\n if (actualRatios.some((r) => r < 0)) {\n throw new ArsenalValidationError('Ratios must be non-negative');\n }\n\n const totalRatio = actualRatios.reduce((sum, ratio) => sum + ratio, 0);\n\n if (totalRatio === 0) {\n throw new ArsenalValidationError('Total ratio cannot be zero');\n }\n\n if (typeof amount === 'bigint') {\n const totalRatioBigInt = BigInt(totalRatio);\n const results = Array.from(\n { length: actualRatios.length - 1 },\n (_, i) => (amount * BigInt(actualRatios[i])) / totalRatioBigInt,\n );\n\n results.push(amount - results.reduce((s, v) => s + v, 0n));\n\n return results;\n }\n\n // For number type, use proportional allocation for all ratios uniformly\n const results = Array.from({ length: actualRatios.length - 1 }, (_, i) =>\n Math.floor((amount * actualRatios[i]) / totalRatio),\n );\n\n results.push(amount - results.reduce((s, v) => s + v, 0));\n\n return results;\n}\n"],"mappings":"iCA8BA,SAAgB,EAAS,EAAyB,EAAgD,CAEhG,GAAI,OAAO,GAAW,WAChB,CAAC,OAAO,UAAU,CAAM,GAAK,EAAS,GACxC,MAAM,IAAI,EAAA,uBAAuB,yCAAyC,GAAQ,EAItF,IAAM,EAAe,MAAM,QAAQ,CAAM,EAAI,EAAS,MAAM,CAAM,CAAC,CAAC,KAAK,CAAC,EAE1E,GAAI,EAAa,SAAW,EAC1B,MAAM,IAAI,EAAA,uBAAuB,8BAA8B,EAGjE,GAAI,EAAa,KAAM,GAAM,EAAI,CAAC,EAChC,MAAM,IAAI,EAAA,uBAAuB,6BAA6B,EAGhE,IAAM,EAAa,EAAa,QAAQ,EAAK,IAAU,EAAM,EAAO,CAAC,EAErE,GAAI,IAAe,EACjB,MAAM,IAAI,EAAA,uBAAuB,4BAA4B,EAG/D,GAAI,OAAO,GAAW,SAAU,CAC9B,IAAM,EAAmB,OAAO,CAAU,EACpC,EAAU,MAAM,KACpB,CAAE,OAAQ,EAAa,OAAS,CAAE,GACjC,EAAG,IAAO,EAAS,OAAO,EAAa,EAAE,EAAK,CACjD,EAIA,OAFA,EAAQ,KAAK,EAAS,EAAQ,QAAQ,EAAG,IAAM,EAAI,EAAG,EAAE,CAAC,EAElD,CACT,CAGA,IAAM,EAAU,MAAM,KAAK,CAAE,OAAQ,EAAa,OAAS,CAAE,GAAI,EAAG,IAClE,KAAK,MAAO,EAAS,EAAa,GAAM,CAAU,CACpD,EAIA,OAFA,EAAQ,KAAK,EAAS,EAAQ,QAAQ,EAAG,IAAM,EAAI,EAAG,CAAC,CAAC,EAEjD,CACT"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Distributes an amount proportionally according to given ratios.
|
|
3
|
+
* Handles rounding to ensure the sum equals the original amount exactly.
|
|
4
|
+
* The indivisible remainder is allocated to the last bucket.
|
|
5
|
+
* Critical for financial operations like splitting payments to avoid rounding errors.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* // Split $100 in ratio 1:2:3 (total ratio = 6)
|
|
10
|
+
* allocate(100, [1, 2, 3]);
|
|
11
|
+
* // [16, 33, 51] - sum is exactly 100
|
|
12
|
+
*
|
|
13
|
+
* // Split $100 evenly among 3 parts
|
|
14
|
+
* allocate(100, 3);
|
|
15
|
+
* // [33, 33, 34] - sum is exactly 100
|
|
16
|
+
*
|
|
17
|
+
* // Split with bigint (e.g., cents)
|
|
18
|
+
* allocate(10000n, [1, 1, 1]);
|
|
19
|
+
* // [3333n, 3333n, 3334n] - sum is exactly 10000n
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param amount - Total amount to allocate
|
|
23
|
+
* @param ratios - Array of ratios for distribution or number of equal parts
|
|
24
|
+
* @returns Array of allocated amounts with remainder applied to last bucket (sum equals original amount)
|
|
25
|
+
* @throws {ArsenalValidationError} If ratios array is empty, contains negative values, sums to zero, or parts is not a positive integer
|
|
26
|
+
*/
|
|
27
|
+
export declare function allocate(amount: number, ratios: number[] | number): number[];
|
|
28
|
+
export declare function allocate(amount: bigint, ratios: number[] | number): bigint[];
|
|
29
|
+
//# sourceMappingURL=allocate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allocate.d.ts","sourceRoot":"","sources":["../../src/math/allocate.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;AAC9E,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ArsenalValidationError as e } from "../errors.js";
|
|
2
|
+
//#region src/math/allocate.ts
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
if (typeof n == "number" && (!Number.isInteger(n) || n < 1)) throw new e(`Parts must be a positive integer, got ${n}`);
|
|
5
|
+
let r = Array.isArray(n) ? n : Array(n).fill(1);
|
|
6
|
+
if (r.length === 0) throw new e("Ratios array cannot be empty");
|
|
7
|
+
if (r.some((e) => e < 0)) throw new e("Ratios must be non-negative");
|
|
8
|
+
let i = r.reduce((e, t) => e + t, 0);
|
|
9
|
+
if (i === 0) throw new e("Total ratio cannot be zero");
|
|
10
|
+
if (typeof t == "bigint") {
|
|
11
|
+
let e = BigInt(i), n = Array.from({ length: r.length - 1 }, (n, i) => t * BigInt(r[i]) / e);
|
|
12
|
+
return n.push(t - n.reduce((e, t) => e + t, 0n)), n;
|
|
13
|
+
}
|
|
14
|
+
let a = Array.from({ length: r.length - 1 }, (e, n) => Math.floor(t * r[n] / i));
|
|
15
|
+
return a.push(t - a.reduce((e, t) => e + t, 0)), a;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { t as allocate };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=allocate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allocate.js","names":[],"sources":["../../src/math/allocate.ts"],"sourcesContent":["import { ArsenalValidationError } from '../errors';\n\n/**\n * Distributes an amount proportionally according to given ratios.\n * Handles rounding to ensure the sum equals the original amount exactly.\n * The indivisible remainder is allocated to the last bucket.\n * Critical for financial operations like splitting payments to avoid rounding errors.\n *\n * @example\n * ```ts\n * // Split $100 in ratio 1:2:3 (total ratio = 6)\n * allocate(100, [1, 2, 3]);\n * // [16, 33, 51] - sum is exactly 100\n *\n * // Split $100 evenly among 3 parts\n * allocate(100, 3);\n * // [33, 33, 34] - sum is exactly 100\n *\n * // Split with bigint (e.g., cents)\n * allocate(10000n, [1, 1, 1]);\n * // [3333n, 3333n, 3334n] - sum is exactly 10000n\n * ```\n *\n * @param amount - Total amount to allocate\n * @param ratios - Array of ratios for distribution or number of equal parts\n * @returns Array of allocated amounts with remainder applied to last bucket (sum equals original amount)\n * @throws {ArsenalValidationError} If ratios array is empty, contains negative values, sums to zero, or parts is not a positive integer\n */\nexport function allocate(amount: number, ratios: number[] | number): number[];\nexport function allocate(amount: bigint, ratios: number[] | number): bigint[];\nexport function allocate(amount: number | bigint, ratios: number[] | number): (number | bigint)[] {\n // If second param is a number, validate and treat it as number of equal parts\n if (typeof ratios === 'number') {\n if (!Number.isInteger(ratios) || ratios < 1) {\n throw new ArsenalValidationError(`Parts must be a positive integer, got ${ratios}`);\n }\n }\n\n const actualRatios = Array.isArray(ratios) ? ratios : Array(ratios).fill(1);\n\n if (actualRatios.length === 0) {\n throw new ArsenalValidationError('Ratios array cannot be empty');\n }\n\n if (actualRatios.some((r) => r < 0)) {\n throw new ArsenalValidationError('Ratios must be non-negative');\n }\n\n const totalRatio = actualRatios.reduce((sum, ratio) => sum + ratio, 0);\n\n if (totalRatio === 0) {\n throw new ArsenalValidationError('Total ratio cannot be zero');\n }\n\n if (typeof amount === 'bigint') {\n const totalRatioBigInt = BigInt(totalRatio);\n const results = Array.from(\n { length: actualRatios.length - 1 },\n (_, i) => (amount * BigInt(actualRatios[i])) / totalRatioBigInt,\n );\n\n results.push(amount - results.reduce((s, v) => s + v, 0n));\n\n return results;\n }\n\n // For number type, use proportional allocation for all ratios uniformly\n const results = Array.from({ length: actualRatios.length - 1 }, (_, i) =>\n Math.floor((amount * actualRatios[i]) / totalRatio),\n );\n\n results.push(amount - results.reduce((s, v) => s + v, 0));\n\n return results;\n}\n"],"mappings":";;AA8BA,SAAgB,EAAS,GAAyB,GAAgD;CAEhG,IAAI,OAAO,KAAW,aAChB,CAAC,OAAO,UAAU,CAAM,KAAK,IAAS,IACxC,MAAM,IAAI,EAAuB,yCAAyC,GAAQ;CAItF,IAAM,IAAe,MAAM,QAAQ,CAAM,IAAI,IAAS,MAAM,CAAM,CAAC,CAAC,KAAK,CAAC;CAE1E,IAAI,EAAa,WAAW,GAC1B,MAAM,IAAI,EAAuB,8BAA8B;CAGjE,IAAI,EAAa,MAAM,MAAM,IAAI,CAAC,GAChC,MAAM,IAAI,EAAuB,6BAA6B;CAGhE,IAAM,IAAa,EAAa,QAAQ,GAAK,MAAU,IAAM,GAAO,CAAC;CAErE,IAAI,MAAe,GACjB,MAAM,IAAI,EAAuB,4BAA4B;CAG/D,IAAI,OAAO,KAAW,UAAU;EAC9B,IAAM,IAAmB,OAAO,CAAU,GACpC,IAAU,MAAM,KACpB,EAAE,QAAQ,EAAa,SAAS,EAAE,IACjC,GAAG,MAAO,IAAS,OAAO,EAAa,EAAE,IAAK,CACjD;EAIA,OAFA,EAAQ,KAAK,IAAS,EAAQ,QAAQ,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,GAElD;CACT;CAGA,IAAM,IAAU,MAAM,KAAK,EAAE,QAAQ,EAAa,SAAS,EAAE,IAAI,GAAG,MAClE,KAAK,MAAO,IAAS,EAAa,KAAM,CAAU,CACpD;CAIA,OAFA,EAAQ,KAAK,IAAS,EAAQ,QAAQ,GAAG,MAAM,IAAI,GAAG,CAAC,CAAC,GAEjD;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"average.cjs","names":[],"sources":["../../src/math/average.ts"],"sourcesContent":["import { sum } from './sum';\n\n/**\n * Calculates the average of an array of numbers.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * average(arr); // 3\n * average(arr, (num) => num * 2); // 6\n * ```\n *\n * @param array - The array to average.\n * @param callback - (optional) A callback function to map each item to a number.\n * @returns The average, or `undefined` if the array is empty or contains non-numeric values.\n */\nexport function average<T>(array: T[], callback?: (item: T) => number): number | undefined {\n if (array.length === 0) return undefined;\n\n try {\n const result = sum(array, callback) / array.length;\n\n return Number.isNaN(result) ? undefined : result;\n } catch {\n return undefined;\n }\n}\n"],"mappings":"6BAgBA,SAAgB,EAAW,EAAY,EAAoD,CACrF,KAAM,SAAW,EAErB,GAAI,CACF,IAAM,EAAS,EAAA,IAAI,EAAO,CAAQ,EAAI,EAAM,OAE5C,OAAO,OAAO,MAAM,CAAM,EAAI,IAAA,GAAY,CAC5C,MAAQ,CACN,MACF,CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the average of an array of numbers.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* const arr = [1, 2, 3, 4, 5];
|
|
7
|
+
* average(arr); // 3
|
|
8
|
+
* average(arr, (num) => num * 2); // 6
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @param array - The array to average.
|
|
12
|
+
* @param callback - (optional) A callback function to map each item to a number.
|
|
13
|
+
* @returns The average, or `undefined` if the array is empty or contains non-numeric values.
|
|
14
|
+
*/
|
|
15
|
+
export declare function average<T>(array: T[], callback?: (item: T) => number): number | undefined;
|
|
16
|
+
//# sourceMappingURL=average.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"average.d.ts","sourceRoot":"","sources":["../../src/math/average.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,GAAG,SAAS,CAUzF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { sum as e } from "./sum.js";
|
|
2
|
+
//#region src/math/average.ts
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
if (t.length !== 0) try {
|
|
5
|
+
let r = e(t, n) / t.length;
|
|
6
|
+
return Number.isNaN(r) ? void 0 : r;
|
|
7
|
+
} catch {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { t as average };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=average.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"average.js","names":[],"sources":["../../src/math/average.ts"],"sourcesContent":["import { sum } from './sum';\n\n/**\n * Calculates the average of an array of numbers.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4, 5];\n * average(arr); // 3\n * average(arr, (num) => num * 2); // 6\n * ```\n *\n * @param array - The array to average.\n * @param callback - (optional) A callback function to map each item to a number.\n * @returns The average, or `undefined` if the array is empty or contains non-numeric values.\n */\nexport function average<T>(array: T[], callback?: (item: T) => number): number | undefined {\n if (array.length === 0) return undefined;\n\n try {\n const result = sum(array, callback) / array.length;\n\n return Number.isNaN(result) ? undefined : result;\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;AAgBA,SAAgB,EAAW,GAAY,GAAoD;CACrF,MAAM,WAAW,GAErB,IAAI;EACF,IAAM,IAAS,EAAI,GAAO,CAAQ,IAAI,EAAM;EAE5C,OAAO,OAAO,MAAM,CAAM,IAAI,KAAA,IAAY;CAC5C,QAAQ;EACN;CACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clamp.cjs","names":[],"sources":["../../src/math/clamp.ts"],"sourcesContent":["/**\n * Restricts a number to be within a specified range.\n * Both `min` and `max` are optional — omitting one leaves that end unconstrained.\n *\n * @example\n * ```ts\n * clamp(5, 1, 10) // 5 — within range\n * clamp(0, 1, 10) // 1 — below min\n * clamp(15, 1, 10) // 10 — above max\n * clamp(15, 1) // 15 — no max, above min\n * clamp(-5, undefined, 0) // -5 — no min, below max\n * ```\n *\n * @param n - The number to clamp.\n * @param min - Optional lower bound (inclusive).\n * @param max - Optional upper bound (inclusive).\n *\n * @returns The clamped number.\n */\nexport function clamp(n: number, min?: number, max?: number): number {\n if (min != null && n < min) return min;\n\n if (max != null && n > max) return max;\n\n return n;\n}\n"],"mappings":"AAmBA,SAAgB,EAAM,EAAW,EAAc,EAAsB,CAKnE,OAJI,GAAO,MAAQ,EAAI,EAAY,EAE/B,GAAO,MAAQ,EAAI,EAAY,EAE5B,CACT"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Restricts a number to be within a specified range.
|
|
3
|
+
* Both `min` and `max` are optional — omitting one leaves that end unconstrained.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* clamp(5, 1, 10) // 5 — within range
|
|
8
|
+
* clamp(0, 1, 10) // 1 — below min
|
|
9
|
+
* clamp(15, 1, 10) // 10 — above max
|
|
10
|
+
* clamp(15, 1) // 15 — no max, above min
|
|
11
|
+
* clamp(-5, undefined, 0) // -5 — no min, below max
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @param n - The number to clamp.
|
|
15
|
+
* @param min - Optional lower bound (inclusive).
|
|
16
|
+
* @param max - Optional upper bound (inclusive).
|
|
17
|
+
*
|
|
18
|
+
* @returns The clamped number.
|
|
19
|
+
*/
|
|
20
|
+
export declare function clamp(n: number, min?: number, max?: number): number;
|
|
21
|
+
//# sourceMappingURL=clamp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clamp.d.ts","sourceRoot":"","sources":["../../src/math/clamp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAMnE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clamp.js","names":[],"sources":["../../src/math/clamp.ts"],"sourcesContent":["/**\n * Restricts a number to be within a specified range.\n * Both `min` and `max` are optional — omitting one leaves that end unconstrained.\n *\n * @example\n * ```ts\n * clamp(5, 1, 10) // 5 — within range\n * clamp(0, 1, 10) // 1 — below min\n * clamp(15, 1, 10) // 10 — above max\n * clamp(15, 1) // 15 — no max, above min\n * clamp(-5, undefined, 0) // -5 — no min, below max\n * ```\n *\n * @param n - The number to clamp.\n * @param min - Optional lower bound (inclusive).\n * @param max - Optional upper bound (inclusive).\n *\n * @returns The clamped number.\n */\nexport function clamp(n: number, min?: number, max?: number): number {\n if (min != null && n < min) return min;\n\n if (max != null && n > max) return max;\n\n return n;\n}\n"],"mappings":";AAmBA,SAAgB,EAAM,GAAW,GAAc,GAAsB;CAKnE,OAJI,KAAO,QAAQ,IAAI,IAAY,IAE/B,KAAO,QAAQ,IAAI,IAAY,IAE5B;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gcd.cjs","names":[],"sources":["../../src/math/gcd.ts"],"sourcesContent":["/**\n * Computes the greatest common divisor of two integers using the Euclidean algorithm.\n * The sign of the inputs is ignored — the result is always non-negative.\n *\n * @example\n * ```ts\n * gcd(12, 18); // 6\n * gcd(-12, 18); // 6\n * gcd(0, 5); // 5\n * gcd(0, 0); // 0\n * ```\n *\n * @param a - The first integer.\n * @param b - The second integer.\n * @returns The greatest common divisor of `a` and `b`.\n */\nexport function gcd(a: number, b: number): number {\n let x = Math.abs(a);\n let y = Math.abs(b);\n\n while (y !== 0) {\n const temp = y;\n\n y = x % y;\n x = temp;\n }\n\n return x;\n}\n"],"mappings":"AAgBA,SAAgB,EAAI,EAAW,EAAmB,CAChD,IAAI,EAAI,KAAK,IAAI,CAAC,EACd,EAAI,KAAK,IAAI,CAAC,EAElB,KAAO,IAAM,GAAG,CACd,IAAM,EAAO,EAEb,EAAI,EAAI,EACR,EAAI,CACN,CAEA,OAAO,CACT"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computes the greatest common divisor of two integers using the Euclidean algorithm.
|
|
3
|
+
* The sign of the inputs is ignored — the result is always non-negative.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* gcd(12, 18); // 6
|
|
8
|
+
* gcd(-12, 18); // 6
|
|
9
|
+
* gcd(0, 5); // 5
|
|
10
|
+
* gcd(0, 0); // 0
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param a - The first integer.
|
|
14
|
+
* @param b - The second integer.
|
|
15
|
+
* @returns The greatest common divisor of `a` and `b`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function gcd(a: number, b: number): number;
|
|
18
|
+
//# sourceMappingURL=gcd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gcd.d.ts","sourceRoot":"","sources":["../../src/math/gcd.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAYhD"}
|
package/dist/math/gcd.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gcd.js","names":[],"sources":["../../src/math/gcd.ts"],"sourcesContent":["/**\n * Computes the greatest common divisor of two integers using the Euclidean algorithm.\n * The sign of the inputs is ignored — the result is always non-negative.\n *\n * @example\n * ```ts\n * gcd(12, 18); // 6\n * gcd(-12, 18); // 6\n * gcd(0, 5); // 5\n * gcd(0, 0); // 0\n * ```\n *\n * @param a - The first integer.\n * @param b - The second integer.\n * @returns The greatest common divisor of `a` and `b`.\n */\nexport function gcd(a: number, b: number): number {\n let x = Math.abs(a);\n let y = Math.abs(b);\n\n while (y !== 0) {\n const temp = y;\n\n y = x % y;\n x = temp;\n }\n\n return x;\n}\n"],"mappings":";AAgBA,SAAgB,EAAI,GAAW,GAAmB;CAChD,IAAI,IAAI,KAAK,IAAI,CAAC,GACd,IAAI,KAAK,IAAI,CAAC;CAElB,OAAO,MAAM,IAAG;EACd,IAAM,IAAO;EAGb,AADA,IAAI,IAAI,GACR,IAAI;CACN;CAEA,OAAO;AACT"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export * from './abs';
|
|
2
|
+
export * from './allocate';
|
|
3
|
+
export * from './average';
|
|
4
|
+
export * from './clamp';
|
|
5
|
+
export * from './gcd';
|
|
6
|
+
export * from './lcm';
|
|
7
|
+
export * from './lerp';
|
|
8
|
+
export * from './linspace';
|
|
9
|
+
export * from './max';
|
|
10
|
+
export * from './median';
|
|
11
|
+
export * from './min';
|
|
12
|
+
export * from './mod';
|
|
13
|
+
export * from './normalize';
|
|
14
|
+
export * from './percent';
|
|
15
|
+
export * from './range';
|
|
16
|
+
export * from './round';
|
|
17
|
+
export * from './standardDeviation';
|
|
18
|
+
export * from './sum';
|
|
19
|
+
export * from './variance';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/math/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lcm.cjs","names":[],"sources":["../../src/math/lcm.ts"],"sourcesContent":["import { gcd } from './gcd';\n\n/**\n * Computes the least common multiple of two integers.\n *\n * @example\n * ```ts\n * lcm(4, 6); // 12\n * lcm(0, 5); // 0\n * ```\n *\n * @param a - The first integer.\n * @param b - The second integer.\n * @returns The least common multiple of `a` and `b`, or `0` if either is `0`.\n */\nexport function lcm(a: number, b: number): number {\n if (a === 0 || b === 0) return 0;\n\n return Math.abs(a * b) / gcd(a, b);\n}\n"],"mappings":"6BAeA,SAAgB,EAAI,EAAW,EAAmB,CAGhD,OAFI,IAAM,GAAK,IAAM,EAAU,EAExB,KAAK,IAAI,EAAI,CAAC,EAAI,EAAA,IAAI,EAAG,CAAC,CACnC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computes the least common multiple of two integers.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* lcm(4, 6); // 12
|
|
7
|
+
* lcm(0, 5); // 0
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @param a - The first integer.
|
|
11
|
+
* @param b - The second integer.
|
|
12
|
+
* @returns The least common multiple of `a` and `b`, or `0` if either is `0`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function lcm(a: number, b: number): number;
|
|
15
|
+
//# sourceMappingURL=lcm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lcm.d.ts","sourceRoot":"","sources":["../../src/math/lcm.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAIhD"}
|
package/dist/math/lcm.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lcm.js","names":[],"sources":["../../src/math/lcm.ts"],"sourcesContent":["import { gcd } from './gcd';\n\n/**\n * Computes the least common multiple of two integers.\n *\n * @example\n * ```ts\n * lcm(4, 6); // 12\n * lcm(0, 5); // 0\n * ```\n *\n * @param a - The first integer.\n * @param b - The second integer.\n * @returns The least common multiple of `a` and `b`, or `0` if either is `0`.\n */\nexport function lcm(a: number, b: number): number {\n if (a === 0 || b === 0) return 0;\n\n return Math.abs(a * b) / gcd(a, b);\n}\n"],"mappings":";;AAeA,SAAgB,EAAI,GAAW,GAAmB;CAGhD,OAFI,MAAM,KAAK,MAAM,IAAU,IAExB,KAAK,IAAI,IAAI,CAAC,IAAI,EAAI,GAAG,CAAC;AACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lerp.cjs","names":[],"sources":["../../src/math/lerp.ts"],"sourcesContent":["/**\n * Linearly interpolates between `a` and `b` by factor `t`. `t` is not clamped, so values\n * outside `[0, 1]` extrapolate beyond the `[a, b]` range.\n *\n * @example\n * ```ts\n * lerp(0, 10, 0.5); // 5\n * lerp(0, 10, 1.5); // 15 (extrapolated — t is not clamped)\n * ```\n *\n * @param a - The start value (returned when `t` is `0`).\n * @param b - The end value (returned when `t` is `1`).\n * @param t - The interpolation factor.\n * @returns The interpolated value.\n */\nexport function lerp(a: number, b: number, t: number): number {\n return a + (b - a) * t;\n}\n"],"mappings":"AAeA,SAAgB,EAAK,EAAW,EAAW,EAAmB,CAC5D,OAAO,GAAK,EAAI,GAAK,CACvB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Linearly interpolates between `a` and `b` by factor `t`. `t` is not clamped, so values
|
|
3
|
+
* outside `[0, 1]` extrapolate beyond the `[a, b]` range.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* lerp(0, 10, 0.5); // 5
|
|
8
|
+
* lerp(0, 10, 1.5); // 15 (extrapolated — t is not clamped)
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @param a - The start value (returned when `t` is `0`).
|
|
12
|
+
* @param b - The end value (returned when `t` is `1`).
|
|
13
|
+
* @param t - The interpolation factor.
|
|
14
|
+
* @returns The interpolated value.
|
|
15
|
+
*/
|
|
16
|
+
export declare function lerp(a: number, b: number, t: number): number;
|
|
17
|
+
//# sourceMappingURL=lerp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lerp.d.ts","sourceRoot":"","sources":["../../src/math/lerp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAE5D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lerp.js","names":[],"sources":["../../src/math/lerp.ts"],"sourcesContent":["/**\n * Linearly interpolates between `a` and `b` by factor `t`. `t` is not clamped, so values\n * outside `[0, 1]` extrapolate beyond the `[a, b]` range.\n *\n * @example\n * ```ts\n * lerp(0, 10, 0.5); // 5\n * lerp(0, 10, 1.5); // 15 (extrapolated — t is not clamped)\n * ```\n *\n * @param a - The start value (returned when `t` is `0`).\n * @param b - The end value (returned when `t` is `1`).\n * @param t - The interpolation factor.\n * @returns The interpolated value.\n */\nexport function lerp(a: number, b: number, t: number): number {\n return a + (b - a) * t;\n}\n"],"mappings":";AAeA,SAAgB,EAAK,GAAW,GAAW,GAAmB;CAC5D,OAAO,KAAK,IAAI,KAAK;AACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linspace.cjs","names":[],"sources":["../../src/math/linspace.ts"],"sourcesContent":["/**\n * Creates an array of evenly-spaced numbers from `start` to `end`.\n *\n * @example\n * ```ts\n * linspace(0, 10); // [0, 2.5, 5, 7.5, 10]\n * linspace(0, 10, 3); // [0, 5, 10]\n * linspace(0, 10, 1); // [0]\n * linspace(10, 0, 5); // [10, 7.5, 5, 2.5, 0]\n * ```\n *\n * @param start - The start of the range.\n * @param end - The end of the range.\n * @param steps - Number of evenly-spaced points to generate (default: 5).\n *\n * @returns An array of `steps` numbers from `start` to `end`.\n */\nexport function linspace(start: number, end: number, steps = 5): number[] {\n if (steps <= 0) return [];\n\n if (steps === 1) return [start];\n\n const stepSize = (end - start) / (steps - 1);\n\n return Array.from({ length: steps }, (_, i) => start + i * stepSize);\n}\n"],"mappings":"AAiBA,SAAgB,EAAS,EAAe,EAAa,EAAQ,EAAa,CACxE,GAAI,GAAS,EAAG,MAAO,CAAC,EAExB,GAAI,IAAU,EAAG,MAAO,CAAC,CAAK,EAE9B,IAAM,GAAY,EAAM,IAAU,EAAQ,GAE1C,OAAO,MAAM,KAAK,CAAE,OAAQ,CAAM,GAAI,EAAG,IAAM,EAAQ,EAAI,CAAQ,CACrE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates an array of evenly-spaced numbers from `start` to `end`.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* linspace(0, 10); // [0, 2.5, 5, 7.5, 10]
|
|
7
|
+
* linspace(0, 10, 3); // [0, 5, 10]
|
|
8
|
+
* linspace(0, 10, 1); // [0]
|
|
9
|
+
* linspace(10, 0, 5); // [10, 7.5, 5, 2.5, 0]
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @param start - The start of the range.
|
|
13
|
+
* @param end - The end of the range.
|
|
14
|
+
* @param steps - Number of evenly-spaced points to generate (default: 5).
|
|
15
|
+
*
|
|
16
|
+
* @returns An array of `steps` numbers from `start` to `end`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function linspace(start: number, end: number, steps?: number): number[];
|
|
19
|
+
//# sourceMappingURL=linspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linspace.d.ts","sourceRoot":"","sources":["../../src/math/linspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,MAAM,EAAE,CAQxE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/math/linspace.ts
|
|
2
|
+
function e(e, t, n = 5) {
|
|
3
|
+
if (n <= 0) return [];
|
|
4
|
+
if (n === 1) return [e];
|
|
5
|
+
let r = (t - e) / (n - 1);
|
|
6
|
+
return Array.from({ length: n }, (t, n) => e + n * r);
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { e as linspace };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=linspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linspace.js","names":[],"sources":["../../src/math/linspace.ts"],"sourcesContent":["/**\n * Creates an array of evenly-spaced numbers from `start` to `end`.\n *\n * @example\n * ```ts\n * linspace(0, 10); // [0, 2.5, 5, 7.5, 10]\n * linspace(0, 10, 3); // [0, 5, 10]\n * linspace(0, 10, 1); // [0]\n * linspace(10, 0, 5); // [10, 7.5, 5, 2.5, 0]\n * ```\n *\n * @param start - The start of the range.\n * @param end - The end of the range.\n * @param steps - Number of evenly-spaced points to generate (default: 5).\n *\n * @returns An array of `steps` numbers from `start` to `end`.\n */\nexport function linspace(start: number, end: number, steps = 5): number[] {\n if (steps <= 0) return [];\n\n if (steps === 1) return [start];\n\n const stepSize = (end - start) / (steps - 1);\n\n return Array.from({ length: steps }, (_, i) => start + i * stepSize);\n}\n"],"mappings":";AAiBA,SAAgB,EAAS,GAAe,GAAa,IAAQ,GAAa;CACxE,IAAI,KAAS,GAAG,OAAO,CAAC;CAExB,IAAI,MAAU,GAAG,OAAO,CAAC,CAAK;CAE9B,IAAM,KAAY,IAAM,MAAU,IAAQ;CAE1C,OAAO,MAAM,KAAK,EAAE,QAAQ,EAAM,IAAI,GAAG,MAAM,IAAQ,IAAI,CAAQ;AACrE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"max.cjs","names":[],"sources":["../../src/math/max.ts"],"sourcesContent":["import { compare } from '../array/compare';\n\n/**\n * Finds the maximum item in an array.\n *\n * @description\n * This function can be used to find the maximum number, string, or any other type of item in an array.\n *\n * @example\n * ```ts\n * max([1, 2, 3]); // 3\n * max([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 3\n * max(['apple', 'banana', 'cherry']); // 'cherry'\n * max([new Date('2023-01-01'), new Date('2022-01-01')]); // 2023-01-01\n * ```\n *\n * @param array - The array to be searched.\n * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.\n *\n * @return The item with the maximum value as determined by the callback function.\n */\nexport function max<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined {\n if (array.length === 0) return undefined;\n\n const fn = callback ?? ((item: T) => item);\n let current = array[0];\n\n for (let i = 1; i < array.length; i++) {\n if (compare(fn(array[i]), fn(current)) > 0) {\n current = array[i];\n }\n }\n\n return current;\n}\n"],"mappings":"wCAqBA,SAAgB,EAAO,EAAY,EAA+D,CAChG,GAAI,EAAM,SAAW,EAAG,OAExB,IAAM,EAAK,IAAc,GAAY,GACjC,EAAU,EAAM,GAEpB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAQ,IAC5B,EAAA,QAAQ,EAAG,EAAM,EAAE,EAAG,EAAG,CAAO,CAAC,EAAI,IACvC,EAAU,EAAM,IAIpB,OAAO,CACT"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds the maximum item in an array.
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* This function can be used to find the maximum number, string, or any other type of item in an array.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* max([1, 2, 3]); // 3
|
|
10
|
+
* max([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 3
|
|
11
|
+
* max(['apple', 'banana', 'cherry']); // 'cherry'
|
|
12
|
+
* max([new Date('2023-01-01'), new Date('2022-01-01')]); // 2023-01-01
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @param array - The array to be searched.
|
|
16
|
+
* @param [callback] - (optional) The function to invoke for each element in the array to determine its value.
|
|
17
|
+
*
|
|
18
|
+
* @return The item with the maximum value as determined by the callback function.
|
|
19
|
+
*/
|
|
20
|
+
export declare function max<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined;
|
|
21
|
+
//# sourceMappingURL=max.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"max.d.ts","sourceRoot":"","sources":["../../src/math/max.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,SAAS,CAahG"}
|
package/dist/math/max.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { compare as e } from "../array/compare.js";
|
|
2
|
+
//#region src/math/max.ts
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
if (t.length === 0) return;
|
|
5
|
+
let r = n ?? ((e) => e), i = t[0];
|
|
6
|
+
for (let n = 1; n < t.length; n++) e(r(t[n]), r(i)) > 0 && (i = t[n]);
|
|
7
|
+
return i;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { t as max };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=max.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"max.js","names":[],"sources":["../../src/math/max.ts"],"sourcesContent":["import { compare } from '../array/compare';\n\n/**\n * Finds the maximum item in an array.\n *\n * @description\n * This function can be used to find the maximum number, string, or any other type of item in an array.\n *\n * @example\n * ```ts\n * max([1, 2, 3]); // 3\n * max([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 3\n * max(['apple', 'banana', 'cherry']); // 'cherry'\n * max([new Date('2023-01-01'), new Date('2022-01-01')]); // 2023-01-01\n * ```\n *\n * @param array - The array to be searched.\n * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.\n *\n * @return The item with the maximum value as determined by the callback function.\n */\nexport function max<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined {\n if (array.length === 0) return undefined;\n\n const fn = callback ?? ((item: T) => item);\n let current = array[0];\n\n for (let i = 1; i < array.length; i++) {\n if (compare(fn(array[i]), fn(current)) > 0) {\n current = array[i];\n }\n }\n\n return current;\n}\n"],"mappings":";;AAqBA,SAAgB,EAAO,GAAY,GAA+D;CAChG,IAAI,EAAM,WAAW,GAAG;CAExB,IAAM,IAAK,OAAc,MAAY,IACjC,IAAU,EAAM;CAEpB,KAAK,IAAI,IAAI,GAAG,IAAI,EAAM,QAAQ,KAChC,AAAI,EAAQ,EAAG,EAAM,EAAE,GAAG,EAAG,CAAO,CAAC,IAAI,MACvC,IAAU,EAAM;CAIpB,OAAO;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"median.cjs","names":[],"sources":["../../src/math/median.ts"],"sourcesContent":["/**\n * Returns the median of an array of numbers.\n *\n * @example\n * ```ts\n * median([1, 2, 3, 4, 100]); // 3\n * median([1, 2, 3, 4, 5], (n) => n * 2); // 6\n * median([]); // undefined\n * median([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); // 5.5\n * ```\n *\n * @param arr - The array of numbers.\n * @param callback - (optional) A callback function to map each item to a number.\n * @returns The median, or `undefined` if the array is empty.\n */\nexport function median<T>(arr: T[], callback?: (item: T) => number): number | undefined {\n if (arr.length === 0) return undefined;\n\n const values = callback ? arr.map(callback) : [...(arr as unknown as number[])];\n\n values.sort((a, b) => a - b);\n\n const mid = Math.floor(values.length / 2);\n\n return values.length % 2 === 0 ? (values[mid - 1] + values[mid]) / 2 : values[mid];\n}\n"],"mappings":"AAeA,SAAgB,EAAU,EAAU,EAAoD,CACtF,GAAI,EAAI,SAAW,EAAG,OAEtB,IAAM,EAAS,EAAW,EAAI,IAAI,CAAQ,EAAI,CAAC,GAAI,CAA2B,EAE9E,EAAO,MAAM,EAAG,IAAM,EAAI,CAAC,EAE3B,IAAM,EAAM,KAAK,MAAM,EAAO,OAAS,CAAC,EAExC,OAAO,EAAO,OAAS,GAAM,GAAK,EAAO,EAAM,GAAK,EAAO,IAAQ,EAAI,EAAO,EAChF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the median of an array of numbers.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* median([1, 2, 3, 4, 100]); // 3
|
|
7
|
+
* median([1, 2, 3, 4, 5], (n) => n * 2); // 6
|
|
8
|
+
* median([]); // undefined
|
|
9
|
+
* median([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); // 5.5
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @param arr - The array of numbers.
|
|
13
|
+
* @param callback - (optional) A callback function to map each item to a number.
|
|
14
|
+
* @returns The median, or `undefined` if the array is empty.
|
|
15
|
+
*/
|
|
16
|
+
export declare function median<T>(arr: T[], callback?: (item: T) => number): number | undefined;
|
|
17
|
+
//# sourceMappingURL=median.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"median.d.ts","sourceRoot":"","sources":["../../src/math/median.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,GAAG,SAAS,CAUtF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/math/median.ts
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
if (e.length === 0) return;
|
|
4
|
+
let n = t ? e.map(t) : [...e];
|
|
5
|
+
n.sort((e, t) => e - t);
|
|
6
|
+
let r = Math.floor(n.length / 2);
|
|
7
|
+
return n.length % 2 == 0 ? (n[r - 1] + n[r]) / 2 : n[r];
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { e as median };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=median.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"median.js","names":[],"sources":["../../src/math/median.ts"],"sourcesContent":["/**\n * Returns the median of an array of numbers.\n *\n * @example\n * ```ts\n * median([1, 2, 3, 4, 100]); // 3\n * median([1, 2, 3, 4, 5], (n) => n * 2); // 6\n * median([]); // undefined\n * median([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); // 5.5\n * ```\n *\n * @param arr - The array of numbers.\n * @param callback - (optional) A callback function to map each item to a number.\n * @returns The median, or `undefined` if the array is empty.\n */\nexport function median<T>(arr: T[], callback?: (item: T) => number): number | undefined {\n if (arr.length === 0) return undefined;\n\n const values = callback ? arr.map(callback) : [...(arr as unknown as number[])];\n\n values.sort((a, b) => a - b);\n\n const mid = Math.floor(values.length / 2);\n\n return values.length % 2 === 0 ? (values[mid - 1] + values[mid]) / 2 : values[mid];\n}\n"],"mappings":";AAeA,SAAgB,EAAU,GAAU,GAAoD;CACtF,IAAI,EAAI,WAAW,GAAG;CAEtB,IAAM,IAAS,IAAW,EAAI,IAAI,CAAQ,IAAI,CAAC,GAAI,CAA2B;CAE9E,EAAO,MAAM,GAAG,MAAM,IAAI,CAAC;CAE3B,IAAM,IAAM,KAAK,MAAM,EAAO,SAAS,CAAC;CAExC,OAAO,EAAO,SAAS,KAAM,KAAK,EAAO,IAAM,KAAK,EAAO,MAAQ,IAAI,EAAO;AAChF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"min.cjs","names":[],"sources":["../../src/math/min.ts"],"sourcesContent":["import { compare } from '../array/compare';\n\n/**\n * Finds the minimum item in an array.\n *\n * @description\n * This function can be used to find the minimum number, string, or any other type of item in an array.\n *\n * @example\n * ```ts\n * min([1, 2, 3]); // 1\n * min([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 1\n * min(['apple', 'banana', 'cherry']); // 'apple'\n * min([new Date('2023-01-01'), new Date('2022-01-01')]); // 2022-01-01\n * ```\n *\n * @param array - The array to be searched.\n * @param [callback] - (optional) The function to invoke for each element in the array to determine its value.\n *\n * @return The item with the minimum value as determined by the callback function.\n */\nexport function min<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined {\n if (array.length === 0) return undefined;\n\n const fn = callback ?? ((item: T) => item);\n let current = array[0];\n\n for (let i = 1; i < array.length; i++) {\n if (compare(fn(array[i]), fn(current)) < 0) {\n current = array[i];\n }\n }\n\n return current;\n}\n"],"mappings":"wCAqBA,SAAgB,EAAO,EAAY,EAA+D,CAChG,GAAI,EAAM,SAAW,EAAG,OAExB,IAAM,EAAK,IAAc,GAAY,GACjC,EAAU,EAAM,GAEpB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAQ,IAC5B,EAAA,QAAQ,EAAG,EAAM,EAAE,EAAG,EAAG,CAAO,CAAC,EAAI,IACvC,EAAU,EAAM,IAIpB,OAAO,CACT"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds the minimum item in an array.
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* This function can be used to find the minimum number, string, or any other type of item in an array.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* min([1, 2, 3]); // 1
|
|
10
|
+
* min([{ value: 1 }, { value: 2 }, { value: 3 }], item => item.value); // 1
|
|
11
|
+
* min(['apple', 'banana', 'cherry']); // 'apple'
|
|
12
|
+
* min([new Date('2023-01-01'), new Date('2022-01-01')]); // 2022-01-01
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @param array - The array to be searched.
|
|
16
|
+
* @param [callback] - (optional) The function to invoke for each element in the array to determine its value.
|
|
17
|
+
*
|
|
18
|
+
* @return The item with the minimum value as determined by the callback function.
|
|
19
|
+
*/
|
|
20
|
+
export declare function min<T>(array: T[], callback?: (item: T) => string | number | Date): T | undefined;
|
|
21
|
+
//# sourceMappingURL=min.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"min.d.ts","sourceRoot":"","sources":["../../src/math/min.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,SAAS,CAahG"}
|