@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,27 @@
|
|
|
1
|
+
import { isUnsafeKey as e } from "../_common/unsafePaths.js";
|
|
2
|
+
import { isPlainObject as t } from "../guards/isPlainObject.js";
|
|
3
|
+
//#region src/object/merge.ts
|
|
4
|
+
function n(r, i, a) {
|
|
5
|
+
if (!t(i)) return i;
|
|
6
|
+
let o = { ...r };
|
|
7
|
+
for (let r of Object.keys(i)) {
|
|
8
|
+
if (e(r)) continue;
|
|
9
|
+
let s = i[r], c = o[r];
|
|
10
|
+
o[r] = Array.isArray(s) && Array.isArray(c) ? a.arrayStrategy === "concat" ? [...c, ...s] : s : t(s) && t(c) ? n(c, s, a) : s;
|
|
11
|
+
}
|
|
12
|
+
return o;
|
|
13
|
+
}
|
|
14
|
+
function r(...e) {
|
|
15
|
+
let t = e[e.length - 1], r = e.length > 0 && typeof t == "object" && !!t && !Array.isArray(t) && "arrayStrategy" in t && Object.keys(t).length === 1 && (t.arrayStrategy === "concat" || t.arrayStrategy === "replace"), i = r ? t : {}, a = r ? e.slice(0, -1) : e;
|
|
16
|
+
return a.length === 0 ? {} : a.reduce((e, t) => n(e, t, i), {});
|
|
17
|
+
}
|
|
18
|
+
function i(...t) {
|
|
19
|
+
if (t.length === 0) return {};
|
|
20
|
+
let n = {};
|
|
21
|
+
for (let r of t) for (let t of Object.keys(r)) e(t) || (n[t] = r[t]);
|
|
22
|
+
return n;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { r as deepMerge, i as shallowMerge };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.js","names":[],"sources":["../../src/object/merge.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\nimport { isPlainObject } from '../guards/isPlainObject';\n\nexport type DeepMergeOptions = {\n /** How to handle arrays when both source and target contain one. Default: `'replace'`. */\n arrayStrategy?: 'concat' | 'replace';\n};\n\ntype DeepMerge<T, U> = T extends Obj\n ? U extends Obj\n ? {\n [K in keyof T | keyof U]: K extends keyof T\n ? K extends keyof U\n ? DeepMerge<T[K], U[K]>\n : T[K]\n : K extends keyof U\n ? U[K]\n : never;\n }\n : U\n : U;\n\ntype Merge<T extends Obj[]> = T extends [infer First, ...infer Rest]\n ? First extends Obj\n ? Rest extends Obj[]\n ? DeepMerge<First, Merge<Rest>>\n : First\n : Obj\n : Obj;\n\nfunction mergeObjects<T extends Obj, U extends Obj>(target: T, source: U, options: DeepMergeOptions): DeepMerge<T, U> {\n if (!isPlainObject(source)) return source as DeepMerge<T, U>;\n\n const result = { ...target } as DeepMerge<T, U>;\n\n for (const key of Object.keys(source)) {\n // Guard against prototype pollution: skip dangerous keys\n if (isUnsafeKey(key)) {\n continue;\n }\n\n const sourceValue = source[key];\n const targetValue = result[key];\n\n (result as Record<string, unknown>)[key] =\n Array.isArray(sourceValue) && Array.isArray(targetValue)\n ? options.arrayStrategy === 'concat'\n ? [...targetValue, ...sourceValue]\n : sourceValue\n : isPlainObject(sourceValue) && isPlainObject(targetValue)\n ? mergeObjects(targetValue as Obj, sourceValue as Obj, options)\n : sourceValue;\n }\n\n return result;\n}\n\n/**\n * Deeply merges two or more objects. Arrays in source objects **replace** the target array by default.\n * Pass `{ arrayStrategy: 'concat' }` as the last argument to concatenate arrays instead.\n *\n * @example\n * ```ts\n * deepMerge({ a: 1, b: { x: 1 } }, { b: { y: 2 }, c: 3 });\n * // { a: 1, b: { x: 1, y: 2 }, c: 3 }\n *\n * deepMerge({ tags: ['a'] }, { tags: ['b'] });\n * // { tags: ['b'] } ← arrays replaced\n *\n * deepMerge({ tags: ['a'] }, { tags: ['b'] }, { arrayStrategy: 'concat' });\n * // { tags: ['a', 'b'] }\n * ```\n */\nexport function deepMerge<T extends Obj[]>(...args: [...T] | [...T, DeepMergeOptions]): Merge<T> {\n const lastArg = args[args.length - 1];\n const hasOptions =\n args.length > 0 &&\n typeof lastArg === 'object' &&\n lastArg !== null &&\n !Array.isArray(lastArg) &&\n 'arrayStrategy' in lastArg &&\n Object.keys(lastArg).length === 1 &&\n ((lastArg as DeepMergeOptions).arrayStrategy === 'concat' ||\n (lastArg as DeepMergeOptions).arrayStrategy === 'replace');\n\n const options: DeepMergeOptions = hasOptions ? (lastArg as DeepMergeOptions) : {};\n const items = (hasOptions ? args.slice(0, -1) : args) as Obj[];\n\n if (items.length === 0) return {} as Merge<T>;\n\n return items.reduce((acc: Obj, obj: Obj) => mergeObjects(acc, obj, options) as Obj, {} as Obj) as unknown as Merge<T>;\n}\n\n/**\n * Shallowly merges two or more objects. Later sources win for duplicate keys.\n * Dangerous keys (`__proto__`, `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * shallowMerge({ a: 1, b: { x: 1 } }, { b: { y: 2 } });\n * // { a: 1, b: { y: 2 } } ← nested object replaced, not merged\n *\n * shallowMerge(defaults, overrides, extras);\n * ```\n */\nexport function shallowMerge<T extends Obj[]>(...items: [...T]): Merge<T> {\n if (items.length === 0) return {} as Merge<T>;\n\n const result: Obj = {};\n\n for (const item of items) {\n for (const key of Object.keys(item)) {\n if (isUnsafeKey(key)) continue;\n\n result[key] = item[key];\n }\n }\n\n return result as Merge<T>;\n}\n"],"mappings":";;;AAgCA,SAAS,EAA2C,GAAW,GAAW,GAA4C;CACpH,IAAI,CAAC,EAAc,CAAM,GAAG,OAAO;CAEnC,IAAM,IAAS,EAAE,GAAG,EAAO;CAE3B,KAAK,IAAM,KAAO,OAAO,KAAK,CAAM,GAAG;EAErC,IAAI,EAAY,CAAG,GACjB;EAGF,IAAM,IAAc,EAAO,IACrB,IAAc,EAAO;EAE3B,EAAoC,KAClC,MAAM,QAAQ,CAAW,KAAK,MAAM,QAAQ,CAAW,IACnD,EAAQ,kBAAkB,WACxB,CAAC,GAAG,GAAa,GAAG,CAAW,IAC/B,IACF,EAAc,CAAW,KAAK,EAAc,CAAW,IACrD,EAAa,GAAoB,GAAoB,CAAO,IAC5D;CACV;CAEA,OAAO;AACT;AAkBA,SAAgB,EAA2B,GAAG,GAAmD;CAC/F,IAAM,IAAU,EAAK,EAAK,SAAS,IAC7B,IACJ,EAAK,SAAS,KACd,OAAO,KAAY,cACnB,KACA,CAAC,MAAM,QAAQ,CAAO,KACtB,mBAAmB,KACnB,OAAO,KAAK,CAAO,CAAC,CAAC,WAAW,MAC9B,EAA6B,kBAAkB,YAC9C,EAA6B,kBAAkB,YAE9C,IAA4B,IAAc,IAA+B,CAAC,GAC1E,IAAS,IAAa,EAAK,MAAM,GAAG,EAAE,IAAI;CAIhD,OAFI,EAAM,WAAW,IAAU,CAAC,IAEzB,EAAM,QAAQ,GAAU,MAAa,EAAa,GAAK,GAAK,CAAO,GAAU,CAAC,CAAQ;AAC/F;AAcA,SAAgB,EAA8B,GAAG,GAAyB;CACxE,IAAI,EAAM,WAAW,GAAG,OAAO,CAAC;CAEhC,IAAM,IAAc,CAAC;CAErB,KAAK,IAAM,KAAQ,GACjB,KAAK,IAAM,KAAO,OAAO,KAAK,CAAI,GAC5B,EAAY,CAAG,MAEnB,EAAO,KAAO,EAAK;CAIvB,OAAO;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omit.cjs","names":[],"sources":["../../src/object/omit.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\n\n/**\n * Creates a new object without the selected keys. Only `obj`'s own enumerable keys are\n * considered; dangerous keys (`__proto__`, `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * omit({ a: 1, b: 2, c: 3 }, ['b']); // { a: 1, c: 3 }\n * ```\n *\n * @param obj - The source object.\n * @param omittedKeys - The keys to exclude.\n * @returns A new object with `omittedKeys` removed.\n */\nexport function omit<T extends Obj, K extends keyof T>(obj: T, omittedKeys: readonly K[]): Omit<T, K> {\n const blacklist = new Set<PropertyKey>(omittedKeys as readonly PropertyKey[]);\n const out = {} as Omit<T, K>;\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (!blacklist.has(key)) {\n (out as T)[key] = obj[key];\n }\n }\n\n return out;\n}\n"],"mappings":"8CAiBA,SAAgB,EAAuC,EAAQ,EAAuC,CACpG,IAAM,EAAY,IAAI,IAAiB,CAAqC,EACtE,EAAM,CAAC,EAEb,IAAK,IAAM,KAAO,OAAO,KAAK,CAAG,EAC3B,EAAA,YAAY,CAAkB,GAE7B,EAAU,IAAI,CAAG,IACpB,EAAW,GAAO,EAAI,IAI1B,OAAO,CACT"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Obj } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new object without the selected keys. Only `obj`'s own enumerable keys are
|
|
4
|
+
* considered; dangerous keys (`__proto__`, `constructor`, `prototype`) are always skipped.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* omit({ a: 1, b: 2, c: 3 }, ['b']); // { a: 1, c: 3 }
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @param obj - The source object.
|
|
12
|
+
* @param omittedKeys - The keys to exclude.
|
|
13
|
+
* @returns A new object with `omittedKeys` removed.
|
|
14
|
+
*/
|
|
15
|
+
export declare function omit<T extends Obj, K extends keyof T>(obj: T, omittedKeys: readonly K[]): Omit<T, K>;
|
|
16
|
+
//# sourceMappingURL=omit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omit.d.ts","sourceRoot":"","sources":["../../src/object/omit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAIpC;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAapG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isUnsafeKey as e } from "../_common/unsafePaths.js";
|
|
2
|
+
//#region src/object/omit.ts
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
let r = new Set(n), i = {};
|
|
5
|
+
for (let n of Object.keys(t)) e(n) || r.has(n) || (i[n] = t[n]);
|
|
6
|
+
return i;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { t as omit };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=omit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omit.js","names":[],"sources":["../../src/object/omit.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\n\n/**\n * Creates a new object without the selected keys. Only `obj`'s own enumerable keys are\n * considered; dangerous keys (`__proto__`, `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * omit({ a: 1, b: 2, c: 3 }, ['b']); // { a: 1, c: 3 }\n * ```\n *\n * @param obj - The source object.\n * @param omittedKeys - The keys to exclude.\n * @returns A new object with `omittedKeys` removed.\n */\nexport function omit<T extends Obj, K extends keyof T>(obj: T, omittedKeys: readonly K[]): Omit<T, K> {\n const blacklist = new Set<PropertyKey>(omittedKeys as readonly PropertyKey[]);\n const out = {} as Omit<T, K>;\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (!blacklist.has(key)) {\n (out as T)[key] = obj[key];\n }\n }\n\n return out;\n}\n"],"mappings":";;AAiBA,SAAgB,EAAuC,GAAQ,GAAuC;CACpG,IAAM,IAAY,IAAI,IAAiB,CAAqC,GACtE,IAAM,CAAC;CAEb,KAAK,IAAM,KAAO,OAAO,KAAK,CAAG,GAC3B,EAAY,CAAkB,KAE7B,EAAU,IAAI,CAAG,MACpB,EAAW,KAAO,EAAI;CAI1B,OAAO;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseJSON.cjs","names":[],"sources":["../../src/object/parseJSON.ts"],"sourcesContent":["import { isNil } from '../guards/isNil';\n\nexport type ParseJSONOptions<T> = {\n fallback?: T;\n reviver?: (key: string, value: unknown) => unknown;\n validator?: (parsed: unknown) => boolean;\n};\n\n/**\n * Parses a JSON string and returns the resulting value.\n * `null` and `undefined` inputs return `fallback` without throwing.\n *\n * @example\n * ```ts\n * parseJSON<Record<string, number>>('{\"a\":1}'); // { a: 1 }\n * parseJSON('bad json', { fallback: {} }); // {}\n * parseJSON(null, { fallback: 0 }); // 0\n *\n * // With a validator — returns fallback when validation fails\n * parseJSON('{\"id\":\"bad\"}', {\n * validator: (v) => typeof (v as Record<string, unknown>).id === 'number',\n * fallback: { id: 0 },\n * }); // { id: 0 }\n * ```\n *\n * @template T - The expected type of the parsed JSON.\n * @param json - The JSON string to parse. `null` / `undefined` return `fallback`.\n * @param [options.fallback] - Value to return when parsing fails, input is nullish, or validation fails.\n * @param [options.reviver] - Optional reviver function for `JSON.parse`.\n * @param [options.validator] - Optional predicate; if it returns `false`, `fallback` is returned.\n *\n * @returns The parsed value, or `fallback` on failure.\n */\nexport function parseJSON<T = unknown>(\n json: string | null | undefined,\n options: ParseJSONOptions<T> = {},\n): T | undefined {\n const { fallback, reviver, validator } = options;\n\n if (isNil(json)) return fallback;\n\n try {\n const value = JSON.parse(json, reviver as Parameters<typeof JSON.parse>[1]) as unknown;\n\n if (value === undefined) return fallback;\n\n if (validator && !validator(value)) return fallback;\n\n return value as T | undefined;\n } catch {\n return fallback;\n }\n}\n"],"mappings":"uCAiCA,SAAgB,EACd,EACA,EAA+B,CAAC,EACjB,CACf,GAAM,CAAE,WAAU,UAAS,aAAc,EAEzC,GAAI,EAAA,MAAM,CAAI,EAAG,OAAO,EAExB,GAAI,CACF,IAAM,EAAQ,KAAK,MAAM,EAAM,CAA2C,EAM1E,OAJI,IAAU,IAAA,IAEV,GAAa,CAAC,EAAU,CAAK,EAAU,EAEpC,CACT,MAAQ,CACN,OAAO,CACT,CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type ParseJSONOptions<T> = {
|
|
2
|
+
fallback?: T;
|
|
3
|
+
reviver?: (key: string, value: unknown) => unknown;
|
|
4
|
+
validator?: (parsed: unknown) => boolean;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Parses a JSON string and returns the resulting value.
|
|
8
|
+
* `null` and `undefined` inputs return `fallback` without throwing.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* parseJSON<Record<string, number>>('{"a":1}'); // { a: 1 }
|
|
13
|
+
* parseJSON('bad json', { fallback: {} }); // {}
|
|
14
|
+
* parseJSON(null, { fallback: 0 }); // 0
|
|
15
|
+
*
|
|
16
|
+
* // With a validator — returns fallback when validation fails
|
|
17
|
+
* parseJSON('{"id":"bad"}', {
|
|
18
|
+
* validator: (v) => typeof (v as Record<string, unknown>).id === 'number',
|
|
19
|
+
* fallback: { id: 0 },
|
|
20
|
+
* }); // { id: 0 }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @template T - The expected type of the parsed JSON.
|
|
24
|
+
* @param json - The JSON string to parse. `null` / `undefined` return `fallback`.
|
|
25
|
+
* @param [options.fallback] - Value to return when parsing fails, input is nullish, or validation fails.
|
|
26
|
+
* @param [options.reviver] - Optional reviver function for `JSON.parse`.
|
|
27
|
+
* @param [options.validator] - Optional predicate; if it returns `false`, `fallback` is returned.
|
|
28
|
+
*
|
|
29
|
+
* @returns The parsed value, or `fallback` on failure.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseJSON<T = unknown>(json: string | null | undefined, options?: ParseJSONOptions<T>): T | undefined;
|
|
32
|
+
//# sourceMappingURL=parseJSON.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseJSON.d.ts","sourceRoot":"","sources":["../../src/object/parseJSON.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAChC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACb,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;IACnD,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC;CAC1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,SAAS,CAAC,CAAC,GAAG,OAAO,EACnC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/B,OAAO,GAAE,gBAAgB,CAAC,CAAC,CAAM,GAChC,CAAC,GAAG,SAAS,CAgBf"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isNil as e } from "../guards/isNil.js";
|
|
2
|
+
//#region src/object/parseJSON.ts
|
|
3
|
+
function t(t, n = {}) {
|
|
4
|
+
let { fallback: r, reviver: i, validator: a } = n;
|
|
5
|
+
if (e(t)) return r;
|
|
6
|
+
try {
|
|
7
|
+
let e = JSON.parse(t, i);
|
|
8
|
+
return e === void 0 || a && !a(e) ? r : e;
|
|
9
|
+
} catch {
|
|
10
|
+
return r;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { t as parseJSON };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=parseJSON.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseJSON.js","names":[],"sources":["../../src/object/parseJSON.ts"],"sourcesContent":["import { isNil } from '../guards/isNil';\n\nexport type ParseJSONOptions<T> = {\n fallback?: T;\n reviver?: (key: string, value: unknown) => unknown;\n validator?: (parsed: unknown) => boolean;\n};\n\n/**\n * Parses a JSON string and returns the resulting value.\n * `null` and `undefined` inputs return `fallback` without throwing.\n *\n * @example\n * ```ts\n * parseJSON<Record<string, number>>('{\"a\":1}'); // { a: 1 }\n * parseJSON('bad json', { fallback: {} }); // {}\n * parseJSON(null, { fallback: 0 }); // 0\n *\n * // With a validator — returns fallback when validation fails\n * parseJSON('{\"id\":\"bad\"}', {\n * validator: (v) => typeof (v as Record<string, unknown>).id === 'number',\n * fallback: { id: 0 },\n * }); // { id: 0 }\n * ```\n *\n * @template T - The expected type of the parsed JSON.\n * @param json - The JSON string to parse. `null` / `undefined` return `fallback`.\n * @param [options.fallback] - Value to return when parsing fails, input is nullish, or validation fails.\n * @param [options.reviver] - Optional reviver function for `JSON.parse`.\n * @param [options.validator] - Optional predicate; if it returns `false`, `fallback` is returned.\n *\n * @returns The parsed value, or `fallback` on failure.\n */\nexport function parseJSON<T = unknown>(\n json: string | null | undefined,\n options: ParseJSONOptions<T> = {},\n): T | undefined {\n const { fallback, reviver, validator } = options;\n\n if (isNil(json)) return fallback;\n\n try {\n const value = JSON.parse(json, reviver as Parameters<typeof JSON.parse>[1]) as unknown;\n\n if (value === undefined) return fallback;\n\n if (validator && !validator(value)) return fallback;\n\n return value as T | undefined;\n } catch {\n return fallback;\n }\n}\n"],"mappings":";;AAiCA,SAAgB,EACd,GACA,IAA+B,CAAC,GACjB;CACf,IAAM,EAAE,aAAU,YAAS,iBAAc;CAEzC,IAAI,EAAM,CAAI,GAAG,OAAO;CAExB,IAAI;EACF,IAAM,IAAQ,KAAK,MAAM,GAAM,CAA2C;EAM1E,OAJI,MAAU,KAAA,KAEV,KAAa,CAAC,EAAU,CAAK,IAAU,IAEpC;CACT,QAAQ;EACN,OAAO;CACT;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pick.cjs","names":[],"sources":["../../src/object/pick.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\n\n/**\n * Creates a new object containing only selected keys. Only `obj`'s own enumerable keys are\n * considered — inherited properties (e.g. `toString`) are never picked, and dangerous keys\n * (`__proto__`, `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * pick({ a: 1, b: 2, c: 3 }, ['a', 'c']); // { a: 1, c: 3 }\n * ```\n *\n * @param obj - The source object.\n * @param selectedKeys - The keys to keep.\n * @returns A new object containing only `selectedKeys` that exist as own properties of `obj`.\n */\nexport function pick<T extends Obj, K extends keyof T>(obj: T, selectedKeys: readonly K[]): Pick<T, K> {\n const out = {} as Pick<T, K>;\n\n for (const key of selectedKeys) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (Object.hasOwn(obj, key)) {\n out[key] = obj[key];\n }\n }\n\n return out;\n}\n"],"mappings":"8CAkBA,SAAgB,EAAuC,EAAQ,EAAwC,CACrG,IAAM,EAAM,CAAC,EAEb,IAAK,IAAM,KAAO,EACZ,EAAA,YAAY,CAAkB,GAE9B,OAAO,OAAO,EAAK,CAAG,IACxB,EAAI,GAAO,EAAI,IAInB,OAAO,CACT"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Obj } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new object containing only selected keys. Only `obj`'s own enumerable keys are
|
|
4
|
+
* considered — inherited properties (e.g. `toString`) are never picked, and dangerous keys
|
|
5
|
+
* (`__proto__`, `constructor`, `prototype`) are always skipped.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* pick({ a: 1, b: 2, c: 3 }, ['a', 'c']); // { a: 1, c: 3 }
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @param obj - The source object.
|
|
13
|
+
* @param selectedKeys - The keys to keep.
|
|
14
|
+
* @returns A new object containing only `selectedKeys` that exist as own properties of `obj`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function pick<T extends Obj, K extends keyof T>(obj: T, selectedKeys: readonly K[]): Pick<T, K>;
|
|
17
|
+
//# sourceMappingURL=pick.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pick.d.ts","sourceRoot":"","sources":["../../src/object/pick.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAIpC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,YAAY,EAAE,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAYrG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isUnsafeKey as e } from "../_common/unsafePaths.js";
|
|
2
|
+
//#region src/object/pick.ts
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
let r = {};
|
|
5
|
+
for (let i of n) e(i) || Object.hasOwn(t, i) && (r[i] = t[i]);
|
|
6
|
+
return r;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { t as pick };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=pick.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pick.js","names":[],"sources":["../../src/object/pick.ts"],"sourcesContent":["import type { Obj } from '../types';\n\nimport { isUnsafeKey } from '../_common/unsafePaths';\n\n/**\n * Creates a new object containing only selected keys. Only `obj`'s own enumerable keys are\n * considered — inherited properties (e.g. `toString`) are never picked, and dangerous keys\n * (`__proto__`, `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * pick({ a: 1, b: 2, c: 3 }, ['a', 'c']); // { a: 1, c: 3 }\n * ```\n *\n * @param obj - The source object.\n * @param selectedKeys - The keys to keep.\n * @returns A new object containing only `selectedKeys` that exist as own properties of `obj`.\n */\nexport function pick<T extends Obj, K extends keyof T>(obj: T, selectedKeys: readonly K[]): Pick<T, K> {\n const out = {} as Pick<T, K>;\n\n for (const key of selectedKeys) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n if (Object.hasOwn(obj, key)) {\n out[key] = obj[key];\n }\n }\n\n return out;\n}\n"],"mappings":";;AAkBA,SAAgB,EAAuC,GAAQ,GAAwC;CACrG,IAAM,IAAM,CAAC;CAEb,KAAK,IAAM,KAAO,GACZ,EAAY,CAAkB,KAE9B,OAAO,OAAO,GAAK,CAAG,MACxB,EAAI,KAAO,EAAI;CAInB,OAAO;AACT"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../guards/isString.cjs"),t=require("../_common/unsafePaths.cjs"),n=require("../array/filterMap.cjs"),r=require("../guards/isNil.cjs"),i=require("../guards/isPlainObject.cjs"),a=require("../guards/isEmpty.cjs");function o(s){if(!r.isNil(s)){if(e.isString(s)){let e=s.trim();return e===``?void 0:e}if(Array.isArray(s)){let e=n.filterMap(s,e=>{let t=o(e);return a.isEmpty(t)?void 0:t});return e.length===0?void 0:e}if(i.isPlainObject(s)){let e={};for(let[n,r]of Object.entries(s)){if(t.isUnsafeKey(n))continue;let i=o(r);a.isEmpty(i)||(e[n]=i)}return Object.keys(e).length===0?void 0:e}return s}}exports.prune=o;
|
|
2
|
+
//# sourceMappingURL=prune.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prune.cjs","names":[],"sources":["../../src/object/prune.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport { filterMap } from '../array/filterMap';\nimport { isEmpty } from '../guards/isEmpty';\nimport { isNil } from '../guards/isNil';\nimport { isPlainObject } from '../guards/isPlainObject';\nimport { isString } from '../guards/isString';\n\n/**\n * Removes all nullable and empty values from strings, arrays, or objects.\n *\n * - For strings: trims whitespace and returns `undefined` if the result is empty.\n * - For arrays: recursively removes `null`, `undefined`, empty strings, and empty objects/arrays.\n * - For objects: recursively removes properties whose pruned value is empty. Dangerous keys\n * (`__proto__`, `constructor`, `prototype`) are always skipped.\n * - For any other type: returns the value unchanged.\n *\n * @example\n * ```ts\n * prune(' hello '); // 'hello'\n * prune(' '); // undefined\n * prune([1, null, '', 2, undefined, 3]); // [1, 2, 3]\n * prune({ a: 1, b: null, c: '', d: 2 }); // { a: 1, d: 2 }\n * prune({ a: { b: null, c: '' }, d: 1 }); // { d: 1 }\n * ```\n *\n * @param value - The value to prune.\n * @returns The pruned value, or `undefined` if the result would be empty.\n */\nexport function prune(value: string): string | undefined;\nexport function prune<T>(value: T[]): Array<NonNullable<T>> | undefined;\nexport function prune<T extends Record<string, unknown>>(value: T): Partial<T> | undefined;\nexport function prune<T>(value: T): T | undefined;\nexport function prune<T>(value: T): T | undefined {\n if (isNil(value)) return undefined;\n\n if (isString(value)) {\n const trimmed = value.trim();\n\n return (trimmed === '' ? undefined : trimmed) as T | undefined;\n }\n\n if (Array.isArray(value)) {\n const cleaned = filterMap(value as unknown[], (item) => {\n const pruned = prune(item);\n\n return isEmpty(pruned) ? undefined : (pruned as unknown);\n });\n\n return (cleaned.length === 0 ? undefined : cleaned) as T | undefined;\n }\n\n if (isPlainObject(value)) {\n const cleaned: Record<string, unknown> = {};\n\n for (const [key, val] of Object.entries(value)) {\n if (isUnsafeKey(key)) continue;\n\n const cleanedValue = prune(val);\n\n if (!isEmpty(cleanedValue)) {\n cleaned[key] = cleanedValue;\n }\n }\n\n return (Object.keys(cleaned).length === 0 ? undefined : cleaned) as T | undefined;\n }\n\n return value;\n}\n"],"mappings":"mOAgCA,SAAgB,EAAS,EAAyB,CAC5C,MAAA,MAAM,CAAK,EAEf,IAAI,EAAA,SAAS,CAAK,EAAG,CACnB,IAAM,EAAU,EAAM,KAAK,EAE3B,OAAQ,IAAY,GAAK,IAAA,GAAY,CACvC,CAEA,GAAI,MAAM,QAAQ,CAAK,EAAG,CACxB,IAAM,EAAU,EAAA,UAAU,EAAqB,GAAS,CACtD,IAAM,EAAS,EAAM,CAAI,EAEzB,OAAO,EAAA,QAAQ,CAAM,EAAI,IAAA,GAAa,CACxC,CAAC,EAED,OAAQ,EAAQ,SAAW,EAAI,IAAA,GAAY,CAC7C,CAEA,GAAI,EAAA,cAAc,CAAK,EAAG,CACxB,IAAM,EAAmC,CAAC,EAE1C,IAAK,GAAM,CAAC,EAAK,KAAQ,OAAO,QAAQ,CAAK,EAAG,CAC9C,GAAI,EAAA,YAAY,CAAG,EAAG,SAEtB,IAAM,EAAe,EAAM,CAAG,EAEzB,EAAA,QAAQ,CAAY,IACvB,EAAQ,GAAO,EAEnB,CAEA,OAAQ,OAAO,KAAK,CAAO,CAAC,CAAC,SAAW,EAAI,IAAA,GAAY,CAC1D,CAEA,OAAO,CA5BP,CA6BF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes all nullable and empty values from strings, arrays, or objects.
|
|
3
|
+
*
|
|
4
|
+
* - For strings: trims whitespace and returns `undefined` if the result is empty.
|
|
5
|
+
* - For arrays: recursively removes `null`, `undefined`, empty strings, and empty objects/arrays.
|
|
6
|
+
* - For objects: recursively removes properties whose pruned value is empty. Dangerous keys
|
|
7
|
+
* (`__proto__`, `constructor`, `prototype`) are always skipped.
|
|
8
|
+
* - For any other type: returns the value unchanged.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* prune(' hello '); // 'hello'
|
|
13
|
+
* prune(' '); // undefined
|
|
14
|
+
* prune([1, null, '', 2, undefined, 3]); // [1, 2, 3]
|
|
15
|
+
* prune({ a: 1, b: null, c: '', d: 2 }); // { a: 1, d: 2 }
|
|
16
|
+
* prune({ a: { b: null, c: '' }, d: 1 }); // { d: 1 }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param value - The value to prune.
|
|
20
|
+
* @returns The pruned value, or `undefined` if the result would be empty.
|
|
21
|
+
*/
|
|
22
|
+
export declare function prune(value: string): string | undefined;
|
|
23
|
+
export declare function prune<T>(value: T[]): Array<NonNullable<T>> | undefined;
|
|
24
|
+
export declare function prune<T extends Record<string, unknown>>(value: T): Partial<T> | undefined;
|
|
25
|
+
export declare function prune<T>(value: T): T | undefined;
|
|
26
|
+
//# sourceMappingURL=prune.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prune.d.ts","sourceRoot":"","sources":["../../src/object/prune.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AACzD,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;AACxE,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;AAC3F,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { isString as e } from "../guards/isString.js";
|
|
2
|
+
import { isUnsafeKey as t } from "../_common/unsafePaths.js";
|
|
3
|
+
import { filterMap as n } from "../array/filterMap.js";
|
|
4
|
+
import { isNil as r } from "../guards/isNil.js";
|
|
5
|
+
import { isPlainObject as i } from "../guards/isPlainObject.js";
|
|
6
|
+
import { isEmpty as a } from "../guards/isEmpty.js";
|
|
7
|
+
//#region src/object/prune.ts
|
|
8
|
+
function o(s) {
|
|
9
|
+
if (!r(s)) {
|
|
10
|
+
if (e(s)) {
|
|
11
|
+
let e = s.trim();
|
|
12
|
+
return e === "" ? void 0 : e;
|
|
13
|
+
}
|
|
14
|
+
if (Array.isArray(s)) {
|
|
15
|
+
let e = n(s, (e) => {
|
|
16
|
+
let t = o(e);
|
|
17
|
+
return a(t) ? void 0 : t;
|
|
18
|
+
});
|
|
19
|
+
return e.length === 0 ? void 0 : e;
|
|
20
|
+
}
|
|
21
|
+
if (i(s)) {
|
|
22
|
+
let e = {};
|
|
23
|
+
for (let [n, r] of Object.entries(s)) {
|
|
24
|
+
if (t(n)) continue;
|
|
25
|
+
let i = o(r);
|
|
26
|
+
a(i) || (e[n] = i);
|
|
27
|
+
}
|
|
28
|
+
return Object.keys(e).length === 0 ? void 0 : e;
|
|
29
|
+
}
|
|
30
|
+
return s;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { o as prune };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=prune.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prune.js","names":[],"sources":["../../src/object/prune.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport { filterMap } from '../array/filterMap';\nimport { isEmpty } from '../guards/isEmpty';\nimport { isNil } from '../guards/isNil';\nimport { isPlainObject } from '../guards/isPlainObject';\nimport { isString } from '../guards/isString';\n\n/**\n * Removes all nullable and empty values from strings, arrays, or objects.\n *\n * - For strings: trims whitespace and returns `undefined` if the result is empty.\n * - For arrays: recursively removes `null`, `undefined`, empty strings, and empty objects/arrays.\n * - For objects: recursively removes properties whose pruned value is empty. Dangerous keys\n * (`__proto__`, `constructor`, `prototype`) are always skipped.\n * - For any other type: returns the value unchanged.\n *\n * @example\n * ```ts\n * prune(' hello '); // 'hello'\n * prune(' '); // undefined\n * prune([1, null, '', 2, undefined, 3]); // [1, 2, 3]\n * prune({ a: 1, b: null, c: '', d: 2 }); // { a: 1, d: 2 }\n * prune({ a: { b: null, c: '' }, d: 1 }); // { d: 1 }\n * ```\n *\n * @param value - The value to prune.\n * @returns The pruned value, or `undefined` if the result would be empty.\n */\nexport function prune(value: string): string | undefined;\nexport function prune<T>(value: T[]): Array<NonNullable<T>> | undefined;\nexport function prune<T extends Record<string, unknown>>(value: T): Partial<T> | undefined;\nexport function prune<T>(value: T): T | undefined;\nexport function prune<T>(value: T): T | undefined {\n if (isNil(value)) return undefined;\n\n if (isString(value)) {\n const trimmed = value.trim();\n\n return (trimmed === '' ? undefined : trimmed) as T | undefined;\n }\n\n if (Array.isArray(value)) {\n const cleaned = filterMap(value as unknown[], (item) => {\n const pruned = prune(item);\n\n return isEmpty(pruned) ? undefined : (pruned as unknown);\n });\n\n return (cleaned.length === 0 ? undefined : cleaned) as T | undefined;\n }\n\n if (isPlainObject(value)) {\n const cleaned: Record<string, unknown> = {};\n\n for (const [key, val] of Object.entries(value)) {\n if (isUnsafeKey(key)) continue;\n\n const cleanedValue = prune(val);\n\n if (!isEmpty(cleanedValue)) {\n cleaned[key] = cleanedValue;\n }\n }\n\n return (Object.keys(cleaned).length === 0 ? undefined : cleaned) as T | undefined;\n }\n\n return value;\n}\n"],"mappings":";;;;;;;AAgCA,SAAgB,EAAS,GAAyB;CAC5C,OAAM,CAAK,GAEf;MAAI,EAAS,CAAK,GAAG;GACnB,IAAM,IAAU,EAAM,KAAK;GAE3B,OAAQ,MAAY,KAAK,KAAA,IAAY;EACvC;EAEA,IAAI,MAAM,QAAQ,CAAK,GAAG;GACxB,IAAM,IAAU,EAAU,IAAqB,MAAS;IACtD,IAAM,IAAS,EAAM,CAAI;IAEzB,OAAO,EAAQ,CAAM,IAAI,KAAA,IAAa;GACxC,CAAC;GAED,OAAQ,EAAQ,WAAW,IAAI,KAAA,IAAY;EAC7C;EAEA,IAAI,EAAc,CAAK,GAAG;GACxB,IAAM,IAAmC,CAAC;GAE1C,KAAK,IAAM,CAAC,GAAK,MAAQ,OAAO,QAAQ,CAAK,GAAG;IAC9C,IAAI,EAAY,CAAG,GAAG;IAEtB,IAAM,IAAe,EAAM,CAAG;IAE9B,AAAK,EAAQ,CAAY,MACvB,EAAQ,KAAO;GAEnB;GAEA,OAAQ,OAAO,KAAK,CAAO,CAAC,CAAC,WAAW,IAAI,KAAA,IAAY;EAC1D;EAEA,OAAO;CA5BP;AA6BF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../_common/_secureRandomIndex.cjs"),t=require("./random.cjs");function n(e){if(e.length!==0)return e[t.random(0,e.length-1)]}function r(t,n){let r=Math.max(0,Math.min(t.length,Math.floor(n)));if(r===0)return[];if(r===t.length)return[...t];let i=[...t];for(let t=i.length-1;t>0;t--){let n=e.secureRandomIndex(t+1),r=i[t];i[t]=i[n],i[n]=r}return i.slice(0,r)}exports.draw=n,exports.drawMany=r;
|
|
2
|
+
//# sourceMappingURL=draw.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draw.cjs","names":[],"sources":["../../src/random/draw.ts"],"sourcesContent":["import { secureRandomIndex } from '../_common/_secureRandomIndex';\nimport { random } from './random';\n\n/**\n * Picks a single random item from an array.\n * Returns `undefined` if the array is empty.\n *\n * @example\n * ```ts\n * draw([1, 2, 3]); // e.g. 2\n * draw([]); // undefined\n * ```\n */\nexport function draw<T>(array: T[]): T | undefined {\n if (array.length === 0) return undefined;\n\n return array[random(0, array.length - 1)];\n}\n\n/**\n * Picks up to `n` unique random items from an array using a cryptographically\n * random shuffle (Fisher-Yates via `crypto.getRandomValues`).\n * Returns a new array; does not mutate the input.\n *\n * @example\n * ```ts\n * drawMany([1, 2, 3, 4, 5], 3); // e.g. [4, 1, 3]\n * drawMany([1, 2], 10); // [1, 2] (clamped to array length)\n * ```\n */\nexport function drawMany<T>(array: T[], n: number): T[] {\n const count = Math.max(0, Math.min(array.length, Math.floor(n)));\n\n if (count === 0) return [];\n\n if (count === array.length) return [...array];\n\n const copy = [...array];\n\n for (let index = copy.length - 1; index > 0; index--) {\n const randomIndex = secureRandomIndex(index + 1);\n const temp = copy[index];\n\n copy[index] = copy[randomIndex]!;\n copy[randomIndex] = temp!;\n }\n\n return copy.slice(0, count);\n}\n"],"mappings":"+EAaA,SAAgB,EAAQ,EAA2B,CAC7C,KAAM,SAAW,EAErB,OAAO,EAAM,EAAA,OAAO,EAAG,EAAM,OAAS,CAAC,EACzC,CAaA,SAAgB,EAAY,EAAY,EAAgB,CACtD,IAAM,EAAQ,KAAK,IAAI,EAAG,KAAK,IAAI,EAAM,OAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,EAE/D,GAAI,IAAU,EAAG,MAAO,CAAC,EAEzB,GAAI,IAAU,EAAM,OAAQ,MAAO,CAAC,GAAG,CAAK,EAE5C,IAAM,EAAO,CAAC,GAAG,CAAK,EAEtB,IAAK,IAAI,EAAQ,EAAK,OAAS,EAAG,EAAQ,EAAG,IAAS,CACpD,IAAM,EAAc,EAAA,kBAAkB,EAAQ,CAAC,EACzC,EAAO,EAAK,GAElB,EAAK,GAAS,EAAK,GACnB,EAAK,GAAe,CACtB,CAEA,OAAO,EAAK,MAAM,EAAG,CAAK,CAC5B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Picks a single random item from an array.
|
|
3
|
+
* Returns `undefined` if the array is empty.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* draw([1, 2, 3]); // e.g. 2
|
|
8
|
+
* draw([]); // undefined
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function draw<T>(array: T[]): T | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Picks up to `n` unique random items from an array using a cryptographically
|
|
14
|
+
* random shuffle (Fisher-Yates via `crypto.getRandomValues`).
|
|
15
|
+
* Returns a new array; does not mutate the input.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* drawMany([1, 2, 3, 4, 5], 3); // e.g. [4, 1, 3]
|
|
20
|
+
* drawMany([1, 2], 10); // [1, 2] (clamped to array length)
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function drawMany<T>(array: T[], n: number): T[];
|
|
24
|
+
//# sourceMappingURL=draw.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draw.d.ts","sourceRoot":"","sources":["../../src/random/draw.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,SAAS,CAIjD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,CAkBtD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { secureRandomIndex as e } from "../_common/_secureRandomIndex.js";
|
|
2
|
+
import { random as t } from "./random.js";
|
|
3
|
+
//#region src/random/draw.ts
|
|
4
|
+
function n(e) {
|
|
5
|
+
if (e.length !== 0) return e[t(0, e.length - 1)];
|
|
6
|
+
}
|
|
7
|
+
function r(t, n) {
|
|
8
|
+
let r = Math.max(0, Math.min(t.length, Math.floor(n)));
|
|
9
|
+
if (r === 0) return [];
|
|
10
|
+
if (r === t.length) return [...t];
|
|
11
|
+
let i = [...t];
|
|
12
|
+
for (let t = i.length - 1; t > 0; t--) {
|
|
13
|
+
let n = e(t + 1), r = i[t];
|
|
14
|
+
i[t] = i[n], i[n] = r;
|
|
15
|
+
}
|
|
16
|
+
return i.slice(0, r);
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { n as draw, r as drawMany };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=draw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draw.js","names":[],"sources":["../../src/random/draw.ts"],"sourcesContent":["import { secureRandomIndex } from '../_common/_secureRandomIndex';\nimport { random } from './random';\n\n/**\n * Picks a single random item from an array.\n * Returns `undefined` if the array is empty.\n *\n * @example\n * ```ts\n * draw([1, 2, 3]); // e.g. 2\n * draw([]); // undefined\n * ```\n */\nexport function draw<T>(array: T[]): T | undefined {\n if (array.length === 0) return undefined;\n\n return array[random(0, array.length - 1)];\n}\n\n/**\n * Picks up to `n` unique random items from an array using a cryptographically\n * random shuffle (Fisher-Yates via `crypto.getRandomValues`).\n * Returns a new array; does not mutate the input.\n *\n * @example\n * ```ts\n * drawMany([1, 2, 3, 4, 5], 3); // e.g. [4, 1, 3]\n * drawMany([1, 2], 10); // [1, 2] (clamped to array length)\n * ```\n */\nexport function drawMany<T>(array: T[], n: number): T[] {\n const count = Math.max(0, Math.min(array.length, Math.floor(n)));\n\n if (count === 0) return [];\n\n if (count === array.length) return [...array];\n\n const copy = [...array];\n\n for (let index = copy.length - 1; index > 0; index--) {\n const randomIndex = secureRandomIndex(index + 1);\n const temp = copy[index];\n\n copy[index] = copy[randomIndex]!;\n copy[randomIndex] = temp!;\n }\n\n return copy.slice(0, count);\n}\n"],"mappings":";;;AAaA,SAAgB,EAAQ,GAA2B;CAC7C,MAAM,WAAW,GAErB,OAAO,EAAM,EAAO,GAAG,EAAM,SAAS,CAAC;AACzC;AAaA,SAAgB,EAAY,GAAY,GAAgB;CACtD,IAAM,IAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,EAAM,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC;CAE/D,IAAI,MAAU,GAAG,OAAO,CAAC;CAEzB,IAAI,MAAU,EAAM,QAAQ,OAAO,CAAC,GAAG,CAAK;CAE5C,IAAM,IAAO,CAAC,GAAG,CAAK;CAEtB,KAAK,IAAI,IAAQ,EAAK,SAAS,GAAG,IAAQ,GAAG,KAAS;EACpD,IAAM,IAAc,EAAkB,IAAQ,CAAC,GACzC,IAAO,EAAK;EAGlB,AADA,EAAK,KAAS,EAAK,IACnB,EAAK,KAAe;CACtB;CAEA,OAAO,EAAK,MAAM,GAAG,CAAK;AAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/random/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("../errors.cjs"),t=require("../_common/_secureRandomIndex.cjs");function n(n,r){if(n>r)throw new e.ArsenalValidationError(`random: minimum value must not be greater than maximum value`);return t.secureRandomIndex(r-n+1)+n}exports.random=n;
|
|
2
|
+
//# sourceMappingURL=random.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"random.cjs","names":[],"sources":["../../src/random/random.ts"],"sourcesContent":["import { secureRandomIndex } from '../_common/_secureRandomIndex';\nimport { ArsenalValidationError } from '../errors';\n\n/**\n * Generates a random integer between two values, inclusive.\n *\n * @example\n * ```ts\n * random(1, 10); // a random integer between 1 and 10\n * ```\n *\n * @param min - The minimum value.\n * @param max - The maximum value.\n * @returns A random integer between min and max.\n */\nexport function random(min: number, max: number): number {\n if (min > max) throw new ArsenalValidationError('random: minimum value must not be greater than maximum value');\n\n return secureRandomIndex(max - min + 1) + min;\n}\n"],"mappings":"gFAeA,SAAgB,EAAO,EAAa,EAAqB,CACvD,GAAI,EAAM,EAAK,MAAM,IAAI,EAAA,uBAAuB,8DAA8D,EAE9G,OAAO,EAAA,kBAAkB,EAAM,EAAM,CAAC,EAAI,CAC5C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a random integer between two values, inclusive.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* random(1, 10); // a random integer between 1 and 10
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* @param min - The minimum value.
|
|
10
|
+
* @param max - The maximum value.
|
|
11
|
+
* @returns A random integer between min and max.
|
|
12
|
+
*/
|
|
13
|
+
export declare function random(min: number, max: number): number;
|
|
14
|
+
//# sourceMappingURL=random.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../src/random/random.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAIvD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ArsenalValidationError as e } from "../errors.js";
|
|
2
|
+
import { secureRandomIndex as t } from "../_common/_secureRandomIndex.js";
|
|
3
|
+
//#region src/random/random.ts
|
|
4
|
+
function n(n, r) {
|
|
5
|
+
if (n > r) throw new e("random: minimum value must not be greater than maximum value");
|
|
6
|
+
return t(r - n + 1) + n;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { n as random };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=random.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"random.js","names":[],"sources":["../../src/random/random.ts"],"sourcesContent":["import { secureRandomIndex } from '../_common/_secureRandomIndex';\nimport { ArsenalValidationError } from '../errors';\n\n/**\n * Generates a random integer between two values, inclusive.\n *\n * @example\n * ```ts\n * random(1, 10); // a random integer between 1 and 10\n * ```\n *\n * @param min - The minimum value.\n * @param max - The maximum value.\n * @returns A random integer between min and max.\n */\nexport function random(min: number, max: number): number {\n if (min > max) throw new ArsenalValidationError('random: minimum value must not be greater than maximum value');\n\n return secureRandomIndex(max - min + 1) + min;\n}\n"],"mappings":";;;AAeA,SAAgB,EAAO,GAAa,GAAqB;CACvD,IAAI,IAAM,GAAK,MAAM,IAAI,EAAuB,8DAA8D;CAE9G,OAAO,EAAkB,IAAM,IAAM,CAAC,IAAI;AAC5C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shuffle.cjs","names":[],"sources":["../../src/random/shuffle.ts"],"sourcesContent":["import { secureRandomIndex } from '../_common/_secureRandomIndex';\n\n/**\n * Returns a new randomly-shuffled copy of the array using Fisher-Yates\n * with `crypto.getRandomValues`. Does not mutate the input.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4];\n * shuffle(arr); // e.g. [3, 1, 4, 2]\n * ```\n */\nexport function shuffle<T>(array: T[]): T[] {\n const result = [...array];\n\n for (let i = result.length - 1; i > 0; i--) {\n const j = secureRandomIndex(i + 1);\n\n [result[i], result[j]] = [result[j], result[i]];\n }\n\n return result;\n}\n"],"mappings":"qDAYA,SAAgB,EAAW,EAAiB,CAC1C,IAAM,EAAS,CAAC,GAAG,CAAK,EAExB,IAAK,IAAI,EAAI,EAAO,OAAS,EAAG,EAAI,EAAG,IAAK,CAC1C,IAAM,EAAI,EAAA,kBAAkB,EAAI,CAAC,EAEjC,CAAC,EAAO,GAAI,EAAO,IAAM,CAAC,EAAO,GAAI,EAAO,EAAE,CAChD,CAEA,OAAO,CACT"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a new randomly-shuffled copy of the array using Fisher-Yates
|
|
3
|
+
* with `crypto.getRandomValues`. Does not mutate the input.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* const arr = [1, 2, 3, 4];
|
|
8
|
+
* shuffle(arr); // e.g. [3, 1, 4, 2]
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function shuffle<T>(array: T[]): T[];
|
|
12
|
+
//# sourceMappingURL=shuffle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shuffle.d.ts","sourceRoot":"","sources":["../../src/random/shuffle.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAU1C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { secureRandomIndex as e } from "../_common/_secureRandomIndex.js";
|
|
2
|
+
//#region src/random/shuffle.ts
|
|
3
|
+
function t(t) {
|
|
4
|
+
let n = [...t];
|
|
5
|
+
for (let t = n.length - 1; t > 0; t--) {
|
|
6
|
+
let r = e(t + 1);
|
|
7
|
+
[n[t], n[r]] = [n[r], n[t]];
|
|
8
|
+
}
|
|
9
|
+
return n;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { t as shuffle };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=shuffle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shuffle.js","names":[],"sources":["../../src/random/shuffle.ts"],"sourcesContent":["import { secureRandomIndex } from '../_common/_secureRandomIndex';\n\n/**\n * Returns a new randomly-shuffled copy of the array using Fisher-Yates\n * with `crypto.getRandomValues`. Does not mutate the input.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4];\n * shuffle(arr); // e.g. [3, 1, 4, 2]\n * ```\n */\nexport function shuffle<T>(array: T[]): T[] {\n const result = [...array];\n\n for (let i = result.length - 1; i > 0; i--) {\n const j = secureRandomIndex(i + 1);\n\n [result[i], result[j]] = [result[j], result[i]];\n }\n\n return result;\n}\n"],"mappings":";;AAYA,SAAgB,EAAW,GAAiB;CAC1C,IAAM,IAAS,CAAC,GAAG,CAAK;CAExB,KAAK,IAAI,IAAI,EAAO,SAAS,GAAG,IAAI,GAAG,KAAK;EAC1C,IAAM,IAAI,EAAkB,IAAI,CAAC;EAEjC,CAAC,EAAO,IAAI,EAAO,MAAM,CAAC,EAAO,IAAI,EAAO,EAAE;CAChD;CAEA,OAAO;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid.cjs","names":[],"sources":["../../src/random/uuid.ts"],"sourcesContent":["/**\n * Generates a unique identifier.\n *\n * @example\n * ```ts\n * uuid(); // a unique identifier, e.g., '22a746d0-08be-4aff-bbc2-4deddf0914e0'\n * ```\n *\n * @returns A unique identifier.\n */\nexport function uuid(): string {\n return crypto.randomUUID();\n}\n"],"mappings":"AAUA,SAAgB,GAAe,CAC7B,OAAO,OAAO,WAAW,CAC3B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a unique identifier.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* uuid(); // a unique identifier, e.g., '22a746d0-08be-4aff-bbc2-4deddf0914e0'
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* @returns A unique identifier.
|
|
10
|
+
*/
|
|
11
|
+
export declare function uuid(): string;
|
|
12
|
+
//# sourceMappingURL=uuid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../src/random/uuid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,IAAI,IAAI,MAAM,CAE7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid.js","names":[],"sources":["../../src/random/uuid.ts"],"sourcesContent":["/**\n * Generates a unique identifier.\n *\n * @example\n * ```ts\n * uuid(); // a unique identifier, e.g., '22a746d0-08be-4aff-bbc2-4deddf0914e0'\n * ```\n *\n * @returns A unique identifier.\n */\nexport function uuid(): string {\n return crypto.randomUUID();\n}\n"],"mappings":";AAUA,SAAgB,IAAe;CAC7B,OAAO,OAAO,WAAW;AAC3B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=/(\p{Ll})(\p{Lu}|\p{N})|(\p{Lu}|\p{N})(\p{Lu}\p{Ll})|(\p{N})(\p{L})/gu;function t(e){return e.replace(/[.*+?^${}()|[\]\\/-]/g,`\\$&`)}function n(n,r=` `){let i=t(r);return n.trim().replace(e,`$1$3$5${r}$2$4$6`).replace(/[^\p{L}\p{N}]+/gu,r).replace(RegExp(`^(?:${i})+|(?:${i})+$`,`g`),``)}exports.normalizeCase=n;
|
|
2
|
+
//# sourceMappingURL=_caseUtils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_caseUtils.cjs","names":[],"sources":["../../src/string/_caseUtils.ts"],"sourcesContent":["/**\n * Shared regex pattern for splitting words in case conversion utilities.\n * Module-private (underscore-prefixed file is not barrel-exported).\n * Used only with String.prototype.replace — which always resets lastIndex.\n * Uses Unicode property escapes (`\\p{Ll}`/`\\p{Lu}`/`\\p{N}`) instead of `[a-z]`/`[A-Z]` so\n * accented and non-Latin letters (e.g. `café`, `日本語`) are treated as letters, not stripped.\n */\nconst CASE_SPLIT_PATTERN = /(\\p{Ll})(\\p{Lu}|\\p{N})|(\\p{Lu}|\\p{N})(\\p{Lu}\\p{Ll})|(\\p{N})(\\p{L})/gu;\n\n/** Escapes all regex metacharacters in a string (per MDN spec). */\nfunction escapeRegex(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\/-]/g, '\\\\$&');\n}\n\n/**\n * Normalizes a string by splitting on word boundaries and removing special characters\n *\n * @param str - The string to normalize\n * @param separator - The separator to use for splitting (default: space)\n * @returns The normalized string\n */\nexport function normalizeCase(str: string, separator = ' '): string {\n const escapedSep = escapeRegex(separator);\n\n return str\n .trim()\n .replace(CASE_SPLIT_PATTERN, `$1$3$5${separator}$2$4$6`)\n .replace(/[^\\p{L}\\p{N}]+/gu, separator)\n .replace(new RegExp(`^(?:${escapedSep})+|(?:${escapedSep})+$`, 'g'), '');\n}\n"],"mappings":"AAOA,IAAM,EAAqB,uEAG3B,SAAS,EAAY,EAAqB,CACxC,OAAO,EAAI,QAAQ,wBAAyB,MAAM,CACpD,CASA,SAAgB,EAAc,EAAa,EAAY,IAAa,CAClE,IAAM,EAAa,EAAY,CAAS,EAExC,OAAO,EACJ,KAAK,CAAC,CACN,QAAQ,EAAoB,SAAS,EAAU,OAAO,CAAC,CACvD,QAAQ,mBAAoB,CAAS,CAAC,CACtC,QAAY,OAAO,OAAO,EAAW,QAAQ,EAAW,KAAM,GAAG,EAAG,EAAE,CAC3E"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes a string by splitting on word boundaries and removing special characters
|
|
3
|
+
*
|
|
4
|
+
* @param str - The string to normalize
|
|
5
|
+
* @param separator - The separator to use for splitting (default: space)
|
|
6
|
+
* @returns The normalized string
|
|
7
|
+
*/
|
|
8
|
+
export declare function normalizeCase(str: string, separator?: string): string;
|
|
9
|
+
//# sourceMappingURL=_caseUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_caseUtils.d.ts","sourceRoot":"","sources":["../../src/string/_caseUtils.ts"],"names":[],"mappings":"AAcA;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,SAAM,GAAG,MAAM,CAQlE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/string/_caseUtils.ts
|
|
2
|
+
var e = /(\p{Ll})(\p{Lu}|\p{N})|(\p{Lu}|\p{N})(\p{Lu}\p{Ll})|(\p{N})(\p{L})/gu;
|
|
3
|
+
function t(e) {
|
|
4
|
+
return e.replace(/[.*+?^${}()|[\]\\/-]/g, "\\$&");
|
|
5
|
+
}
|
|
6
|
+
function n(n, r = " ") {
|
|
7
|
+
let i = t(r);
|
|
8
|
+
return n.trim().replace(e, `$1$3$5${r}$2$4$6`).replace(/[^\p{L}\p{N}]+/gu, r).replace(RegExp(`^(?:${i})+|(?:${i})+$`, "g"), "");
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { n as normalizeCase };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=_caseUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_caseUtils.js","names":[],"sources":["../../src/string/_caseUtils.ts"],"sourcesContent":["/**\n * Shared regex pattern for splitting words in case conversion utilities.\n * Module-private (underscore-prefixed file is not barrel-exported).\n * Used only with String.prototype.replace — which always resets lastIndex.\n * Uses Unicode property escapes (`\\p{Ll}`/`\\p{Lu}`/`\\p{N}`) instead of `[a-z]`/`[A-Z]` so\n * accented and non-Latin letters (e.g. `café`, `日本語`) are treated as letters, not stripped.\n */\nconst CASE_SPLIT_PATTERN = /(\\p{Ll})(\\p{Lu}|\\p{N})|(\\p{Lu}|\\p{N})(\\p{Lu}\\p{Ll})|(\\p{N})(\\p{L})/gu;\n\n/** Escapes all regex metacharacters in a string (per MDN spec). */\nfunction escapeRegex(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\/-]/g, '\\\\$&');\n}\n\n/**\n * Normalizes a string by splitting on word boundaries and removing special characters\n *\n * @param str - The string to normalize\n * @param separator - The separator to use for splitting (default: space)\n * @returns The normalized string\n */\nexport function normalizeCase(str: string, separator = ' '): string {\n const escapedSep = escapeRegex(separator);\n\n return str\n .trim()\n .replace(CASE_SPLIT_PATTERN, `$1$3$5${separator}$2$4$6`)\n .replace(/[^\\p{L}\\p{N}]+/gu, separator)\n .replace(new RegExp(`^(?:${escapedSep})+|(?:${escapedSep})+$`, 'g'), '');\n}\n"],"mappings":";AAOA,IAAM,IAAqB;AAG3B,SAAS,EAAY,GAAqB;CACxC,OAAO,EAAI,QAAQ,yBAAyB,MAAM;AACpD;AASA,SAAgB,EAAc,GAAa,IAAY,KAAa;CAClE,IAAM,IAAa,EAAY,CAAS;CAExC,OAAO,EACJ,KAAK,CAAC,CACN,QAAQ,GAAoB,SAAS,EAAU,OAAO,CAAC,CACvD,QAAQ,oBAAoB,CAAS,CAAC,CACtC,QAAY,OAAO,OAAO,EAAW,QAAQ,EAAW,MAAM,GAAG,GAAG,EAAE;AAC3E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camelCase.cjs","names":[],"sources":["../../src/string/camelCase.ts"],"sourcesContent":["import { normalizeCase } from './_caseUtils';\n\n/**\n * Converts a string to camel case.\n *\n * @example\n * ```ts\n * const text = 'hello world';\n * camelCase(text); // 'helloWorld'\n * ```\n *\n * @param str - The string to convert.\n * @returns The converted string.\n */\nexport function camelCase(str: string): string {\n return normalizeCase(str, ' ')\n .replace(/[^\\p{L}\\p{N}]+(.)/gu, (_, char) => char.toUpperCase())\n .replace(/^./, (char) => char.toLowerCase());\n}\n"],"mappings":"oCAcA,SAAgB,EAAU,EAAqB,CAC7C,OAAO,EAAA,cAAc,EAAK,GAAG,CAAC,CAC3B,QAAQ,uBAAwB,EAAG,IAAS,EAAK,YAAY,CAAC,CAAC,CAC/D,QAAQ,KAAO,GAAS,EAAK,YAAY,CAAC,CAC/C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a string to camel case.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* const text = 'hello world';
|
|
7
|
+
* camelCase(text); // 'helloWorld'
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @param str - The string to convert.
|
|
11
|
+
* @returns The converted string.
|
|
12
|
+
*/
|
|
13
|
+
export declare function camelCase(str: string): string;
|
|
14
|
+
//# sourceMappingURL=camelCase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camelCase.d.ts","sourceRoot":"","sources":["../../src/string/camelCase.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI7C"}
|