@vielzeug/arsenal 2.1.0 → 26.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -18
- package/dist/_common/_lruMap.cjs +1 -1
- package/dist/_common/_lruMap.cjs.map +1 -1
- package/dist/_common/_lruMap.js +1 -17
- package/dist/_common/_lruMap.js.map +1 -1
- package/dist/_common/_selectorSet.cjs +1 -1
- package/dist/_common/_selectorSet.cjs.map +1 -1
- package/dist/_common/_selectorSet.js +1 -15
- package/dist/_common/_selectorSet.js.map +1 -1
- package/dist/_common/unsafePaths.cjs +1 -1
- package/dist/_common/unsafePaths.cjs.map +1 -1
- package/dist/_common/unsafePaths.js +1 -12
- package/dist/_common/unsafePaths.js.map +1 -1
- package/dist/_dev.cjs +1 -1
- package/dist/_dev.cjs.map +1 -1
- package/dist/_dev.js +1 -5
- package/dist/_dev.js.map +1 -1
- package/dist/array/chunk.cjs +1 -1
- package/dist/array/chunk.cjs.map +1 -1
- package/dist/array/chunk.d.ts +1 -1
- package/dist/array/chunk.d.ts.map +1 -1
- package/dist/array/chunk.js +1 -9
- package/dist/array/chunk.js.map +1 -1
- package/dist/array/compact.cjs +1 -1
- package/dist/array/compact.cjs.map +1 -1
- package/dist/array/compact.d.ts +1 -1
- package/dist/array/compact.d.ts.map +1 -1
- package/dist/array/compact.js +1 -7
- package/dist/array/compact.js.map +1 -1
- package/dist/array/compare.cjs +1 -1
- package/dist/array/compare.cjs.map +1 -1
- package/dist/array/compare.js +1 -18
- package/dist/array/compare.js.map +1 -1
- package/dist/array/compareBy.cjs +1 -1
- package/dist/array/compareBy.cjs.map +1 -1
- package/dist/array/compareBy.js +1 -15
- package/dist/array/compareBy.js.map +1 -1
- package/dist/array/contains.cjs +1 -1
- package/dist/array/contains.cjs.map +1 -1
- package/dist/array/contains.d.ts +1 -1
- package/dist/array/contains.d.ts.map +1 -1
- package/dist/array/contains.js +1 -8
- package/dist/array/contains.js.map +1 -1
- package/dist/array/countBy.cjs +1 -1
- package/dist/array/countBy.cjs.map +1 -1
- package/dist/array/countBy.d.ts +1 -1
- package/dist/array/countBy.d.ts.map +1 -1
- package/dist/array/countBy.js +1 -13
- package/dist/array/countBy.js.map +1 -1
- package/dist/array/difference.cjs +1 -1
- package/dist/array/difference.cjs.map +1 -1
- package/dist/array/difference.d.ts +4 -2
- package/dist/array/difference.d.ts.map +1 -1
- package/dist/array/difference.js +1 -13
- package/dist/array/difference.js.map +1 -1
- package/dist/array/drop.cjs +1 -1
- package/dist/array/drop.cjs.map +1 -1
- package/dist/array/drop.d.ts +1 -1
- package/dist/array/drop.d.ts.map +1 -1
- package/dist/array/drop.js +1 -8
- package/dist/array/drop.js.map +1 -1
- package/dist/array/dropLast.cjs +1 -1
- package/dist/array/dropLast.cjs.map +1 -1
- package/dist/array/dropLast.d.ts +1 -1
- package/dist/array/dropLast.d.ts.map +1 -1
- package/dist/array/dropLast.js +1 -8
- package/dist/array/dropLast.js.map +1 -1
- package/dist/array/filterMap.cjs +1 -1
- package/dist/array/filterMap.cjs.map +1 -1
- package/dist/array/filterMap.d.ts +3 -1
- package/dist/array/filterMap.d.ts.map +1 -1
- package/dist/array/filterMap.js +1 -12
- package/dist/array/filterMap.js.map +1 -1
- package/dist/array/first.cjs +1 -1
- package/dist/array/first.cjs.map +1 -1
- package/dist/array/first.d.ts +1 -1
- package/dist/array/first.d.ts.map +1 -1
- package/dist/array/first.js +1 -7
- package/dist/array/first.js.map +1 -1
- package/dist/array/groupBy.cjs +1 -1
- package/dist/array/groupBy.cjs.map +1 -1
- package/dist/array/groupBy.d.ts +1 -1
- package/dist/array/groupBy.d.ts.map +1 -1
- package/dist/array/groupBy.js +1 -13
- package/dist/array/groupBy.js.map +1 -1
- package/dist/array/index.cjs +1 -1
- package/dist/array/index.d.ts +0 -1
- package/dist/array/index.d.ts.map +1 -1
- package/dist/array/index.js +1 -29
- package/dist/array/indexBy.cjs +1 -1
- package/dist/array/indexBy.cjs.map +1 -1
- package/dist/array/indexBy.d.ts +1 -1
- package/dist/array/indexBy.d.ts.map +1 -1
- package/dist/array/indexBy.js +1 -13
- package/dist/array/indexBy.js.map +1 -1
- package/dist/array/intersection.cjs +1 -1
- package/dist/array/intersection.cjs.map +1 -1
- package/dist/array/intersection.d.ts +4 -2
- package/dist/array/intersection.d.ts.map +1 -1
- package/dist/array/intersection.js +1 -13
- package/dist/array/intersection.js.map +1 -1
- package/dist/array/last.cjs +1 -1
- package/dist/array/last.cjs.map +1 -1
- package/dist/array/last.d.ts +1 -1
- package/dist/array/last.d.ts.map +1 -1
- package/dist/array/last.js +1 -7
- package/dist/array/last.js.map +1 -1
- package/dist/array/partition.cjs +1 -1
- package/dist/array/partition.cjs.map +1 -1
- package/dist/array/partition.d.ts +3 -1
- package/dist/array/partition.d.ts.map +1 -1
- package/dist/array/partition.js +1 -9
- package/dist/array/partition.js.map +1 -1
- package/dist/array/replace.cjs +1 -1
- package/dist/array/replace.cjs.map +1 -1
- package/dist/array/replace.d.ts +2 -15
- package/dist/array/replace.d.ts.map +1 -1
- package/dist/array/replace.js +1 -12
- package/dist/array/replace.js.map +1 -1
- package/dist/array/rotate.cjs +1 -1
- package/dist/array/rotate.cjs.map +1 -1
- package/dist/array/rotate.d.ts +5 -17
- package/dist/array/rotate.d.ts.map +1 -1
- package/dist/array/rotate.js +1 -9
- package/dist/array/rotate.js.map +1 -1
- package/dist/array/search.cjs +1 -1
- package/dist/array/search.cjs.map +1 -1
- package/dist/array/search.js +1 -29
- package/dist/array/search.js.map +1 -1
- package/dist/array/sort.cjs +1 -1
- package/dist/array/sort.cjs.map +1 -1
- package/dist/array/sort.d.ts +2 -2
- package/dist/array/sort.d.ts.map +1 -1
- package/dist/array/sort.js +1 -14
- package/dist/array/sort.js.map +1 -1
- package/dist/array/take.cjs +1 -1
- package/dist/array/take.cjs.map +1 -1
- package/dist/array/take.d.ts +1 -1
- package/dist/array/take.d.ts.map +1 -1
- package/dist/array/take.js +1 -8
- package/dist/array/take.js.map +1 -1
- package/dist/array/takeLast.cjs +1 -1
- package/dist/array/takeLast.cjs.map +1 -1
- package/dist/array/takeLast.d.ts +1 -1
- package/dist/array/takeLast.d.ts.map +1 -1
- package/dist/array/takeLast.js +1 -8
- package/dist/array/takeLast.js.map +1 -1
- package/dist/array/toggle.cjs +1 -1
- package/dist/array/toggle.cjs.map +1 -1
- package/dist/array/toggle.d.ts +1 -1
- package/dist/array/toggle.d.ts.map +1 -1
- package/dist/array/toggle.js +1 -8
- package/dist/array/toggle.js.map +1 -1
- package/dist/array/union.cjs +1 -1
- package/dist/array/union.cjs.map +1 -1
- package/dist/array/union.d.ts +4 -2
- package/dist/array/union.d.ts.map +1 -1
- package/dist/array/union.js +1 -8
- package/dist/array/union.js.map +1 -1
- package/dist/array/uniq.cjs +1 -1
- package/dist/array/uniq.cjs.map +1 -1
- package/dist/array/uniq.d.ts +1 -1
- package/dist/array/uniq.d.ts.map +1 -1
- package/dist/array/uniq.js +1 -8
- package/dist/array/uniq.js.map +1 -1
- package/dist/array/unzip.cjs +1 -1
- package/dist/array/unzip.cjs.map +1 -1
- package/dist/array/unzip.js +1 -10
- package/dist/array/unzip.js.map +1 -1
- package/dist/array/zip.cjs +1 -1
- package/dist/array/zip.cjs.map +1 -1
- package/dist/array/zip.d.ts +1 -1
- package/dist/array/zip.d.ts.map +1 -1
- package/dist/array/zip.js +1 -10
- package/dist/array/zip.js.map +1 -1
- package/dist/arsenal.cjs +1 -1
- package/dist/arsenal.cjs.map +1 -1
- package/dist/arsenal.iife.js +1 -1
- package/dist/arsenal.iife.js.map +1 -1
- package/dist/arsenal.js +1 -1
- package/dist/arsenal.js.map +1 -1
- package/dist/async/abortError.cjs +1 -1
- package/dist/async/abortError.cjs.map +1 -1
- package/dist/async/abortError.d.ts +3 -2
- package/dist/async/abortError.d.ts.map +1 -1
- package/dist/async/abortError.js +1 -7
- package/dist/async/abortError.js.map +1 -1
- package/dist/async/abortable.cjs +1 -1
- package/dist/async/abortable.cjs.map +1 -1
- package/dist/async/abortable.js +1 -11
- package/dist/async/abortable.js.map +1 -1
- package/dist/async/attempt.cjs +1 -1
- package/dist/async/attempt.cjs.map +1 -1
- package/dist/async/attempt.js +1 -23
- package/dist/async/attempt.js.map +1 -1
- package/dist/async/backoff.cjs +1 -1
- package/dist/async/backoff.cjs.map +1 -1
- package/dist/async/backoff.js +1 -7
- package/dist/async/backoff.js.map +1 -1
- package/dist/async/index.js +1 -10
- package/dist/async/parallel.cjs +1 -1
- package/dist/async/parallel.cjs.map +1 -1
- package/dist/async/parallel.js +1 -24
- package/dist/async/parallel.js.map +1 -1
- package/dist/async/retry.cjs +1 -1
- package/dist/async/retry.cjs.map +1 -1
- package/dist/async/retry.d.ts +4 -6
- package/dist/async/retry.d.ts.map +1 -1
- package/dist/async/retry.js +1 -24
- package/dist/async/retry.js.map +1 -1
- package/dist/async/sleep.cjs +1 -1
- package/dist/async/sleep.cjs.map +1 -1
- package/dist/async/sleep.js +1 -15
- package/dist/async/sleep.js.map +1 -1
- package/dist/async/taskPool.cjs +1 -1
- package/dist/async/taskPool.cjs.map +1 -1
- package/dist/async/taskPool.js +1 -50
- package/dist/async/taskPool.js.map +1 -1
- package/dist/async/waitFor.cjs +1 -1
- package/dist/async/waitFor.cjs.map +1 -1
- package/dist/async/waitFor.js +1 -12
- package/dist/async/waitFor.js.map +1 -1
- package/dist/cache/cache.cjs +1 -1
- package/dist/cache/cache.cjs.map +1 -1
- package/dist/cache/cache.d.ts +1 -0
- package/dist/cache/cache.d.ts.map +1 -1
- package/dist/cache/cache.js +1 -58
- package/dist/cache/cache.js.map +1 -1
- package/dist/cache/index.js +1 -3
- package/dist/cache/memo.cjs +1 -1
- package/dist/cache/memo.cjs.map +1 -1
- package/dist/cache/memo.js +1 -37
- package/dist/cache/memo.js.map +1 -1
- package/dist/encoding/base64url.cjs +2 -0
- package/dist/encoding/base64url.cjs.map +1 -0
- package/dist/encoding/base64url.d.ts +9 -0
- package/dist/encoding/base64url.d.ts.map +1 -0
- package/dist/encoding/base64url.js +2 -0
- package/dist/encoding/base64url.js.map +1 -0
- package/dist/encoding/index.cjs +1 -0
- package/dist/encoding/index.d.ts +2 -0
- package/dist/encoding/index.d.ts.map +1 -0
- package/dist/encoding/index.js +1 -0
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.js +1 -9
- package/dist/errors.js.map +1 -1
- package/dist/function/assert.cjs +1 -1
- package/dist/function/assert.cjs.map +1 -1
- package/dist/function/assert.d.ts +1 -1
- package/dist/function/assert.js +1 -7
- package/dist/function/assert.js.map +1 -1
- package/dist/function/debounce.cjs +1 -1
- package/dist/function/debounce.cjs.map +1 -1
- package/dist/function/debounce.js +1 -26
- package/dist/function/debounce.js.map +1 -1
- package/dist/function/index.cjs +1 -1
- package/dist/function/index.d.ts +1 -0
- package/dist/function/index.d.ts.map +1 -1
- package/dist/function/index.js +1 -8
- package/dist/function/once.cjs +1 -1
- package/dist/function/once.cjs.map +1 -1
- package/dist/function/once.js +1 -10
- package/dist/function/once.js.map +1 -1
- package/dist/function/pipe.cjs +1 -1
- package/dist/function/pipe.cjs.map +1 -1
- package/dist/function/pipe.js +1 -9
- package/dist/function/pipe.js.map +1 -1
- package/dist/function/runAll.cjs +1 -1
- package/dist/function/runAll.cjs.map +1 -1
- package/dist/function/runAll.js +1 -18
- package/dist/function/runAll.js.map +1 -1
- package/dist/function/tap.cjs +1 -1
- package/dist/function/tap.cjs.map +1 -1
- package/dist/function/tap.js +1 -7
- package/dist/function/tap.js.map +1 -1
- package/dist/function/tapper.cjs +2 -0
- package/dist/function/tapper.cjs.map +1 -0
- package/dist/function/tapper.d.ts +27 -0
- package/dist/function/tapper.d.ts.map +1 -0
- package/dist/function/tapper.js +2 -0
- package/dist/function/tapper.js.map +1 -0
- package/dist/function/throttle.cjs +1 -1
- package/dist/function/throttle.cjs.map +1 -1
- package/dist/function/throttle.js +1 -35
- package/dist/function/throttle.js.map +1 -1
- package/dist/guards/combinators.cjs +1 -1
- package/dist/guards/combinators.cjs.map +1 -1
- package/dist/guards/combinators.js +1 -16
- package/dist/guards/combinators.js.map +1 -1
- package/dist/guards/index.cjs +1 -1
- package/dist/guards/index.js +1 -17
- package/dist/guards/isAbortError.cjs +1 -1
- package/dist/guards/isAbortError.cjs.map +1 -1
- package/dist/guards/isAbortError.js +1 -7
- package/dist/guards/isAbortError.js.map +1 -1
- package/dist/guards/isDate.cjs +1 -1
- package/dist/guards/isDate.cjs.map +1 -1
- package/dist/guards/isDate.js +1 -7
- package/dist/guards/isDate.js.map +1 -1
- package/dist/guards/isDefined.cjs +1 -1
- package/dist/guards/isDefined.cjs.map +1 -1
- package/dist/guards/isDefined.js +1 -7
- package/dist/guards/isDefined.js.map +1 -1
- package/dist/guards/isEmpty.cjs +1 -1
- package/dist/guards/isEmpty.cjs.map +1 -1
- package/dist/guards/isEmpty.d.ts.map +1 -1
- package/dist/guards/isEmpty.js +1 -9
- package/dist/guards/isEmpty.js.map +1 -1
- package/dist/guards/isEqual.cjs +1 -1
- package/dist/guards/isEqual.cjs.map +1 -1
- package/dist/guards/isEqual.js +1 -33
- package/dist/guards/isEqual.js.map +1 -1
- package/dist/guards/isError.cjs +1 -1
- package/dist/guards/isError.cjs.map +1 -1
- package/dist/guards/isError.js +1 -7
- package/dist/guards/isError.js.map +1 -1
- package/dist/guards/isFunction.cjs +1 -1
- package/dist/guards/isFunction.cjs.map +1 -1
- package/dist/guards/isFunction.d.ts +1 -1
- package/dist/guards/isFunction.d.ts.map +1 -1
- package/dist/guards/isFunction.js +1 -7
- package/dist/guards/isFunction.js.map +1 -1
- package/dist/guards/isMatch.cjs +1 -1
- package/dist/guards/isMatch.cjs.map +1 -1
- package/dist/guards/isMatch.js +1 -22
- package/dist/guards/isMatch.js.map +1 -1
- package/dist/guards/isNil.cjs +1 -1
- package/dist/guards/isNil.cjs.map +1 -1
- package/dist/guards/isNil.js +1 -7
- package/dist/guards/isNil.js.map +1 -1
- package/dist/guards/isNumber.cjs +1 -1
- package/dist/guards/isNumber.cjs.map +1 -1
- package/dist/guards/isNumber.js +1 -7
- package/dist/guards/isNumber.js.map +1 -1
- package/dist/guards/isPlainObject.cjs +1 -1
- package/dist/guards/isPlainObject.cjs.map +1 -1
- package/dist/guards/isPlainObject.js +1 -9
- package/dist/guards/isPlainObject.js.map +1 -1
- package/dist/guards/isPrimitive.cjs +1 -1
- package/dist/guards/isPrimitive.cjs.map +1 -1
- package/dist/guards/isPrimitive.d.ts +4 -17
- package/dist/guards/isPrimitive.d.ts.map +1 -1
- package/dist/guards/isPrimitive.js +1 -8
- package/dist/guards/isPrimitive.js.map +1 -1
- package/dist/guards/isPromise.cjs +1 -1
- package/dist/guards/isPromise.cjs.map +1 -1
- package/dist/guards/isPromise.js +1 -7
- package/dist/guards/isPromise.js.map +1 -1
- package/dist/guards/isRegex.cjs +1 -1
- package/dist/guards/isRegex.cjs.map +1 -1
- package/dist/guards/isRegex.js +1 -7
- package/dist/guards/isRegex.js.map +1 -1
- package/dist/guards/shallowEqual.cjs +1 -1
- package/dist/guards/shallowEqual.cjs.map +1 -1
- package/dist/guards/shallowEqual.js +1 -19
- package/dist/guards/shallowEqual.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -30
- package/dist/math/allocate.cjs +1 -1
- package/dist/math/allocate.cjs.map +1 -1
- package/dist/math/allocate.js +1 -18
- package/dist/math/allocate.js.map +1 -1
- package/dist/math/average.cjs +1 -1
- package/dist/math/average.cjs.map +1 -1
- package/dist/math/average.d.ts +3 -2
- package/dist/math/average.d.ts.map +1 -1
- package/dist/math/average.js +1 -13
- package/dist/math/average.js.map +1 -1
- package/dist/math/clamp.cjs +1 -1
- package/dist/math/clamp.cjs.map +1 -1
- package/dist/math/clamp.js +1 -7
- package/dist/math/clamp.js.map +1 -1
- package/dist/math/gcd.cjs +1 -1
- package/dist/math/gcd.cjs.map +1 -1
- package/dist/math/gcd.d.ts.map +1 -1
- package/dist/math/gcd.js +1 -12
- package/dist/math/gcd.js.map +1 -1
- package/dist/math/index.cjs +1 -1
- package/dist/math/index.d.ts +0 -1
- package/dist/math/index.d.ts.map +1 -1
- package/dist/math/index.js +1 -17
- package/dist/math/lcm.cjs +1 -1
- package/dist/math/lcm.cjs.map +1 -1
- package/dist/math/lcm.d.ts.map +1 -1
- package/dist/math/lcm.js +1 -8
- package/dist/math/lcm.js.map +1 -1
- package/dist/math/lerp.cjs +1 -1
- package/dist/math/lerp.cjs.map +1 -1
- package/dist/math/lerp.js +1 -7
- package/dist/math/lerp.js.map +1 -1
- package/dist/math/linspace.cjs +1 -1
- package/dist/math/linspace.cjs.map +1 -1
- package/dist/math/linspace.d.ts.map +1 -1
- package/dist/math/linspace.js +1 -10
- package/dist/math/linspace.js.map +1 -1
- package/dist/math/median.cjs +1 -1
- package/dist/math/median.cjs.map +1 -1
- package/dist/math/median.d.ts +1 -1
- package/dist/math/median.d.ts.map +1 -1
- package/dist/math/median.js +1 -11
- package/dist/math/median.js.map +1 -1
- package/dist/math/mod.cjs +1 -1
- package/dist/math/mod.cjs.map +1 -1
- package/dist/math/mod.js +1 -8
- package/dist/math/mod.js.map +1 -1
- package/dist/math/normalize.cjs +1 -1
- package/dist/math/normalize.cjs.map +1 -1
- package/dist/math/normalize.js +1 -8
- package/dist/math/normalize.js.map +1 -1
- package/dist/math/range.cjs +1 -1
- package/dist/math/range.cjs.map +1 -1
- package/dist/math/range.js +1 -25
- package/dist/math/range.js.map +1 -1
- package/dist/math/round.cjs +1 -1
- package/dist/math/round.cjs.map +1 -1
- package/dist/math/round.js +1 -9
- package/dist/math/round.js.map +1 -1
- package/dist/math/standardDeviation.cjs +1 -1
- package/dist/math/standardDeviation.cjs.map +1 -1
- package/dist/math/standardDeviation.d.ts +1 -1
- package/dist/math/standardDeviation.d.ts.map +1 -1
- package/dist/math/standardDeviation.js +1 -8
- package/dist/math/standardDeviation.js.map +1 -1
- package/dist/math/sum.cjs +1 -1
- package/dist/math/sum.cjs.map +1 -1
- package/dist/math/sum.d.ts +1 -1
- package/dist/math/sum.d.ts.map +1 -1
- package/dist/math/sum.js +1 -11
- package/dist/math/sum.js.map +1 -1
- package/dist/math/variance.cjs +1 -1
- package/dist/math/variance.cjs.map +1 -1
- package/dist/math/variance.d.ts +1 -1
- package/dist/math/variance.d.ts.map +1 -1
- package/dist/math/variance.js +1 -10
- package/dist/math/variance.js.map +1 -1
- package/dist/object/defaults.cjs +1 -1
- package/dist/object/defaults.cjs.map +1 -1
- package/dist/object/defaults.js +1 -11
- package/dist/object/defaults.js.map +1 -1
- package/dist/object/diff.cjs +1 -1
- package/dist/object/diff.cjs.map +1 -1
- package/dist/object/diff.d.ts +1 -1
- package/dist/object/diff.d.ts.map +1 -1
- package/dist/object/diff.js +1 -26
- package/dist/object/diff.js.map +1 -1
- package/dist/object/filterValues.cjs +1 -1
- package/dist/object/filterValues.cjs.map +1 -1
- package/dist/object/filterValues.js +1 -10
- package/dist/object/filterValues.js.map +1 -1
- package/dist/object/flattenPaths.cjs +1 -1
- package/dist/object/flattenPaths.cjs.map +1 -1
- package/dist/object/flattenPaths.js +1 -30
- package/dist/object/flattenPaths.js.map +1 -1
- package/dist/object/getPath.cjs +1 -1
- package/dist/object/getPath.cjs.map +1 -1
- package/dist/object/getPath.js +1 -25
- package/dist/object/getPath.js.map +1 -1
- package/dist/object/hash.cjs +1 -1
- package/dist/object/hash.cjs.map +1 -1
- package/dist/object/hash.js +1 -27
- package/dist/object/hash.js.map +1 -1
- package/dist/object/index.js +1 -15
- package/dist/object/invert.cjs +1 -1
- package/dist/object/invert.cjs.map +1 -1
- package/dist/object/invert.js +1 -10
- package/dist/object/invert.js.map +1 -1
- package/dist/object/mapKeys.cjs +1 -1
- package/dist/object/mapKeys.cjs.map +1 -1
- package/dist/object/mapKeys.js +1 -14
- package/dist/object/mapKeys.js.map +1 -1
- package/dist/object/mapValues.cjs +1 -1
- package/dist/object/mapValues.cjs.map +1 -1
- package/dist/object/mapValues.js +1 -10
- package/dist/object/mapValues.js.map +1 -1
- package/dist/object/merge.cjs +1 -1
- package/dist/object/merge.cjs.map +1 -1
- package/dist/object/merge.js +1 -25
- package/dist/object/merge.js.map +1 -1
- package/dist/object/omit.cjs +1 -1
- package/dist/object/omit.cjs.map +1 -1
- package/dist/object/omit.js +1 -10
- package/dist/object/omit.js.map +1 -1
- package/dist/object/pick.cjs +1 -1
- package/dist/object/pick.cjs.map +1 -1
- package/dist/object/pick.js +1 -10
- package/dist/object/pick.js.map +1 -1
- package/dist/object/prune.cjs +1 -1
- package/dist/object/prune.cjs.map +1 -1
- package/dist/object/prune.d.ts.map +1 -1
- package/dist/object/prune.js +1 -34
- package/dist/object/prune.js.map +1 -1
- package/dist/object/tryParseJson.cjs +1 -1
- package/dist/object/tryParseJson.cjs.map +1 -1
- package/dist/object/tryParseJson.js +1 -17
- package/dist/object/tryParseJson.js.map +1 -1
- package/dist/random/_index.cjs +1 -1
- package/dist/random/_index.cjs.map +1 -1
- package/dist/random/_index.d.ts +1 -1
- package/dist/random/_index.d.ts.map +1 -1
- package/dist/random/_index.js +1 -9
- package/dist/random/_index.js.map +1 -1
- package/dist/random/draw.cjs +1 -1
- package/dist/random/draw.cjs.map +1 -1
- package/dist/random/draw.js +1 -20
- package/dist/random/draw.js.map +1 -1
- package/dist/random/index.cjs +1 -1
- package/dist/random/index.d.ts +0 -1
- package/dist/random/index.d.ts.map +1 -1
- package/dist/random/index.js +1 -5
- package/dist/random/random.cjs +1 -1
- package/dist/random/random.cjs.map +1 -1
- package/dist/random/random.js +1 -9
- package/dist/random/random.js.map +1 -1
- package/dist/random/shuffle.cjs +1 -1
- package/dist/random/shuffle.cjs.map +1 -1
- package/dist/random/shuffle.js +1 -13
- package/dist/random/shuffle.js.map +1 -1
- package/dist/random/source.cjs +2 -0
- package/dist/random/source.cjs.map +1 -0
- package/dist/random/source.d.ts +2 -0
- package/dist/random/source.d.ts.map +1 -1
- package/dist/random/source.js +2 -0
- package/dist/random/source.js.map +1 -0
- package/dist/string/_caseUtils.cjs +1 -1
- package/dist/string/_caseUtils.cjs.map +1 -1
- package/dist/string/_caseUtils.js +1 -12
- package/dist/string/_caseUtils.js.map +1 -1
- package/dist/string/camelCase.cjs +1 -1
- package/dist/string/camelCase.cjs.map +1 -1
- package/dist/string/camelCase.js +1 -8
- package/dist/string/camelCase.js.map +1 -1
- package/dist/string/escape.cjs +1 -1
- package/dist/string/escape.cjs.map +1 -1
- package/dist/string/escape.js +1 -14
- package/dist/string/escape.js.map +1 -1
- package/dist/string/index.cjs +1 -1
- package/dist/string/index.d.ts +1 -1
- package/dist/string/index.d.ts.map +1 -1
- package/dist/string/index.js +1 -12
- package/dist/string/kebabCase.cjs +1 -1
- package/dist/string/kebabCase.cjs.map +1 -1
- package/dist/string/kebabCase.js +1 -8
- package/dist/string/kebabCase.js.map +1 -1
- package/dist/string/padCenter.cjs +2 -0
- package/dist/string/padCenter.cjs.map +1 -0
- package/dist/string/padCenter.d.ts +3 -0
- package/dist/string/padCenter.d.ts.map +1 -0
- package/dist/string/padCenter.js +2 -0
- package/dist/string/padCenter.js.map +1 -0
- package/dist/string/pascalCase.cjs +1 -1
- package/dist/string/pascalCase.cjs.map +1 -1
- package/dist/string/pascalCase.js +1 -8
- package/dist/string/pascalCase.js.map +1 -1
- package/dist/string/similarity.cjs +1 -1
- package/dist/string/similarity.cjs.map +1 -1
- package/dist/string/similarity.js +1 -22
- package/dist/string/similarity.js.map +1 -1
- package/dist/string/snakeCase.cjs +1 -1
- package/dist/string/snakeCase.cjs.map +1 -1
- package/dist/string/snakeCase.js +1 -8
- package/dist/string/snakeCase.js.map +1 -1
- package/dist/string/titleCase.cjs +1 -1
- package/dist/string/titleCase.cjs.map +1 -1
- package/dist/string/titleCase.js +1 -8
- package/dist/string/titleCase.js.map +1 -1
- package/dist/string/truncate.cjs +1 -1
- package/dist/string/truncate.cjs.map +1 -1
- package/dist/string/truncate.js +1 -15
- package/dist/string/truncate.js.map +1 -1
- package/dist/string/unescape.cjs +1 -1
- package/dist/string/unescape.cjs.map +1 -1
- package/dist/string/unescape.js +1 -14
- package/dist/string/unescape.js.map +1 -1
- package/dist/string/words.cjs +1 -1
- package/dist/string/words.cjs.map +1 -1
- package/dist/string/words.js +1 -9
- package/dist/string/words.js.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +16 -8
- package/dist/array/flatten.cjs +0 -2
- package/dist/array/flatten.cjs.map +0 -1
- package/dist/array/flatten.d.ts +0 -5
- package/dist/array/flatten.d.ts.map +0 -1
- package/dist/array/flatten.js +0 -11
- package/dist/array/flatten.js.map +0 -1
- package/dist/math/percent.cjs +0 -2
- package/dist/math/percent.cjs.map +0 -1
- package/dist/math/percent.d.ts +0 -19
- package/dist/math/percent.d.ts.map +0 -1
- package/dist/math/percent.js +0 -8
- package/dist/math/percent.js.map +0 -1
- package/dist/random/uuid.cjs +0 -2
- package/dist/random/uuid.cjs.map +0 -1
- package/dist/random/uuid.d.ts +0 -12
- package/dist/random/uuid.d.ts.map +0 -1
- package/dist/random/uuid.js +0 -8
- package/dist/random/uuid.js.map +0 -1
- package/dist/string/pad.cjs +0 -2
- package/dist/string/pad.cjs.map +0 -1
- package/dist/string/pad.d.ts +0 -5
- package/dist/string/pad.d.ts.map +0 -1
- package/dist/string/pad.js +0 -10
- package/dist/string/pad.js.map +0 -1
package/dist/object/index.js
CHANGED
|
@@ -1,15 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { hash as r } from "./hash.js";
|
|
3
|
-
import { omit as i } from "./omit.js";
|
|
4
|
-
import { pick as a } from "./pick.js";
|
|
5
|
-
import { defaults as o } from "./defaults.js";
|
|
6
|
-
import { diff as s, diffArrays as c } from "./diff.js";
|
|
7
|
-
import { filterValues as l } from "./filterValues.js";
|
|
8
|
-
import { flattenPaths as u, unflattenPaths as d } from "./flattenPaths.js";
|
|
9
|
-
import { invert as f } from "./invert.js";
|
|
10
|
-
import { mapKeys as p } from "./mapKeys.js";
|
|
11
|
-
import { mapValues as m } from "./mapValues.js";
|
|
12
|
-
import { deepMerge as h, shallowMerge as g } from "./merge.js";
|
|
13
|
-
import { prune as _ } from "./prune.js";
|
|
14
|
-
import { tryParseJson as v } from "./tryParseJson.js";
|
|
15
|
-
export { h as deepMerge, o as defaults, s as diff, c as diffArrays, l as filterValues, u as flattenPaths, e as getPath, t as getPathOr, r as hash, f as invert, p as mapKeys, m as mapValues, i as omit, a as pick, _ as prune, n as requirePath, g as shallowMerge, v as tryParseJson, d as unflattenPaths };
|
|
1
|
+
import{getPath as e,getPathOr as t,requirePath as n}from"./getPath.js";import{hash as r}from"./hash.js";import{omit as i}from"./omit.js";import{pick as a}from"./pick.js";import{defaults as o}from"./defaults.js";import{diff as s,diffArrays as c}from"./diff.js";import{filterValues as l}from"./filterValues.js";import{flattenPaths as u,unflattenPaths as d}from"./flattenPaths.js";import{invert as f}from"./invert.js";import{mapKeys as p}from"./mapKeys.js";import{mapValues as m}from"./mapValues.js";import{deepMerge as h,shallowMerge as g}from"./merge.js";import{prune as _}from"./prune.js";import{tryParseJson as v}from"./tryParseJson.js";export{h as deepMerge,o as defaults,s as diff,c as diffArrays,l as filterValues,u as flattenPaths,e as getPath,t as getPathOr,r as hash,f as invert,p as mapKeys,m as mapValues,i as omit,a as pick,_ as prune,n as requirePath,g as shallowMerge,v as tryParseJson,d as unflattenPaths};
|
package/dist/object/invert.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../_common/unsafePaths.cjs");function
|
|
1
|
+
const e=require("../_common/unsafePaths.cjs");function invert(t){let n={};for(let[r,i]of Object.entries(t))e.isUnsafeKey(i)||(n[i]=r);return n}exports.invert=invert;
|
|
2
2
|
//# sourceMappingURL=invert.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invert.cjs","names":[],"sources":["../../src/object/invert.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\n\n/**\n * Inverts key-value pairs, so each value becomes a key and each key becomes its value.\n * Entries whose value is a dangerous key (`__proto__`, `constructor`, `prototype`) are skipped\n * to avoid prototype pollution. If multiple keys share the same value, the last one wins.\n *\n * @example\n * ```ts\n * invert({ a: 'x', b: 'y' }); // { x: 'a', y: 'b' }\n * ```\n *\n * @param obj - The source object. Values must be valid property keys (string, number, or symbol).\n * @returns A new object with keys and values swapped.\n */\nexport function invert<T extends Record<PropertyKey, PropertyKey>>(obj: T): Record<T[keyof T], keyof T> {\n const out = {} as Record<T[keyof T], keyof T>;\n\n for (const [key, value] of Object.entries(obj) as Array<[keyof T, T[keyof T]]>) {\n if (isUnsafeKey(value)) continue;\n\n out[value] = key;\n }\n\n return out;\n}\n"],"mappings":"8CAeA,SAAgB,
|
|
1
|
+
{"version":3,"file":"invert.cjs","names":[],"sources":["../../src/object/invert.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\n\n/**\n * Inverts key-value pairs, so each value becomes a key and each key becomes its value.\n * Entries whose value is a dangerous key (`__proto__`, `constructor`, `prototype`) are skipped\n * to avoid prototype pollution. If multiple keys share the same value, the last one wins.\n *\n * @example\n * ```ts\n * invert({ a: 'x', b: 'y' }); // { x: 'a', y: 'b' }\n * ```\n *\n * @param obj - The source object. Values must be valid property keys (string, number, or symbol).\n * @returns A new object with keys and values swapped.\n */\nexport function invert<T extends Record<PropertyKey, PropertyKey>>(obj: T): Record<T[keyof T], keyof T> {\n const out = {} as Record<T[keyof T], keyof T>;\n\n for (const [key, value] of Object.entries(obj) as Array<[keyof T, T[keyof T]]>) {\n if (isUnsafeKey(value)) continue;\n\n out[value] = key;\n }\n\n return out;\n}\n"],"mappings":"8CAeA,SAAgB,OAAmD,EAAqC,CACtG,IAAM,EAAM,CAAC,EAEb,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAG,EACvC,EAAA,YAAY,CAAK,IAErB,EAAI,GAAS,GAGf,OAAO,CACT"}
|
package/dist/object/invert.js
CHANGED
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
//#region src/object/invert.ts
|
|
3
|
-
function t(t) {
|
|
4
|
-
let n = {};
|
|
5
|
-
for (let [r, i] of Object.entries(t)) e(i) || (n[i] = r);
|
|
6
|
-
return n;
|
|
7
|
-
}
|
|
8
|
-
//#endregion
|
|
9
|
-
export { t as invert };
|
|
10
|
-
|
|
1
|
+
import{isUnsafeKey as e}from"../_common/unsafePaths.js";function invert(t){let n={};for(let[r,i]of Object.entries(t))e(i)||(n[i]=r);return n}export{invert};
|
|
11
2
|
//# sourceMappingURL=invert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invert.js","names":[],"sources":["../../src/object/invert.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\n\n/**\n * Inverts key-value pairs, so each value becomes a key and each key becomes its value.\n * Entries whose value is a dangerous key (`__proto__`, `constructor`, `prototype`) are skipped\n * to avoid prototype pollution. If multiple keys share the same value, the last one wins.\n *\n * @example\n * ```ts\n * invert({ a: 'x', b: 'y' }); // { x: 'a', y: 'b' }\n * ```\n *\n * @param obj - The source object. Values must be valid property keys (string, number, or symbol).\n * @returns A new object with keys and values swapped.\n */\nexport function invert<T extends Record<PropertyKey, PropertyKey>>(obj: T): Record<T[keyof T], keyof T> {\n const out = {} as Record<T[keyof T], keyof T>;\n\n for (const [key, value] of Object.entries(obj) as Array<[keyof T, T[keyof T]]>) {\n if (isUnsafeKey(value)) continue;\n\n out[value] = key;\n }\n\n return out;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"invert.js","names":[],"sources":["../../src/object/invert.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\n\n/**\n * Inverts key-value pairs, so each value becomes a key and each key becomes its value.\n * Entries whose value is a dangerous key (`__proto__`, `constructor`, `prototype`) are skipped\n * to avoid prototype pollution. If multiple keys share the same value, the last one wins.\n *\n * @example\n * ```ts\n * invert({ a: 'x', b: 'y' }); // { x: 'a', y: 'b' }\n * ```\n *\n * @param obj - The source object. Values must be valid property keys (string, number, or symbol).\n * @returns A new object with keys and values swapped.\n */\nexport function invert<T extends Record<PropertyKey, PropertyKey>>(obj: T): Record<T[keyof T], keyof T> {\n const out = {} as Record<T[keyof T], keyof T>;\n\n for (const [key, value] of Object.entries(obj) as Array<[keyof T, T[keyof T]]>) {\n if (isUnsafeKey(value)) continue;\n\n out[value] = key;\n }\n\n return out;\n}\n"],"mappings":"wDAeA,SAAgB,OAAmD,EAAqC,CACtG,IAAM,EAAM,CAAC,EAEb,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,CAAG,EACvC,EAAY,CAAK,IAErB,EAAI,GAAS,GAGf,OAAO,CACT"}
|
package/dist/object/mapKeys.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../_common/unsafePaths.cjs");function
|
|
1
|
+
const e=require("../_common/unsafePaths.cjs");function mapKeys(t,n){let r={};for(let i of Object.keys(t)){if(e.isUnsafeKey(i))continue;let a=n(i,t[i],t);e.isUnsafeKey(a)||(r[a]=t[i])}return r}exports.mapKeys=mapKeys;
|
|
2
2
|
//# sourceMappingURL=mapKeys.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapKeys.cjs","names":[],"sources":["../../src/object/mapKeys.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\n\n/**\n * Maps object keys while preserving values. Both the original key and any mapped key that\n * resolve to a dangerous key (`__proto__`, `constructor`, `prototype`) are skipped.\n *\n * @example\n * ```ts\n * mapKeys({ a: 1, b: 2 }, (key) => `x_${String(key)}`); // { x_a: 1, x_b: 2 }\n * ```\n *\n * @param obj - The source object.\n * @param mapper - Function producing the new key for each entry.\n * @returns A new object with mapped keys and the original values.\n */\nexport function mapKeys<T extends Obj>(\n obj: T,\n mapper: (key: keyof T, value: T[keyof T], obj: T) => PropertyKey,\n): Record<PropertyKey, T[keyof T]> {\n const out: Record<PropertyKey, T[keyof T]> = {};\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n const mappedKey = mapper(key, obj[key], obj);\n\n if (isUnsafeKey(mappedKey)) continue;\n\n out[mappedKey] = obj[key];\n }\n\n return out;\n}\n"],"mappings":"8CAgBA,SAAgB,
|
|
1
|
+
{"version":3,"file":"mapKeys.cjs","names":[],"sources":["../../src/object/mapKeys.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\n\n/**\n * Maps object keys while preserving values. Both the original key and any mapped key that\n * resolve to a dangerous key (`__proto__`, `constructor`, `prototype`) are skipped.\n *\n * @example\n * ```ts\n * mapKeys({ a: 1, b: 2 }, (key) => `x_${String(key)}`); // { x_a: 1, x_b: 2 }\n * ```\n *\n * @param obj - The source object.\n * @param mapper - Function producing the new key for each entry.\n * @returns A new object with mapped keys and the original values.\n */\nexport function mapKeys<T extends Obj>(\n obj: T,\n mapper: (key: keyof T, value: T[keyof T], obj: T) => PropertyKey,\n): Record<PropertyKey, T[keyof T]> {\n const out: Record<PropertyKey, T[keyof T]> = {};\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n const mappedKey = mapper(key, obj[key], obj);\n\n if (isUnsafeKey(mappedKey)) continue;\n\n out[mappedKey] = obj[key];\n }\n\n return out;\n}\n"],"mappings":"8CAgBA,SAAgB,QACd,EACA,EACiC,CACjC,IAAM,EAAuC,CAAC,EAE9C,IAAK,IAAM,KAAO,OAAO,KAAK,CAAG,EAAqB,CACpD,GAAI,EAAA,YAAY,CAAkB,EAAG,SAErC,IAAM,EAAY,EAAO,EAAK,EAAI,GAAM,CAAG,EAEvC,EAAA,YAAY,CAAS,IAEzB,EAAI,GAAa,EAAI,GACvB,CAEA,OAAO,CACT"}
|
package/dist/object/mapKeys.js
CHANGED
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
//#region src/object/mapKeys.ts
|
|
3
|
-
function t(t, n) {
|
|
4
|
-
let r = {};
|
|
5
|
-
for (let i of Object.keys(t)) {
|
|
6
|
-
if (e(i)) continue;
|
|
7
|
-
let a = n(i, t[i], t);
|
|
8
|
-
e(a) || (r[a] = t[i]);
|
|
9
|
-
}
|
|
10
|
-
return r;
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
export { t as mapKeys };
|
|
14
|
-
|
|
1
|
+
import{isUnsafeKey as e}from"../_common/unsafePaths.js";function mapKeys(t,n){let r={};for(let i of Object.keys(t)){if(e(i))continue;let a=n(i,t[i],t);e(a)||(r[a]=t[i])}return r}export{mapKeys};
|
|
15
2
|
//# sourceMappingURL=mapKeys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapKeys.js","names":[],"sources":["../../src/object/mapKeys.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\n\n/**\n * Maps object keys while preserving values. Both the original key and any mapped key that\n * resolve to a dangerous key (`__proto__`, `constructor`, `prototype`) are skipped.\n *\n * @example\n * ```ts\n * mapKeys({ a: 1, b: 2 }, (key) => `x_${String(key)}`); // { x_a: 1, x_b: 2 }\n * ```\n *\n * @param obj - The source object.\n * @param mapper - Function producing the new key for each entry.\n * @returns A new object with mapped keys and the original values.\n */\nexport function mapKeys<T extends Obj>(\n obj: T,\n mapper: (key: keyof T, value: T[keyof T], obj: T) => PropertyKey,\n): Record<PropertyKey, T[keyof T]> {\n const out: Record<PropertyKey, T[keyof T]> = {};\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n const mappedKey = mapper(key, obj[key], obj);\n\n if (isUnsafeKey(mappedKey)) continue;\n\n out[mappedKey] = obj[key];\n }\n\n return out;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"mapKeys.js","names":[],"sources":["../../src/object/mapKeys.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\n\n/**\n * Maps object keys while preserving values. Both the original key and any mapped key that\n * resolve to a dangerous key (`__proto__`, `constructor`, `prototype`) are skipped.\n *\n * @example\n * ```ts\n * mapKeys({ a: 1, b: 2 }, (key) => `x_${String(key)}`); // { x_a: 1, x_b: 2 }\n * ```\n *\n * @param obj - The source object.\n * @param mapper - Function producing the new key for each entry.\n * @returns A new object with mapped keys and the original values.\n */\nexport function mapKeys<T extends Obj>(\n obj: T,\n mapper: (key: keyof T, value: T[keyof T], obj: T) => PropertyKey,\n): Record<PropertyKey, T[keyof T]> {\n const out: Record<PropertyKey, T[keyof T]> = {};\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n const mappedKey = mapper(key, obj[key], obj);\n\n if (isUnsafeKey(mappedKey)) continue;\n\n out[mappedKey] = obj[key];\n }\n\n return out;\n}\n"],"mappings":"wDAgBA,SAAgB,QACd,EACA,EACiC,CACjC,IAAM,EAAuC,CAAC,EAE9C,IAAK,IAAM,KAAO,OAAO,KAAK,CAAG,EAAqB,CACpD,GAAI,EAAY,CAAkB,EAAG,SAErC,IAAM,EAAY,EAAO,EAAK,EAAI,GAAM,CAAG,EAEvC,EAAY,CAAS,IAEzB,EAAI,GAAa,EAAI,GACvB,CAEA,OAAO,CACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../_common/unsafePaths.cjs");function
|
|
1
|
+
const e=require("../_common/unsafePaths.cjs");function mapValues(t,n){let r={};for(let i of Object.keys(t))e.isUnsafeKey(i)||(r[i]=n(t[i],i,t));return r}exports.mapValues=mapValues;
|
|
2
2
|
//# sourceMappingURL=mapValues.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapValues.cjs","names":[],"sources":["../../src/object/mapValues.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\n\n/**\n * Maps object values while preserving the original keys. Dangerous keys (`__proto__`,\n * `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * mapValues({ a: 1, b: 2 }, (value) => value * 2); // { a: 2, b: 4 }\n * ```\n *\n * @param obj - The source object.\n * @param mapper - Function producing the new value for each entry.\n * @returns A new object with the same keys and mapped values.\n */\nexport function mapValues<T extends Obj, R>(\n obj: T,\n mapper: (value: T[keyof T], key: keyof T, obj: T) => R,\n): { [K in keyof T]: R } {\n const out = {} as { [K in keyof T]: R };\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n out[key] = mapper(obj[key], key, obj);\n }\n\n return out;\n}\n"],"mappings":"8CAgBA,SAAgB,
|
|
1
|
+
{"version":3,"file":"mapValues.cjs","names":[],"sources":["../../src/object/mapValues.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\n\n/**\n * Maps object values while preserving the original keys. Dangerous keys (`__proto__`,\n * `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * mapValues({ a: 1, b: 2 }, (value) => value * 2); // { a: 2, b: 4 }\n * ```\n *\n * @param obj - The source object.\n * @param mapper - Function producing the new value for each entry.\n * @returns A new object with the same keys and mapped values.\n */\nexport function mapValues<T extends Obj, R>(\n obj: T,\n mapper: (value: T[keyof T], key: keyof T, obj: T) => R,\n): { [K in keyof T]: R } {\n const out = {} as { [K in keyof T]: R };\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n out[key] = mapper(obj[key], key, obj);\n }\n\n return out;\n}\n"],"mappings":"8CAgBA,SAAgB,UACd,EACA,EACuB,CACvB,IAAM,EAAM,CAAC,EAEb,IAAK,IAAM,KAAO,OAAO,KAAK,CAAG,EAC3B,EAAA,YAAY,CAAkB,IAElC,EAAI,GAAO,EAAO,EAAI,GAAM,EAAK,CAAG,GAGtC,OAAO,CACT"}
|
package/dist/object/mapValues.js
CHANGED
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
//#region src/object/mapValues.ts
|
|
3
|
-
function t(t, n) {
|
|
4
|
-
let r = {};
|
|
5
|
-
for (let i of Object.keys(t)) e(i) || (r[i] = n(t[i], i, t));
|
|
6
|
-
return r;
|
|
7
|
-
}
|
|
8
|
-
//#endregion
|
|
9
|
-
export { t as mapValues };
|
|
10
|
-
|
|
1
|
+
import{isUnsafeKey as e}from"../_common/unsafePaths.js";function mapValues(t,n){let r={};for(let i of Object.keys(t))e(i)||(r[i]=n(t[i],i,t));return r}export{mapValues};
|
|
11
2
|
//# sourceMappingURL=mapValues.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapValues.js","names":[],"sources":["../../src/object/mapValues.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\n\n/**\n * Maps object values while preserving the original keys. Dangerous keys (`__proto__`,\n * `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * mapValues({ a: 1, b: 2 }, (value) => value * 2); // { a: 2, b: 4 }\n * ```\n *\n * @param obj - The source object.\n * @param mapper - Function producing the new value for each entry.\n * @returns A new object with the same keys and mapped values.\n */\nexport function mapValues<T extends Obj, R>(\n obj: T,\n mapper: (value: T[keyof T], key: keyof T, obj: T) => R,\n): { [K in keyof T]: R } {\n const out = {} as { [K in keyof T]: R };\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n out[key] = mapper(obj[key], key, obj);\n }\n\n return out;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"mapValues.js","names":[],"sources":["../../src/object/mapValues.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\n\n/**\n * Maps object values while preserving the original keys. Dangerous keys (`__proto__`,\n * `constructor`, `prototype`) are always skipped.\n *\n * @example\n * ```ts\n * mapValues({ a: 1, b: 2 }, (value) => value * 2); // { a: 2, b: 4 }\n * ```\n *\n * @param obj - The source object.\n * @param mapper - Function producing the new value for each entry.\n * @returns A new object with the same keys and mapped values.\n */\nexport function mapValues<T extends Obj, R>(\n obj: T,\n mapper: (value: T[keyof T], key: keyof T, obj: T) => R,\n): { [K in keyof T]: R } {\n const out = {} as { [K in keyof T]: R };\n\n for (const key of Object.keys(obj) as Array<keyof T>) {\n if (isUnsafeKey(key as PropertyKey)) continue;\n\n out[key] = mapper(obj[key], key, obj);\n }\n\n return out;\n}\n"],"mappings":"wDAgBA,SAAgB,UACd,EACA,EACuB,CACvB,IAAM,EAAM,CAAC,EAEb,IAAK,IAAM,KAAO,OAAO,KAAK,CAAG,EAC3B,EAAY,CAAkB,IAElC,EAAI,GAAO,EAAO,EAAI,GAAM,EAAK,CAAG,GAGtC,OAAO,CACT"}
|
package/dist/object/merge.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../_common/unsafePaths.cjs"),t=require("../guards/isPlainObject.cjs");function n
|
|
1
|
+
const e=require("../_common/unsafePaths.cjs"),t=require("../guards/isPlainObject.cjs");function mergeObjects(n,r,i){if(!t.isPlainObject(r))return r;let a={...n};for(let n of Object.keys(r)){if(e.isUnsafeKey(n))continue;let o=r[n],s=a[n];a[n]=Array.isArray(o)&&Array.isArray(s)?i.arrayStrategy===`concat`?[...s,...o]:o:t.isPlainObject(o)&&t.isPlainObject(s)?mergeObjects(s,o,i):o}return a}function deepMerge(e,t={}){return e.reduce((e,n)=>mergeObjects(e,n,t),{})}function shallowMerge(...t){if(t.length===0)return{};let n={};for(let r of t)for(let t of Object.keys(r))e.isUnsafeKey(t)||(n[t]=r[t]);return n}exports.deepMerge=deepMerge,exports.shallowMerge=shallowMerge;
|
|
2
2
|
//# sourceMappingURL=merge.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.cjs","names":[],"sources":["../../src/object/merge.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport { isPlainObject } from '../guards/isPlainObject';\nimport type { Obj } from '../types';\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[]>(items: readonly [...T], options: DeepMergeOptions = {}): Merge<T> {\n return items.reduce((acc: Obj, item) => mergeObjects(acc, item, options) as Obj, {} as Obj) 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":"uFA+BA,SAAS,
|
|
1
|
+
{"version":3,"file":"merge.cjs","names":[],"sources":["../../src/object/merge.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport { isPlainObject } from '../guards/isPlainObject';\nimport type { Obj } from '../types';\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[]>(items: readonly [...T], options: DeepMergeOptions = {}): Merge<T> {\n return items.reduce((acc: Obj, item) => mergeObjects(acc, item, options) as Obj, {} as Obj) 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":"uFA+BA,SAAS,aAA2C,EAAW,EAAW,EAA4C,CACpH,GAAI,CAAC,EAAA,cAAc,CAAM,EAAG,OAAO,EAEnC,IAAM,EAAS,CAAE,GAAG,CAAO,EAE3B,IAAK,IAAM,KAAO,OAAO,KAAK,CAAM,EAAG,CAErC,GAAI,EAAA,YAAY,CAAG,EACjB,SAGF,IAAM,EAAc,EAAO,GACrB,EAAc,EAAO,GAE3B,EAAoC,GAClC,MAAM,QAAQ,CAAW,GAAK,MAAM,QAAQ,CAAW,EACnD,EAAQ,gBAAkB,SACxB,CAAC,GAAG,EAAa,GAAG,CAAW,EAC/B,EACF,EAAA,cAAc,CAAW,GAAK,EAAA,cAAc,CAAW,EACrD,aAAa,EAAoB,EAAoB,CAAO,EAC5D,CACV,CAEA,OAAO,CACT,CAkBA,SAAgB,UAA2B,EAAwB,EAA4B,CAAC,EAAa,CAC3G,OAAO,EAAM,QAAQ,EAAU,IAAS,aAAa,EAAK,EAAM,CAAO,EAAU,CAAC,CAAQ,CAC5F,CAcA,SAAgB,aAA8B,GAAG,EAAyB,CACxE,GAAI,EAAM,SAAW,EAAG,MAAO,CAAC,EAEhC,IAAM,EAAc,CAAC,EAErB,IAAK,IAAM,KAAQ,EACjB,IAAK,IAAM,KAAO,OAAO,KAAK,CAAI,EAC5B,EAAA,YAAY,CAAG,IAEnB,EAAO,GAAO,EAAK,IAIvB,OAAO,CACT"}
|
package/dist/object/merge.js
CHANGED
|
@@ -1,26 +1,2 @@
|
|
|
1
|
-
import
|
|
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, t = {}) {
|
|
15
|
-
return e.reduce((e, r) => n(e, r, t), {});
|
|
16
|
-
}
|
|
17
|
-
function i(...t) {
|
|
18
|
-
if (t.length === 0) return {};
|
|
19
|
-
let n = {};
|
|
20
|
-
for (let r of t) for (let t of Object.keys(r)) e(t) || (n[t] = r[t]);
|
|
21
|
-
return n;
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
|
-
export { r as deepMerge, i as shallowMerge };
|
|
25
|
-
|
|
1
|
+
import{isUnsafeKey as e}from"../_common/unsafePaths.js";import{isPlainObject as t}from"../guards/isPlainObject.js";function mergeObjects(n,r,i){if(!t(r))return r;let a={...n};for(let n of Object.keys(r)){if(e(n))continue;let o=r[n],s=a[n];a[n]=Array.isArray(o)&&Array.isArray(s)?i.arrayStrategy===`concat`?[...s,...o]:o:t(o)&&t(s)?mergeObjects(s,o,i):o}return a}function deepMerge(e,t={}){return e.reduce((e,n)=>mergeObjects(e,n,t),{})}function shallowMerge(...t){if(t.length===0)return{};let n={};for(let r of t)for(let t of Object.keys(r))e(t)||(n[t]=r[t]);return n}export{deepMerge,shallowMerge};
|
|
26
2
|
//# sourceMappingURL=merge.js.map
|
package/dist/object/merge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.js","names":[],"sources":["../../src/object/merge.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport { isPlainObject } from '../guards/isPlainObject';\nimport type { Obj } from '../types';\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[]>(items: readonly [...T], options: DeepMergeOptions = {}): Merge<T> {\n return items.reduce((acc: Obj, item) => mergeObjects(acc, item, options) as Obj, {} as Obj) 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":"
|
|
1
|
+
{"version":3,"file":"merge.js","names":[],"sources":["../../src/object/merge.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport { isPlainObject } from '../guards/isPlainObject';\nimport type { Obj } from '../types';\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[]>(items: readonly [...T], options: DeepMergeOptions = {}): Merge<T> {\n return items.reduce((acc: Obj, item) => mergeObjects(acc, item, options) as Obj, {} as Obj) 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":"mHA+BA,SAAS,aAA2C,EAAW,EAAW,EAA4C,CACpH,GAAI,CAAC,EAAc,CAAM,EAAG,OAAO,EAEnC,IAAM,EAAS,CAAE,GAAG,CAAO,EAE3B,IAAK,IAAM,KAAO,OAAO,KAAK,CAAM,EAAG,CAErC,GAAI,EAAY,CAAG,EACjB,SAGF,IAAM,EAAc,EAAO,GACrB,EAAc,EAAO,GAE3B,EAAoC,GAClC,MAAM,QAAQ,CAAW,GAAK,MAAM,QAAQ,CAAW,EACnD,EAAQ,gBAAkB,SACxB,CAAC,GAAG,EAAa,GAAG,CAAW,EAC/B,EACF,EAAc,CAAW,GAAK,EAAc,CAAW,EACrD,aAAa,EAAoB,EAAoB,CAAO,EAC5D,CACV,CAEA,OAAO,CACT,CAkBA,SAAgB,UAA2B,EAAwB,EAA4B,CAAC,EAAa,CAC3G,OAAO,EAAM,QAAQ,EAAU,IAAS,aAAa,EAAK,EAAM,CAAO,EAAU,CAAC,CAAQ,CAC5F,CAcA,SAAgB,aAA8B,GAAG,EAAyB,CACxE,GAAI,EAAM,SAAW,EAAG,MAAO,CAAC,EAEhC,IAAM,EAAc,CAAC,EAErB,IAAK,IAAM,KAAQ,EACjB,IAAK,IAAM,KAAO,OAAO,KAAK,CAAI,EAC5B,EAAY,CAAG,IAEnB,EAAO,GAAO,EAAK,IAIvB,OAAO,CACT"}
|
package/dist/object/omit.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../_common/unsafePaths.cjs");function
|
|
1
|
+
const e=require("../_common/unsafePaths.cjs");function omit(t,n){let r=new Set(n),i={};for(let n of Object.keys(t))e.isUnsafeKey(n)||r.has(n)||(i[n]=t[n]);return i}exports.omit=omit;
|
|
2
2
|
//# sourceMappingURL=omit.cjs.map
|
package/dist/object/omit.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"omit.cjs","names":[],"sources":["../../src/object/omit.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\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":"8CAgBA,SAAgB,
|
|
1
|
+
{"version":3,"file":"omit.cjs","names":[],"sources":["../../src/object/omit.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\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":"8CAgBA,SAAgB,KAAuC,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"}
|
package/dist/object/omit.js
CHANGED
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
1
|
+
import{isUnsafeKey as e}from"../_common/unsafePaths.js";function omit(t,n){let r=new Set(n),i={};for(let n of Object.keys(t))e(n)||r.has(n)||(i[n]=t[n]);return i}export{omit};
|
|
11
2
|
//# sourceMappingURL=omit.js.map
|
package/dist/object/omit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"omit.js","names":[],"sources":["../../src/object/omit.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\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":"
|
|
1
|
+
{"version":3,"file":"omit.js","names":[],"sources":["../../src/object/omit.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\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":"wDAgBA,SAAgB,KAAuC,EAAQ,EAAuC,CACpG,IAAM,EAAY,IAAI,IAAiB,CAAqC,EACtE,EAAM,CAAC,EAEb,IAAK,IAAM,KAAO,OAAO,KAAK,CAAG,EAC3B,EAAY,CAAkB,GAE7B,EAAU,IAAI,CAAG,IACpB,EAAW,GAAO,EAAI,IAI1B,OAAO,CACT"}
|
package/dist/object/pick.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../_common/unsafePaths.cjs");function
|
|
1
|
+
const e=require("../_common/unsafePaths.cjs");function pick(t,n){let r={};for(let i of n)e.isUnsafeKey(i)||Object.hasOwn(t,i)&&(r[i]=t[i]);return r}exports.pick=pick;
|
|
2
2
|
//# sourceMappingURL=pick.cjs.map
|
package/dist/object/pick.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pick.cjs","names":[],"sources":["../../src/object/pick.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\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":"8CAiBA,SAAgB,
|
|
1
|
+
{"version":3,"file":"pick.cjs","names":[],"sources":["../../src/object/pick.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\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":"8CAiBA,SAAgB,KAAuC,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"}
|
package/dist/object/pick.js
CHANGED
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
1
|
+
import{isUnsafeKey as e}from"../_common/unsafePaths.js";function pick(t,n){let r={};for(let i of n)e(i)||Object.hasOwn(t,i)&&(r[i]=t[i]);return r}export{pick};
|
|
11
2
|
//# sourceMappingURL=pick.js.map
|
package/dist/object/pick.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pick.js","names":[],"sources":["../../src/object/pick.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\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":"
|
|
1
|
+
{"version":3,"file":"pick.js","names":[],"sources":["../../src/object/pick.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Obj } from '../types';\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":"wDAiBA,SAAgB,KAAuC,EAAQ,EAAwC,CACrG,IAAM,EAAM,CAAC,EAEb,IAAK,IAAM,KAAO,EACZ,EAAY,CAAkB,GAE9B,OAAO,OAAO,EAAK,CAAG,IACxB,EAAI,GAAO,EAAI,IAInB,OAAO,CACT"}
|
package/dist/object/prune.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../_common/unsafePaths.cjs"),t=require("../array/filterMap.cjs"),n=require("../guards/
|
|
1
|
+
const e=require("../_common/unsafePaths.cjs"),t=require("../array/filterMap.cjs"),n=require("../guards/isPlainObject.cjs"),r=require("../guards/isEmpty.cjs");function prune(i){if(i!=null){if(typeof i==`string`){let e=i.trim();return e===``?void 0:e}if(Array.isArray(i)){let e=t.filterMap(i,e=>{let t=prune(e);return r.isEmpty(t)?void 0:t});return e.length===0?void 0:e}if(n.isPlainObject(i)){let t={};for(let[n,a]of Object.entries(i)){if(e.isUnsafeKey(n))continue;let i=prune(a);r.isEmpty(i)||(t[n]=i)}return Object.keys(t).length===0?void 0:t}return i}}exports.prune=prune;
|
|
2
2
|
//# sourceMappingURL=prune.cjs.map
|
|
@@ -1 +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 {
|
|
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 { isPlainObject } from '../guards/isPlainObject';\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 (value === null || value === undefined) return undefined;\n\n if (typeof value === 'string') {\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":"8JA8BA,SAAgB,MAAS,EAAyB,CAC5C,MAAU,KAEd,IAAI,OAAO,GAAU,SAAU,CAC7B,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,MAAM,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,MAAM,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prune.d.ts","sourceRoot":"","sources":["../../src/object/prune.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prune.d.ts","sourceRoot":"","sources":["../../src/object/prune.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;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"}
|
package/dist/object/prune.js
CHANGED
|
@@ -1,35 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { filterMap as t } from "../array/filterMap.js";
|
|
3
|
-
import { isNil as n } from "../guards/isNil.js";
|
|
4
|
-
import { isPlainObject as r } from "../guards/isPlainObject.js";
|
|
5
|
-
import { isEmpty as i } from "../guards/isEmpty.js";
|
|
6
|
-
//#region src/object/prune.ts
|
|
7
|
-
function a(o) {
|
|
8
|
-
if (!n(o)) {
|
|
9
|
-
if (typeof o == "string") {
|
|
10
|
-
let e = o.trim();
|
|
11
|
-
return e === "" ? void 0 : e;
|
|
12
|
-
}
|
|
13
|
-
if (Array.isArray(o)) {
|
|
14
|
-
let e = t(o, (e) => {
|
|
15
|
-
let t = a(e);
|
|
16
|
-
return i(t) ? void 0 : t;
|
|
17
|
-
});
|
|
18
|
-
return e.length === 0 ? void 0 : e;
|
|
19
|
-
}
|
|
20
|
-
if (r(o)) {
|
|
21
|
-
let t = {};
|
|
22
|
-
for (let [n, r] of Object.entries(o)) {
|
|
23
|
-
if (e(n)) continue;
|
|
24
|
-
let o = a(r);
|
|
25
|
-
i(o) || (t[n] = o);
|
|
26
|
-
}
|
|
27
|
-
return Object.keys(t).length === 0 ? void 0 : t;
|
|
28
|
-
}
|
|
29
|
-
return o;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
//#endregion
|
|
33
|
-
export { a as prune };
|
|
34
|
-
|
|
1
|
+
import{isUnsafeKey as e}from"../_common/unsafePaths.js";import{filterMap as t}from"../array/filterMap.js";import{isPlainObject as n}from"../guards/isPlainObject.js";import{isEmpty as r}from"../guards/isEmpty.js";function prune(i){if(i!=null){if(typeof i==`string`){let e=i.trim();return e===``?void 0:e}if(Array.isArray(i)){let e=t(i,e=>{let t=prune(e);return r(t)?void 0:t});return e.length===0?void 0:e}if(n(i)){let t={};for(let[n,a]of Object.entries(i)){if(e(n))continue;let i=prune(a);r(i)||(t[n]=i)}return Object.keys(t).length===0?void 0:t}return i}}export{prune};
|
|
35
2
|
//# sourceMappingURL=prune.js.map
|
package/dist/object/prune.js.map
CHANGED
|
@@ -1 +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 {
|
|
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 { isPlainObject } from '../guards/isPlainObject';\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 (value === null || value === undefined) return undefined;\n\n if (typeof value === 'string') {\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":"oNA8BA,SAAgB,MAAS,EAAyB,CAC5C,MAAU,KAEd,IAAI,OAAO,GAAU,SAAU,CAC7B,IAAM,EAAU,EAAM,KAAK,EAE3B,OAAQ,IAAY,GAAK,IAAA,GAAY,CACvC,CAEA,GAAI,MAAM,QAAQ,CAAK,EAAG,CACxB,IAAM,EAAU,EAAU,EAAqB,GAAS,CACtD,IAAM,EAAS,MAAM,CAAI,EAEzB,OAAO,EAAQ,CAAM,EAAI,IAAA,GAAa,CACxC,CAAC,EAED,OAAQ,EAAQ,SAAW,EAAI,IAAA,GAAY,CAC7C,CAEA,GAAI,EAAc,CAAK,EAAG,CACxB,IAAM,EAAmC,CAAC,EAE1C,IAAK,GAAM,CAAC,EAAK,KAAQ,OAAO,QAAQ,CAAK,EAAG,CAC9C,GAAI,EAAY,CAAG,EAAG,SAEtB,IAAM,EAAe,MAAM,CAAG,EAEzB,EAAQ,CAAY,IACvB,EAAQ,GAAO,EAEnB,CAEA,OAAQ,OAAO,KAAK,CAAO,CAAC,CAAC,SAAW,EAAI,IAAA,GAAY,CAC1D,CAEA,OAAO,CA5BP,CA6BF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
1
|
+
function tryParseJson(e){try{return{ok:!0,value:JSON.parse(e)}}catch(e){return{error:e,ok:!1}}}exports.tryParseJson=tryParseJson;
|
|
2
2
|
//# sourceMappingURL=tryParseJson.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tryParseJson.cjs","names":[],"sources":["../../src/object/tryParseJson.ts"],"sourcesContent":["export type JsonParseResult = { ok: true; value: unknown } | { error: SyntaxError; ok: false };\n\nexport function tryParseJson(text: string): JsonParseResult {\n try {\n return { ok: true, value: JSON.parse(text) as unknown };\n } catch (error) {\n return { error: error as SyntaxError, ok: false };\n }\n}\n"],"mappings":"AAEA,SAAgB,
|
|
1
|
+
{"version":3,"file":"tryParseJson.cjs","names":[],"sources":["../../src/object/tryParseJson.ts"],"sourcesContent":["export type JsonParseResult = { ok: true; value: unknown } | { error: SyntaxError; ok: false };\n\nexport function tryParseJson(text: string): JsonParseResult {\n try {\n return { ok: true, value: JSON.parse(text) as unknown };\n } catch (error) {\n return { error: error as SyntaxError, ok: false };\n }\n}\n"],"mappings":"AAEA,SAAgB,aAAa,EAA+B,CAC1D,GAAI,CACF,MAAO,CAAE,GAAI,GAAM,MAAO,KAAK,MAAM,CAAI,CAAa,CACxD,OAAS,EAAO,CACd,MAAO,CAAS,QAAsB,GAAI,EAAM,CAClD,CACF"}
|
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
function e(e) {
|
|
3
|
-
try {
|
|
4
|
-
return {
|
|
5
|
-
ok: !0,
|
|
6
|
-
value: JSON.parse(e)
|
|
7
|
-
};
|
|
8
|
-
} catch (e) {
|
|
9
|
-
return {
|
|
10
|
-
error: e,
|
|
11
|
-
ok: !1
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
//#endregion
|
|
16
|
-
export { e as tryParseJson };
|
|
17
|
-
|
|
1
|
+
function tryParseJson(e){try{return{ok:!0,value:JSON.parse(e)}}catch(e){return{error:e,ok:!1}}}export{tryParseJson};
|
|
18
2
|
//# sourceMappingURL=tryParseJson.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tryParseJson.js","names":[],"sources":["../../src/object/tryParseJson.ts"],"sourcesContent":["export type JsonParseResult = { ok: true; value: unknown } | { error: SyntaxError; ok: false };\n\nexport function tryParseJson(text: string): JsonParseResult {\n try {\n return { ok: true, value: JSON.parse(text) as unknown };\n } catch (error) {\n return { error: error as SyntaxError, ok: false };\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"tryParseJson.js","names":[],"sources":["../../src/object/tryParseJson.ts"],"sourcesContent":["export type JsonParseResult = { ok: true; value: unknown } | { error: SyntaxError; ok: false };\n\nexport function tryParseJson(text: string): JsonParseResult {\n try {\n return { ok: true, value: JSON.parse(text) as unknown };\n } catch (error) {\n return { error: error as SyntaxError, ok: false };\n }\n}\n"],"mappings":"AAEA,SAAgB,aAAa,EAA+B,CAC1D,GAAI,CACF,MAAO,CAAE,GAAI,GAAM,MAAO,KAAK,MAAM,CAAI,CAAa,CACxD,OAAS,EAAO,CACd,MAAO,CAAS,QAAsB,GAAI,EAAM,CAClD,CACF"}
|
package/dist/random/_index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require("./source.cjs");function randomIndex(t,n){return Math.floor(e.randomFloat(n)*t)}exports.randomIndex=randomIndex;
|
|
2
2
|
//# sourceMappingURL=_index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_index.cjs","names":[],"sources":["../../src/random/_index.ts"],"sourcesContent":["import type
|
|
1
|
+
{"version":3,"file":"_index.cjs","names":[],"sources":["../../src/random/_index.ts"],"sourcesContent":["import { type RandomSource, randomFloat } from './source';\n\nexport function randomIndex(exclusiveMax: number, source?: RandomSource): number {\n return Math.floor(randomFloat(source) * exclusiveMax);\n}\n"],"mappings":"gCAEA,SAAgB,YAAY,EAAsB,EAA+B,CAC/E,OAAO,KAAK,MAAM,EAAA,YAAY,CAAM,EAAI,CAAY,CACtD"}
|
package/dist/random/_index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_index.d.ts","sourceRoot":"","sources":["../../src/random/_index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"_index.d.ts","sourceRoot":"","sources":["../../src/random/_index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAe,MAAM,UAAU,CAAC;AAE1D,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAE/E"}
|
package/dist/random/_index.js
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
function e(e, t) {
|
|
3
|
-
let n = t?.next() ?? crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(1))[0] / 4294967296;
|
|
4
|
-
if (!Number.isFinite(n) || n < 0 || n >= 1) throw RangeError("random source must return a finite number in [0, 1)");
|
|
5
|
-
return Math.floor(n * e);
|
|
6
|
-
}
|
|
7
|
-
//#endregion
|
|
8
|
-
export { e as randomIndex };
|
|
9
|
-
|
|
1
|
+
import{randomFloat as e}from"./source.js";function randomIndex(t,n){return Math.floor(e(n)*t)}export{randomIndex};
|
|
10
2
|
//# sourceMappingURL=_index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_index.js","names":[],"sources":["../../src/random/_index.ts"],"sourcesContent":["import type
|
|
1
|
+
{"version":3,"file":"_index.js","names":[],"sources":["../../src/random/_index.ts"],"sourcesContent":["import { type RandomSource, randomFloat } from './source';\n\nexport function randomIndex(exclusiveMax: number, source?: RandomSource): number {\n return Math.floor(randomFloat(source) * exclusiveMax);\n}\n"],"mappings":"0CAEA,SAAgB,YAAY,EAAsB,EAA+B,CAC/E,OAAO,KAAK,MAAM,EAAY,CAAM,EAAI,CAAY,CACtD"}
|
package/dist/random/draw.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./_index.cjs"),t=require("./random.cjs");function
|
|
1
|
+
const e=require("./_index.cjs"),t=require("./random.cjs");function draw(e,n){if(e.length!==0)return e[t.random(0,e.length-1,n)]}function drawMany(t,n,r){let i=Math.max(0,Math.min(t.length,Math.floor(n)));if(i===0)return[];if(i===t.length)return[...t];let a=[...t];for(let t=a.length-1;t>0;t--){let n=e.randomIndex(t+1,r),i=a[t];a[t]=a[n],a[n]=i}return a.slice(0,i)}exports.draw=draw,exports.drawMany=drawMany;
|
|
2
2
|
//# sourceMappingURL=draw.cjs.map
|
package/dist/random/draw.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draw.cjs","names":[],"sources":["../../src/random/draw.ts"],"sourcesContent":["import { randomIndex } from './_index';\nimport { random } from './random';\nimport type { RandomSource } from './source';\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[], source?: RandomSource): T | undefined {\n if (array.length === 0) return undefined;\n\n return array[random(0, array.length - 1, source)];\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, source?: RandomSource): 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 selectedIndex = randomIndex(index + 1, source);\n const temp = copy[index];\n\n copy[index] = copy[selectedIndex]!;\n copy[selectedIndex] = temp!;\n }\n\n return copy.slice(0, count);\n}\n"],"mappings":"0DAcA,SAAgB,
|
|
1
|
+
{"version":3,"file":"draw.cjs","names":[],"sources":["../../src/random/draw.ts"],"sourcesContent":["import { randomIndex } from './_index';\nimport { random } from './random';\nimport type { RandomSource } from './source';\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[], source?: RandomSource): T | undefined {\n if (array.length === 0) return undefined;\n\n return array[random(0, array.length - 1, source)];\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, source?: RandomSource): 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 selectedIndex = randomIndex(index + 1, source);\n const temp = copy[index];\n\n copy[index] = copy[selectedIndex]!;\n copy[selectedIndex] = temp!;\n }\n\n return copy.slice(0, count);\n}\n"],"mappings":"0DAcA,SAAgB,KAAQ,EAAY,EAAsC,CACpE,KAAM,SAAW,EAErB,OAAO,EAAM,EAAA,OAAO,EAAG,EAAM,OAAS,EAAG,CAAM,EACjD,CAaA,SAAgB,SAAY,EAAY,EAAW,EAA4B,CAC7E,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,EAAgB,EAAA,YAAY,EAAQ,EAAG,CAAM,EAC7C,EAAO,EAAK,GAElB,EAAK,GAAS,EAAK,GACnB,EAAK,GAAiB,CACxB,CAEA,OAAO,EAAK,MAAM,EAAG,CAAK,CAC5B"}
|
package/dist/random/draw.js
CHANGED
|
@@ -1,21 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { random as t } from "./random.js";
|
|
3
|
-
//#region src/random/draw.ts
|
|
4
|
-
function n(e, n) {
|
|
5
|
-
if (e.length !== 0) return e[t(0, e.length - 1, n)];
|
|
6
|
-
}
|
|
7
|
-
function r(t, n, r) {
|
|
8
|
-
let i = Math.max(0, Math.min(t.length, Math.floor(n)));
|
|
9
|
-
if (i === 0) return [];
|
|
10
|
-
if (i === t.length) return [...t];
|
|
11
|
-
let a = [...t];
|
|
12
|
-
for (let t = a.length - 1; t > 0; t--) {
|
|
13
|
-
let n = e(t + 1, r), i = a[t];
|
|
14
|
-
a[t] = a[n], a[n] = i;
|
|
15
|
-
}
|
|
16
|
-
return a.slice(0, i);
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
|
-
export { n as draw, r as drawMany };
|
|
20
|
-
|
|
1
|
+
import{randomIndex as e}from"./_index.js";import{random as t}from"./random.js";function draw(e,n){if(e.length!==0)return e[t(0,e.length-1,n)]}function drawMany(t,n,r){let i=Math.max(0,Math.min(t.length,Math.floor(n)));if(i===0)return[];if(i===t.length)return[...t];let a=[...t];for(let t=a.length-1;t>0;t--){let n=e(t+1,r),i=a[t];a[t]=a[n],a[n]=i}return a.slice(0,i)}export{draw,drawMany};
|
|
21
2
|
//# sourceMappingURL=draw.js.map
|
package/dist/random/draw.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draw.js","names":[],"sources":["../../src/random/draw.ts"],"sourcesContent":["import { randomIndex } from './_index';\nimport { random } from './random';\nimport type { RandomSource } from './source';\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[], source?: RandomSource): T | undefined {\n if (array.length === 0) return undefined;\n\n return array[random(0, array.length - 1, source)];\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, source?: RandomSource): 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 selectedIndex = randomIndex(index + 1, source);\n const temp = copy[index];\n\n copy[index] = copy[selectedIndex]!;\n copy[selectedIndex] = temp!;\n }\n\n return copy.slice(0, count);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"draw.js","names":[],"sources":["../../src/random/draw.ts"],"sourcesContent":["import { randomIndex } from './_index';\nimport { random } from './random';\nimport type { RandomSource } from './source';\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[], source?: RandomSource): T | undefined {\n if (array.length === 0) return undefined;\n\n return array[random(0, array.length - 1, source)];\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, source?: RandomSource): 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 selectedIndex = randomIndex(index + 1, source);\n const temp = copy[index];\n\n copy[index] = copy[selectedIndex]!;\n copy[selectedIndex] = temp!;\n }\n\n return copy.slice(0, count);\n}\n"],"mappings":"+EAcA,SAAgB,KAAQ,EAAY,EAAsC,CACpE,KAAM,SAAW,EAErB,OAAO,EAAM,EAAO,EAAG,EAAM,OAAS,EAAG,CAAM,EACjD,CAaA,SAAgB,SAAY,EAAY,EAAW,EAA4B,CAC7E,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,EAAgB,EAAY,EAAQ,EAAG,CAAM,EAC7C,EAAO,EAAK,GAElB,EAAK,GAAS,EAAK,GACnB,EAAK,GAAiB,CACxB,CAEA,OAAO,EAAK,MAAM,EAAG,CAAK,CAC5B"}
|
package/dist/random/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./source.cjs"),t=require("./random.cjs"),n=require("./draw.cjs"),r=require("./shuffle.cjs");exports.draw=n.draw,exports.drawMany=n.drawMany,exports.random=t.random,exports.randomFloat=e.randomFloat,exports.shuffle=r.shuffle;
|
package/dist/random/index.d.ts
CHANGED
|
@@ -1 +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,UAAU,CAAC
|
|
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,UAAU,CAAC"}
|
package/dist/random/index.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { random as t } from "./random.js";
|
|
3
|
-
import { draw as n, drawMany as r } from "./draw.js";
|
|
4
|
-
import { shuffle as i } from "./shuffle.js";
|
|
5
|
-
export { n as draw, r as drawMany, t as random, i as shuffle, e as uuid };
|
|
1
|
+
import{randomFloat as e}from"./source.js";import{random as t}from"./random.js";import{draw as n,drawMany as r}from"./draw.js";import{shuffle as i}from"./shuffle.js";export{n as draw,r as drawMany,t as random,e as randomFloat,i as shuffle};
|