@vielzeug/arsenal 26.10.15 → 26.10.17
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/LICENSE +21 -0
- package/dist/_common/_lruMap.cjs.map +1 -1
- package/dist/_common/_lruMap.js +17 -1
- package/dist/_common/_lruMap.js.map +1 -1
- package/dist/_common/_selectorSet.cjs.map +1 -1
- package/dist/_common/_selectorSet.js +15 -1
- package/dist/_common/_selectorSet.js.map +1 -1
- package/dist/_common/unsafePaths.cjs.map +1 -1
- package/dist/_common/unsafePaths.js +12 -1
- package/dist/_common/unsafePaths.js.map +1 -1
- package/dist/_dev.cjs.map +1 -1
- package/dist/_dev.js +5 -1
- package/dist/_dev.js.map +1 -1
- package/dist/array/chunk.cjs.map +1 -1
- package/dist/array/chunk.js +9 -1
- package/dist/array/chunk.js.map +1 -1
- package/dist/array/compact.cjs.map +1 -1
- package/dist/array/compact.js +7 -1
- package/dist/array/compact.js.map +1 -1
- package/dist/array/compare.cjs.map +1 -1
- package/dist/array/compare.js +18 -1
- package/dist/array/compare.js.map +1 -1
- package/dist/array/compareBy.cjs.map +1 -1
- package/dist/array/compareBy.js +15 -1
- package/dist/array/compareBy.js.map +1 -1
- package/dist/array/contains.cjs.map +1 -1
- package/dist/array/contains.js +8 -1
- package/dist/array/contains.js.map +1 -1
- package/dist/array/countBy.cjs.map +1 -1
- package/dist/array/countBy.js +13 -1
- package/dist/array/countBy.js.map +1 -1
- package/dist/array/difference.cjs.map +1 -1
- package/dist/array/difference.js +13 -1
- package/dist/array/difference.js.map +1 -1
- package/dist/array/drop.cjs.map +1 -1
- package/dist/array/drop.js +8 -1
- package/dist/array/drop.js.map +1 -1
- package/dist/array/dropLast.cjs.map +1 -1
- package/dist/array/dropLast.js +8 -1
- package/dist/array/dropLast.js.map +1 -1
- package/dist/array/filterMap.cjs.map +1 -1
- package/dist/array/filterMap.js +12 -1
- package/dist/array/filterMap.js.map +1 -1
- package/dist/array/first.cjs.map +1 -1
- package/dist/array/first.js +7 -1
- package/dist/array/first.js.map +1 -1
- package/dist/array/groupBy.cjs.map +1 -1
- package/dist/array/groupBy.js +13 -1
- package/dist/array/groupBy.js.map +1 -1
- package/dist/array/index.js +29 -1
- package/dist/array/indexBy.cjs.map +1 -1
- package/dist/array/indexBy.js +13 -1
- package/dist/array/indexBy.js.map +1 -1
- package/dist/array/intersection.cjs.map +1 -1
- package/dist/array/intersection.js +13 -1
- package/dist/array/intersection.js.map +1 -1
- package/dist/array/last.cjs.map +1 -1
- package/dist/array/last.js +7 -1
- package/dist/array/last.js.map +1 -1
- package/dist/array/paginate.cjs.map +1 -1
- package/dist/array/paginate.js +18 -1
- package/dist/array/paginate.js.map +1 -1
- package/dist/array/partition.cjs.map +1 -1
- package/dist/array/partition.js +9 -1
- package/dist/array/partition.js.map +1 -1
- package/dist/array/replace.cjs.map +1 -1
- package/dist/array/replace.js +12 -1
- package/dist/array/replace.js.map +1 -1
- package/dist/array/rotate.cjs.map +1 -1
- package/dist/array/rotate.js +9 -1
- package/dist/array/rotate.js.map +1 -1
- package/dist/array/search.cjs.map +1 -1
- package/dist/array/search.js +29 -1
- package/dist/array/search.js.map +1 -1
- package/dist/array/sort.cjs.map +1 -1
- package/dist/array/sort.js +31 -1
- package/dist/array/sort.js.map +1 -1
- package/dist/array/take.cjs.map +1 -1
- package/dist/array/take.js +8 -1
- package/dist/array/take.js.map +1 -1
- package/dist/array/takeLast.cjs.map +1 -1
- package/dist/array/takeLast.js +8 -1
- package/dist/array/takeLast.js.map +1 -1
- package/dist/array/toggle.cjs.map +1 -1
- package/dist/array/toggle.js +8 -1
- package/dist/array/toggle.js.map +1 -1
- package/dist/array/union.cjs.map +1 -1
- package/dist/array/union.js +8 -1
- package/dist/array/union.js.map +1 -1
- package/dist/array/uniq.cjs.map +1 -1
- package/dist/array/uniq.js +8 -1
- package/dist/array/uniq.js.map +1 -1
- package/dist/array/unzip.cjs.map +1 -1
- package/dist/array/unzip.js +10 -1
- package/dist/array/unzip.js.map +1 -1
- package/dist/array/zip.cjs.map +1 -1
- package/dist/array/zip.js +10 -1
- 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 +815 -1
- package/dist/arsenal.js.map +1 -1
- package/dist/async/abortError.cjs.map +1 -1
- package/dist/async/abortError.js +7 -1
- package/dist/async/abortError.js.map +1 -1
- package/dist/async/abortable.cjs.map +1 -1
- package/dist/async/abortable.js +11 -1
- package/dist/async/abortable.js.map +1 -1
- package/dist/async/attempt.cjs.map +1 -1
- package/dist/async/attempt.js +23 -1
- package/dist/async/attempt.js.map +1 -1
- package/dist/async/backoff.cjs.map +1 -1
- package/dist/async/backoff.js +7 -1
- package/dist/async/backoff.js.map +1 -1
- package/dist/async/index.js +10 -1
- package/dist/async/parallel.cjs.map +1 -1
- package/dist/async/parallel.js +24 -1
- package/dist/async/parallel.js.map +1 -1
- package/dist/async/retry.cjs.map +1 -1
- package/dist/async/retry.js +24 -1
- package/dist/async/retry.js.map +1 -1
- package/dist/async/sleep.cjs.map +1 -1
- package/dist/async/sleep.js +15 -1
- package/dist/async/sleep.js.map +1 -1
- package/dist/async/taskPool.cjs.map +1 -1
- package/dist/async/taskPool.js +50 -1
- package/dist/async/taskPool.js.map +1 -1
- package/dist/async/waitFor.cjs.map +1 -1
- package/dist/async/waitFor.js +12 -1
- package/dist/async/waitFor.js.map +1 -1
- package/dist/cache/cache.cjs +1 -1
- package/dist/cache/cache.cjs.map +1 -1
- package/dist/cache/cache.js +56 -1
- package/dist/cache/cache.js.map +1 -1
- package/dist/cache/index.js +3 -1
- package/dist/cache/memo.cjs.map +1 -1
- package/dist/cache/memo.js +37 -1
- package/dist/cache/memo.js.map +1 -1
- package/dist/encoding/base64url.cjs.map +1 -1
- package/dist/encoding/base64url.js +32 -1
- package/dist/encoding/base64url.js.map +1 -1
- package/dist/encoding/compression.cjs.map +1 -1
- package/dist/encoding/compression.js +40 -1
- package/dist/encoding/compression.js.map +1 -1
- package/dist/encoding/index.js +4 -1
- package/dist/encoding/share-code.cjs.map +1 -1
- package/dist/encoding/share-code.js +61 -1
- package/dist/encoding/share-code.js.map +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.js +14 -1
- package/dist/errors.js.map +1 -1
- package/dist/function/assert.cjs.map +1 -1
- package/dist/function/assert.js +7 -1
- 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 +26 -1
- package/dist/function/debounce.js.map +1 -1
- package/dist/function/index.js +9 -1
- package/dist/function/once.cjs.map +1 -1
- package/dist/function/once.js +10 -1
- package/dist/function/once.js.map +1 -1
- package/dist/function/pipe.cjs.map +1 -1
- package/dist/function/pipe.js +9 -1
- package/dist/function/pipe.js.map +1 -1
- package/dist/function/runAll.cjs.map +1 -1
- package/dist/function/runAll.js +18 -1
- package/dist/function/runAll.js.map +1 -1
- package/dist/function/tap.cjs.map +1 -1
- package/dist/function/tap.js +7 -1
- package/dist/function/tap.js.map +1 -1
- package/dist/function/tapper.cjs.map +1 -1
- package/dist/function/tapper.js +30 -1
- package/dist/function/tapper.js.map +1 -1
- package/dist/function/throttle.cjs.map +1 -1
- package/dist/function/throttle.js +35 -1
- package/dist/function/throttle.js.map +1 -1
- package/dist/guards/combinators.cjs.map +1 -1
- package/dist/guards/combinators.js +16 -1
- package/dist/guards/combinators.js.map +1 -1
- package/dist/guards/index.js +17 -1
- package/dist/guards/isAbortError.cjs.map +1 -1
- package/dist/guards/isAbortError.js +7 -1
- package/dist/guards/isAbortError.js.map +1 -1
- package/dist/guards/isDate.cjs.map +1 -1
- package/dist/guards/isDate.js +7 -1
- package/dist/guards/isDate.js.map +1 -1
- package/dist/guards/isDefined.cjs.map +1 -1
- package/dist/guards/isDefined.js +7 -1
- package/dist/guards/isDefined.js.map +1 -1
- package/dist/guards/isEmpty.cjs.map +1 -1
- package/dist/guards/isEmpty.js +8 -1
- package/dist/guards/isEmpty.js.map +1 -1
- package/dist/guards/isEqual.cjs.map +1 -1
- package/dist/guards/isEqual.js +33 -1
- package/dist/guards/isEqual.js.map +1 -1
- package/dist/guards/isError.cjs.map +1 -1
- package/dist/guards/isError.js +7 -1
- package/dist/guards/isError.js.map +1 -1
- package/dist/guards/isFunction.cjs.map +1 -1
- package/dist/guards/isFunction.js +7 -1
- package/dist/guards/isFunction.js.map +1 -1
- package/dist/guards/isMatch.cjs.map +1 -1
- package/dist/guards/isMatch.js +22 -1
- package/dist/guards/isMatch.js.map +1 -1
- package/dist/guards/isNil.cjs.map +1 -1
- package/dist/guards/isNil.js +7 -1
- package/dist/guards/isNil.js.map +1 -1
- package/dist/guards/isNumber.cjs.map +1 -1
- package/dist/guards/isNumber.js +7 -1
- package/dist/guards/isNumber.js.map +1 -1
- package/dist/guards/isPlainObject.cjs.map +1 -1
- package/dist/guards/isPlainObject.js +9 -1
- package/dist/guards/isPlainObject.js.map +1 -1
- package/dist/guards/isPrimitive.cjs.map +1 -1
- package/dist/guards/isPrimitive.js +7 -1
- package/dist/guards/isPrimitive.js.map +1 -1
- package/dist/guards/isPromise.cjs.map +1 -1
- package/dist/guards/isPromise.js +7 -1
- package/dist/guards/isPromise.js.map +1 -1
- package/dist/guards/isRegex.cjs.map +1 -1
- package/dist/guards/isRegex.js +7 -1
- package/dist/guards/isRegex.js.map +1 -1
- package/dist/guards/shallowEqual.cjs.map +1 -1
- package/dist/guards/shallowEqual.js +19 -1
- package/dist/guards/shallowEqual.js.map +1 -1
- package/dist/index.js +44 -1
- package/dist/math/allocate.cjs.map +1 -1
- package/dist/math/allocate.js +18 -1
- package/dist/math/allocate.js.map +1 -1
- package/dist/math/average.cjs.map +1 -1
- package/dist/math/average.js +8 -1
- package/dist/math/average.js.map +1 -1
- package/dist/math/clamp.cjs.map +1 -1
- package/dist/math/clamp.js +7 -1
- package/dist/math/clamp.js.map +1 -1
- package/dist/math/gcd.cjs.map +1 -1
- package/dist/math/gcd.js +13 -1
- package/dist/math/gcd.js.map +1 -1
- package/dist/math/index.js +16 -1
- package/dist/math/lcm.cjs.map +1 -1
- package/dist/math/lcm.js +12 -1
- package/dist/math/lcm.js.map +1 -1
- package/dist/math/lerp.cjs.map +1 -1
- package/dist/math/lerp.js +7 -1
- package/dist/math/lerp.js.map +1 -1
- package/dist/math/linspace.cjs.map +1 -1
- package/dist/math/linspace.js +11 -1
- package/dist/math/linspace.js.map +1 -1
- package/dist/math/median.cjs.map +1 -1
- package/dist/math/median.js +11 -1
- package/dist/math/median.js.map +1 -1
- package/dist/math/mod.cjs.map +1 -1
- package/dist/math/mod.js +8 -1
- package/dist/math/mod.js.map +1 -1
- package/dist/math/normalize.cjs.map +1 -1
- package/dist/math/normalize.js +8 -1
- package/dist/math/normalize.js.map +1 -1
- package/dist/math/range.cjs.map +1 -1
- package/dist/math/range.js +25 -1
- package/dist/math/range.js.map +1 -1
- package/dist/math/round.cjs.map +1 -1
- package/dist/math/round.js +9 -1
- package/dist/math/round.js.map +1 -1
- package/dist/math/standardDeviation.cjs.map +1 -1
- package/dist/math/standardDeviation.js +8 -1
- package/dist/math/standardDeviation.js.map +1 -1
- package/dist/math/sum.cjs.map +1 -1
- package/dist/math/sum.js +11 -1
- package/dist/math/sum.js.map +1 -1
- package/dist/math/variance.cjs.map +1 -1
- package/dist/math/variance.js +10 -1
- package/dist/math/variance.js.map +1 -1
- package/dist/object/defaults.cjs.map +1 -1
- package/dist/object/defaults.js +11 -1
- package/dist/object/defaults.js.map +1 -1
- package/dist/object/diff.cjs.map +1 -1
- package/dist/object/diff.js +26 -1
- package/dist/object/diff.js.map +1 -1
- package/dist/object/filterValues.cjs.map +1 -1
- package/dist/object/filterValues.js +10 -1
- package/dist/object/filterValues.js.map +1 -1
- package/dist/object/flattenPaths.cjs.map +1 -1
- package/dist/object/flattenPaths.js +30 -1
- package/dist/object/flattenPaths.js.map +1 -1
- package/dist/object/getPath.cjs.map +1 -1
- package/dist/object/getPath.js +25 -1
- package/dist/object/getPath.js.map +1 -1
- package/dist/object/hash.cjs.map +1 -1
- package/dist/object/hash.js +27 -1
- package/dist/object/hash.js.map +1 -1
- package/dist/object/index.js +15 -1
- package/dist/object/invert.cjs.map +1 -1
- package/dist/object/invert.js +10 -1
- package/dist/object/invert.js.map +1 -1
- package/dist/object/mapKeys.cjs.map +1 -1
- package/dist/object/mapKeys.js +14 -1
- package/dist/object/mapKeys.js.map +1 -1
- package/dist/object/mapValues.cjs.map +1 -1
- package/dist/object/mapValues.js +10 -1
- package/dist/object/mapValues.js.map +1 -1
- package/dist/object/merge.cjs.map +1 -1
- package/dist/object/merge.js +25 -1
- package/dist/object/merge.js.map +1 -1
- package/dist/object/omit.cjs.map +1 -1
- package/dist/object/omit.js +10 -1
- package/dist/object/omit.js.map +1 -1
- package/dist/object/pick.cjs.map +1 -1
- package/dist/object/pick.js +10 -1
- package/dist/object/pick.js.map +1 -1
- package/dist/object/prune.cjs.map +1 -1
- package/dist/object/prune.js +33 -1
- package/dist/object/prune.js.map +1 -1
- package/dist/object/tryParseJson.cjs.map +1 -1
- package/dist/object/tryParseJson.js +17 -1
- package/dist/object/tryParseJson.js.map +1 -1
- package/dist/random/_index.cjs.map +1 -1
- package/dist/random/_index.js +8 -1
- package/dist/random/_index.js.map +1 -1
- package/dist/random/draw.cjs.map +1 -1
- package/dist/random/draw.js +20 -1
- package/dist/random/draw.js.map +1 -1
- package/dist/random/index.js +5 -1
- package/dist/random/random.cjs.map +1 -1
- package/dist/random/random.js +9 -1
- package/dist/random/random.js.map +1 -1
- package/dist/random/shuffle.cjs.map +1 -1
- package/dist/random/shuffle.js +13 -1
- package/dist/random/shuffle.js.map +1 -1
- package/dist/random/source.cjs.map +1 -1
- package/dist/random/source.js +9 -1
- package/dist/random/source.js.map +1 -1
- package/dist/string/_caseUtils.cjs.map +1 -1
- package/dist/string/_caseUtils.js +12 -1
- package/dist/string/_caseUtils.js.map +1 -1
- package/dist/string/camelCase.cjs.map +1 -1
- package/dist/string/camelCase.js +8 -1
- package/dist/string/camelCase.js.map +1 -1
- package/dist/string/escape.cjs.map +1 -1
- package/dist/string/escape.js +14 -1
- package/dist/string/escape.js.map +1 -1
- package/dist/string/index.js +12 -1
- package/dist/string/kebabCase.cjs.map +1 -1
- package/dist/string/kebabCase.js +8 -1
- package/dist/string/kebabCase.js.map +1 -1
- package/dist/string/padCenter.cjs.map +1 -1
- package/dist/string/padCenter.js +9 -1
- package/dist/string/padCenter.js.map +1 -1
- package/dist/string/pascalCase.cjs.map +1 -1
- package/dist/string/pascalCase.js +8 -1
- package/dist/string/pascalCase.js.map +1 -1
- package/dist/string/similarity.cjs.map +1 -1
- package/dist/string/similarity.js +22 -1
- package/dist/string/similarity.js.map +1 -1
- package/dist/string/snakeCase.cjs.map +1 -1
- package/dist/string/snakeCase.js +8 -1
- package/dist/string/snakeCase.js.map +1 -1
- package/dist/string/titleCase.cjs.map +1 -1
- package/dist/string/titleCase.js +8 -1
- package/dist/string/titleCase.js.map +1 -1
- package/dist/string/truncate.cjs.map +1 -1
- package/dist/string/truncate.js +15 -1
- package/dist/string/truncate.js.map +1 -1
- package/dist/string/unescape.cjs.map +1 -1
- package/dist/string/unescape.js +14 -1
- package/dist/string/unescape.js.map +1 -1
- package/dist/string/words.cjs.map +1 -1
- package/dist/string/words.js +9 -1
- package/dist/string/words.js.map +1 -1
- package/package.json +5 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Helmuth Saatkamp
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_lruMap.cjs","names":[],"sources":["../../src/_common/_lruMap.ts"],"sourcesContent":["/**\n * A Map subclass that evicts the oldest non-excluded entry when the map exceeds\n * `maxSize`. Iteration order (insertion order) determines LRU: the first key\n * returned by `keys()` is the oldest.\n *\n * Calling `set` on an existing key refreshes its position (move-to-end).\n *\n * Module-private: underscore-prefixed file is excluded from barrel exports.\n */\nexport class LruMap<K, V> extends Map<K, V> {\n readonly maxSize: number;\n\n constructor(maxSize: number) {\n super();\n this.maxSize = maxSize;\n }\n\n override set(key: K, value: V): this {\n // Move existing entry to the end (most-recently-used position)\n if (this.has(key)) this.delete(key);\n\n super.set(key, value);\n\n // Evict oldest entry if we've exceeded maxSize\n if (this.size > this.maxSize) this.evictOldest();\n\n return this;\n }\n\n /**\n * Evicts the oldest entry for which `canEvict` returns true.\n * Returns `true` if an entry was evicted, `false` if all entries are guarded.\n */\n evictOldest(canEvict: (key: K, value: V) => boolean = () => true): boolean {\n for (const [k, v] of this) {\n if (canEvict(k, v)) {\n this.delete(k);\n\n return true;\n }\n }\n\n return false;\n }\n}\n"],"mappings":"AASA,IAAa,OAAb,cAAkC,GAAU,CAC1C,QAEA,YAAY,EAAiB,CAC3B,MAAM,EACN,KAAK,
|
|
1
|
+
{"version":3,"file":"_lruMap.cjs","names":["maxSize","key","value","k","v","canEvict"],"sources":["../../src/_common/_lruMap.ts"],"sourcesContent":["/**\n * A Map subclass that evicts the oldest non-excluded entry when the map exceeds\n * `maxSize`. Iteration order (insertion order) determines LRU: the first key\n * returned by `keys()` is the oldest.\n *\n * Calling `set` on an existing key refreshes its position (move-to-end).\n *\n * Module-private: underscore-prefixed file is excluded from barrel exports.\n */\nexport class LruMap<K, V> extends Map<K, V> {\n readonly maxSize: number;\n\n constructor(maxSize: number) {\n super();\n this.maxSize = maxSize;\n }\n\n override set(key: K, value: V): this {\n // Move existing entry to the end (most-recently-used position)\n if (this.has(key)) this.delete(key);\n\n super.set(key, value);\n\n // Evict oldest entry if we've exceeded maxSize\n if (this.size > this.maxSize) this.evictOldest();\n\n return this;\n }\n\n /**\n * Evicts the oldest entry for which `canEvict` returns true.\n * Returns `true` if an entry was evicted, `false` if all entries are guarded.\n */\n evictOldest(canEvict: (key: K, value: V) => boolean = () => true): boolean {\n for (const [k, v] of this) {\n if (canEvict(k, v)) {\n this.delete(k);\n\n return true;\n }\n }\n\n return false;\n }\n}\n"],"mappings":"AASA,IAAa,OAAb,cAAkC,GAAU,CAC1C,QAEA,YAAY,EAAiB,CAC3B,MAAM,EACN,KAAK,QAAUA,CACjB,CAEA,IAAa,EAAQ,EAAgB,CASnC,OAPI,KAAK,IAAIC,CAAG,GAAG,KAAK,OAAOA,CAAG,EAElC,MAAM,IAAIA,EAAKC,CAAK,EAGhB,KAAK,KAAO,KAAK,SAAS,KAAK,YAAY,EAExC,IACT,CAMA,YAAY,MAAgD,GAAe,CACzE,IAAK,GAAM,CAACC,EAAGC,KAAM,KACnB,GAAIC,EAASF,EAAGC,CAAC,EAGf,OAFA,KAAK,OAAOD,CAAC,EAEN,GAIX,MAAO,EACT,CACF,E"}
|
package/dist/_common/_lruMap.js
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/_common/_lruMap.ts
|
|
2
|
+
var LruMap = class extends Map {
|
|
3
|
+
maxSize;
|
|
4
|
+
constructor(e) {
|
|
5
|
+
super(), this.maxSize = e;
|
|
6
|
+
}
|
|
7
|
+
set(e, t) {
|
|
8
|
+
return this.has(e) && this.delete(e), super.set(e, t), this.size > this.maxSize && this.evictOldest(), this;
|
|
9
|
+
}
|
|
10
|
+
evictOldest(e = () => !0) {
|
|
11
|
+
for (let [t, n] of this) if (e(t, n)) return this.delete(t), !0;
|
|
12
|
+
return !1;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { LruMap };
|
|
17
|
+
|
|
2
18
|
//# sourceMappingURL=_lruMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_lruMap.js","names":[],"sources":["../../src/_common/_lruMap.ts"],"sourcesContent":["/**\n * A Map subclass that evicts the oldest non-excluded entry when the map exceeds\n * `maxSize`. Iteration order (insertion order) determines LRU: the first key\n * returned by `keys()` is the oldest.\n *\n * Calling `set` on an existing key refreshes its position (move-to-end).\n *\n * Module-private: underscore-prefixed file is excluded from barrel exports.\n */\nexport class LruMap<K, V> extends Map<K, V> {\n readonly maxSize: number;\n\n constructor(maxSize: number) {\n super();\n this.maxSize = maxSize;\n }\n\n override set(key: K, value: V): this {\n // Move existing entry to the end (most-recently-used position)\n if (this.has(key)) this.delete(key);\n\n super.set(key, value);\n\n // Evict oldest entry if we've exceeded maxSize\n if (this.size > this.maxSize) this.evictOldest();\n\n return this;\n }\n\n /**\n * Evicts the oldest entry for which `canEvict` returns true.\n * Returns `true` if an entry was evicted, `false` if all entries are guarded.\n */\n evictOldest(canEvict: (key: K, value: V) => boolean = () => true): boolean {\n for (const [k, v] of this) {\n if (canEvict(k, v)) {\n this.delete(k);\n\n return true;\n }\n }\n\n return false;\n }\n}\n"],"mappings":"AASA,IAAa,
|
|
1
|
+
{"version":3,"file":"_lruMap.js","names":["maxSize","key","value","k","v","canEvict"],"sources":["../../src/_common/_lruMap.ts"],"sourcesContent":["/**\n * A Map subclass that evicts the oldest non-excluded entry when the map exceeds\n * `maxSize`. Iteration order (insertion order) determines LRU: the first key\n * returned by `keys()` is the oldest.\n *\n * Calling `set` on an existing key refreshes its position (move-to-end).\n *\n * Module-private: underscore-prefixed file is excluded from barrel exports.\n */\nexport class LruMap<K, V> extends Map<K, V> {\n readonly maxSize: number;\n\n constructor(maxSize: number) {\n super();\n this.maxSize = maxSize;\n }\n\n override set(key: K, value: V): this {\n // Move existing entry to the end (most-recently-used position)\n if (this.has(key)) this.delete(key);\n\n super.set(key, value);\n\n // Evict oldest entry if we've exceeded maxSize\n if (this.size > this.maxSize) this.evictOldest();\n\n return this;\n }\n\n /**\n * Evicts the oldest entry for which `canEvict` returns true.\n * Returns `true` if an entry was evicted, `false` if all entries are guarded.\n */\n evictOldest(canEvict: (key: K, value: V) => boolean = () => true): boolean {\n for (const [k, v] of this) {\n if (canEvict(k, v)) {\n this.delete(k);\n\n return true;\n }\n }\n\n return false;\n }\n}\n"],"mappings":";AASA,IAAa,SAAb,cAAkC,IAAU;CAC1C;CAEA,YAAY,GAAiB;EAE3B,AADA,MAAM,GACN,KAAK,UAAUA;CACjB;CAEA,IAAa,GAAQ,GAAgB;EASnC,OAPI,KAAK,IAAIC,CAAG,KAAG,KAAK,OAAOA,CAAG,GAElC,MAAM,IAAIA,GAAKC,CAAK,GAGhB,KAAK,OAAO,KAAK,WAAS,KAAK,YAAY,GAExC;CACT;CAMA,YAAY,UAAgD,IAAe;EACzE,KAAK,IAAM,CAACC,GAAGC,MAAM,MACnB,IAAIC,EAASF,GAAGC,CAAC,GAGf,OAFA,KAAK,OAAOD,CAAC,GAEN;EAIX,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_selectorSet.cjs","names":[],"sources":["../../src/_common/_selectorSet.ts"],"sourcesContent":["import type { Primitive } from '../types';\n\n/**\n * Builds a `Set` of `selector(item)` results for O(1) membership checks: shared by\n * `intersection()` and `difference()`.\n *\n * Module-private: underscore-prefixed file is excluded from barrel exports.\n * @internal\n */\nexport function toSelectorSet<T>(items: readonly T[], selector: (item: T) => Primitive): Set<Primitive> {\n return new Set(items.map((item) => selector(item)));\n}\n\n/**\n * Returns `items` with duplicate `selector(item)` results removed, preserving the first\n * occurrence of each key: shared by `union()` and `uniq()`.\n *\n * Module-private: underscore-prefixed file is excluded from barrel exports.\n * @internal\n */\nexport function dedupeBySelector<T>(items: readonly T[], selector: (item: T) => Primitive): T[] {\n const seen = new Set<Primitive>();\n const out: T[] = [];\n\n for (const item of items) {\n const key = selector(item);\n\n if (seen.has(key)) continue;\n\n seen.add(key);\n out.push(item);\n }\n\n return out;\n}\n"],"mappings":"AASA,SAAgB,cAAiB,EAAqB,EAAkD,CACtG,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"_selectorSet.cjs","names":["items","selector","item","seen","out","key"],"sources":["../../src/_common/_selectorSet.ts"],"sourcesContent":["import type { Primitive } from '../types';\n\n/**\n * Builds a `Set` of `selector(item)` results for O(1) membership checks: shared by\n * `intersection()` and `difference()`.\n *\n * Module-private: underscore-prefixed file is excluded from barrel exports.\n * @internal\n */\nexport function toSelectorSet<T>(items: readonly T[], selector: (item: T) => Primitive): Set<Primitive> {\n return new Set(items.map((item) => selector(item)));\n}\n\n/**\n * Returns `items` with duplicate `selector(item)` results removed, preserving the first\n * occurrence of each key: shared by `union()` and `uniq()`.\n *\n * Module-private: underscore-prefixed file is excluded from barrel exports.\n * @internal\n */\nexport function dedupeBySelector<T>(items: readonly T[], selector: (item: T) => Primitive): T[] {\n const seen = new Set<Primitive>();\n const out: T[] = [];\n\n for (const item of items) {\n const key = selector(item);\n\n if (seen.has(key)) continue;\n\n seen.add(key);\n out.push(item);\n }\n\n return out;\n}\n"],"mappings":"AASA,SAAgB,cAAiB,EAAqB,EAAkD,CACtG,OAAO,IAAI,IAAIA,EAAM,IAAK,GAASC,EAASC,CAAI,CAAC,CAAC,CACpD,CASA,SAAgB,iBAAoB,EAAqB,EAAuC,CAC9F,IAAMC,EAAO,IAAI,IACXC,EAAW,CAAC,EAElB,IAAK,IAAMF,KAAQF,EAAO,CACxB,IAAMK,EAAMJ,EAASC,CAAI,EAErBC,EAAK,IAAIE,CAAG,IAEhBF,EAAK,IAAIE,CAAG,EACZD,EAAI,KAAKF,CAAI,EACf,CAEA,OAAOE,CACT,C"}
|
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/_common/_selectorSet.ts
|
|
2
|
+
function toSelectorSet(e, t) {
|
|
3
|
+
return new Set(e.map((e) => t(e)));
|
|
4
|
+
}
|
|
5
|
+
function dedupeBySelector(e, t) {
|
|
6
|
+
let n = /* @__PURE__ */ new Set(), r = [];
|
|
7
|
+
for (let i of e) {
|
|
8
|
+
let e = t(i);
|
|
9
|
+
n.has(e) || (n.add(e), r.push(i));
|
|
10
|
+
}
|
|
11
|
+
return r;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { dedupeBySelector, toSelectorSet };
|
|
15
|
+
|
|
2
16
|
//# sourceMappingURL=_selectorSet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_selectorSet.js","names":[],"sources":["../../src/_common/_selectorSet.ts"],"sourcesContent":["import type { Primitive } from '../types';\n\n/**\n * Builds a `Set` of `selector(item)` results for O(1) membership checks: shared by\n * `intersection()` and `difference()`.\n *\n * Module-private: underscore-prefixed file is excluded from barrel exports.\n * @internal\n */\nexport function toSelectorSet<T>(items: readonly T[], selector: (item: T) => Primitive): Set<Primitive> {\n return new Set(items.map((item) => selector(item)));\n}\n\n/**\n * Returns `items` with duplicate `selector(item)` results removed, preserving the first\n * occurrence of each key: shared by `union()` and `uniq()`.\n *\n * Module-private: underscore-prefixed file is excluded from barrel exports.\n * @internal\n */\nexport function dedupeBySelector<T>(items: readonly T[], selector: (item: T) => Primitive): T[] {\n const seen = new Set<Primitive>();\n const out: T[] = [];\n\n for (const item of items) {\n const key = selector(item);\n\n if (seen.has(key)) continue;\n\n seen.add(key);\n out.push(item);\n }\n\n return out;\n}\n"],"mappings":"AASA,SAAgB,cAAiB,
|
|
1
|
+
{"version":3,"file":"_selectorSet.js","names":["items","selector","item","seen","out","key"],"sources":["../../src/_common/_selectorSet.ts"],"sourcesContent":["import type { Primitive } from '../types';\n\n/**\n * Builds a `Set` of `selector(item)` results for O(1) membership checks: shared by\n * `intersection()` and `difference()`.\n *\n * Module-private: underscore-prefixed file is excluded from barrel exports.\n * @internal\n */\nexport function toSelectorSet<T>(items: readonly T[], selector: (item: T) => Primitive): Set<Primitive> {\n return new Set(items.map((item) => selector(item)));\n}\n\n/**\n * Returns `items` with duplicate `selector(item)` results removed, preserving the first\n * occurrence of each key: shared by `union()` and `uniq()`.\n *\n * Module-private: underscore-prefixed file is excluded from barrel exports.\n * @internal\n */\nexport function dedupeBySelector<T>(items: readonly T[], selector: (item: T) => Primitive): T[] {\n const seen = new Set<Primitive>();\n const out: T[] = [];\n\n for (const item of items) {\n const key = selector(item);\n\n if (seen.has(key)) continue;\n\n seen.add(key);\n out.push(item);\n }\n\n return out;\n}\n"],"mappings":";AASA,SAAgB,cAAiB,GAAqB,GAAkD;CACtG,OAAO,IAAI,IAAIA,EAAM,KAAK,MAASC,EAASC,CAAI,CAAC,CAAC;AACpD;AASA,SAAgB,iBAAoB,GAAqB,GAAuC;CAC9F,IAAMC,oBAAO,IAAI,IAAe,GAC1BC,IAAW,CAAC;CAElB,KAAK,IAAMF,KAAQF,GAAO;EACxB,IAAMK,IAAMJ,EAASC,CAAI;EAEzB,AAAIC,EAAK,IAAIE,CAAG,MAEhBF,EAAK,IAAIE,CAAG,GACZD,EAAI,KAAKF,CAAI;CACf;CAEA,OAAOE;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsafePaths.cjs","names":[],"sources":["../../src/_common/unsafePaths.ts"],"sourcesContent":["/**\n * Path segments that must be rejected in any dot-notation traversal or mutation\n * to prevent prototype pollution reads and writes.\n * @internal\n */\nexport const UNSAFE_PATH_SEGMENTS = new Set(['__proto__', 'constructor', 'prototype']);\n\n/**\n * Returns `true` if every dot-notation segment in `key` is safe to use as a\n * plain-object property.\n *\n * @example\n * ```ts\n * isSafePath('user.name') // true\n * isSafePath('__proto__.polluted') // false\n * ```\n */\nexport function isSafePath(key: string): boolean {\n return key.split('.').every((s) => !UNSAFE_PATH_SEGMENTS.has(s));\n}\n\n/**\n * Returns `true` if `key` is one of the dangerous own-property names that can be used to\n * pollute `Object.prototype` (`__proto__`, `constructor`, `prototype`). Use this for plain\n * (non-dotted) property keys: e.g. object keys being copied or reassigned. For dotted paths,\n * use `isSafePath` instead.\n *\n * @example\n * ```ts\n * isUnsafeKey('name') // false\n * isUnsafeKey('__proto__') // true\n * ```\n */\nexport function isUnsafeKey(key: PropertyKey): boolean {\n return typeof key === 'string' && UNSAFE_PATH_SEGMENTS.has(key);\n}\n"],"mappings":"AAKA,
|
|
1
|
+
{"version":3,"file":"unsafePaths.cjs","names":["UNSAFE_PATH_SEGMENTS","key"],"sources":["../../src/_common/unsafePaths.ts"],"sourcesContent":["/**\n * Path segments that must be rejected in any dot-notation traversal or mutation\n * to prevent prototype pollution reads and writes.\n * @internal\n */\nexport const UNSAFE_PATH_SEGMENTS = new Set(['__proto__', 'constructor', 'prototype']);\n\n/**\n * Returns `true` if every dot-notation segment in `key` is safe to use as a\n * plain-object property.\n *\n * @example\n * ```ts\n * isSafePath('user.name') // true\n * isSafePath('__proto__.polluted') // false\n * ```\n */\nexport function isSafePath(key: string): boolean {\n return key.split('.').every((s) => !UNSAFE_PATH_SEGMENTS.has(s));\n}\n\n/**\n * Returns `true` if `key` is one of the dangerous own-property names that can be used to\n * pollute `Object.prototype` (`__proto__`, `constructor`, `prototype`). Use this for plain\n * (non-dotted) property keys: e.g. object keys being copied or reassigned. For dotted paths,\n * use `isSafePath` instead.\n *\n * @example\n * ```ts\n * isUnsafeKey('name') // false\n * isUnsafeKey('__proto__') // true\n * ```\n */\nexport function isUnsafeKey(key: PropertyKey): boolean {\n return typeof key === 'string' && UNSAFE_PATH_SEGMENTS.has(key);\n}\n"],"mappings":"AAKA,IAAaA,EAAuB,IAAI,IAAI,CAAC,YAAa,cAAe,WAAW,CAAC,EA4BrF,SAAgB,YAAY,EAA2B,CACrD,OAAO,OAAOC,GAAQ,UAAYD,EAAqB,IAAIC,CAAG,CAChE,C"}
|
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/_common/unsafePaths.ts
|
|
2
|
+
var e = /* @__PURE__ */ new Set([
|
|
3
|
+
"__proto__",
|
|
4
|
+
"constructor",
|
|
5
|
+
"prototype"
|
|
6
|
+
]);
|
|
7
|
+
function isUnsafeKey(t) {
|
|
8
|
+
return typeof t == "string" && e.has(t);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { e as UNSAFE_PATH_SEGMENTS, isUnsafeKey };
|
|
12
|
+
|
|
2
13
|
//# sourceMappingURL=unsafePaths.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsafePaths.js","names":[],"sources":["../../src/_common/unsafePaths.ts"],"sourcesContent":["/**\n * Path segments that must be rejected in any dot-notation traversal or mutation\n * to prevent prototype pollution reads and writes.\n * @internal\n */\nexport const UNSAFE_PATH_SEGMENTS = new Set(['__proto__', 'constructor', 'prototype']);\n\n/**\n * Returns `true` if every dot-notation segment in `key` is safe to use as a\n * plain-object property.\n *\n * @example\n * ```ts\n * isSafePath('user.name') // true\n * isSafePath('__proto__.polluted') // false\n * ```\n */\nexport function isSafePath(key: string): boolean {\n return key.split('.').every((s) => !UNSAFE_PATH_SEGMENTS.has(s));\n}\n\n/**\n * Returns `true` if `key` is one of the dangerous own-property names that can be used to\n * pollute `Object.prototype` (`__proto__`, `constructor`, `prototype`). Use this for plain\n * (non-dotted) property keys: e.g. object keys being copied or reassigned. For dotted paths,\n * use `isSafePath` instead.\n *\n * @example\n * ```ts\n * isUnsafeKey('name') // false\n * isUnsafeKey('__proto__') // true\n * ```\n */\nexport function isUnsafeKey(key: PropertyKey): boolean {\n return typeof key === 'string' && UNSAFE_PATH_SEGMENTS.has(key);\n}\n"],"mappings":"AAKA,
|
|
1
|
+
{"version":3,"file":"unsafePaths.js","names":["UNSAFE_PATH_SEGMENTS","key"],"sources":["../../src/_common/unsafePaths.ts"],"sourcesContent":["/**\n * Path segments that must be rejected in any dot-notation traversal or mutation\n * to prevent prototype pollution reads and writes.\n * @internal\n */\nexport const UNSAFE_PATH_SEGMENTS = new Set(['__proto__', 'constructor', 'prototype']);\n\n/**\n * Returns `true` if every dot-notation segment in `key` is safe to use as a\n * plain-object property.\n *\n * @example\n * ```ts\n * isSafePath('user.name') // true\n * isSafePath('__proto__.polluted') // false\n * ```\n */\nexport function isSafePath(key: string): boolean {\n return key.split('.').every((s) => !UNSAFE_PATH_SEGMENTS.has(s));\n}\n\n/**\n * Returns `true` if `key` is one of the dangerous own-property names that can be used to\n * pollute `Object.prototype` (`__proto__`, `constructor`, `prototype`). Use this for plain\n * (non-dotted) property keys: e.g. object keys being copied or reassigned. For dotted paths,\n * use `isSafePath` instead.\n *\n * @example\n * ```ts\n * isUnsafeKey('name') // false\n * isUnsafeKey('__proto__') // true\n * ```\n */\nexport function isUnsafeKey(key: PropertyKey): boolean {\n return typeof key === 'string' && UNSAFE_PATH_SEGMENTS.has(key);\n}\n"],"mappings":";AAKA,IAAaA,oBAAuB,IAAI,IAAI;CAAC;CAAa;CAAe;AAAW,CAAC;AA4BrF,SAAgB,YAAY,GAA2B;CACrD,OAAO,OAAOC,KAAQ,YAAYD,EAAqB,IAAIC,CAAG;AAChE"}
|
package/dist/_dev.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_dev.cjs","names":[],"sources":["../src/_dev.ts"],"sourcesContent":["const isDev = !(globalThis as { __ARSENAL_PROD__?: boolean }).__ARSENAL_PROD__;\n\n/** @internal @security Messages may include user data. */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/arsenal] ${msg}`);\n}\n"],"mappings":"AAGA,SAAgB,KAAK,EAAmB,CAExC"}
|
|
1
|
+
{"version":3,"file":"_dev.cjs","names":[],"sources":["../src/_dev.ts"],"sourcesContent":["const isDev = !(globalThis as { __ARSENAL_PROD__?: boolean }).__ARSENAL_PROD__;\n\n/** @internal @security Messages may include user data. */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/arsenal] ${msg}`);\n}\n"],"mappings":"AAGA,SAAgB,KAAK,EAAmB,CAExC,C"}
|
package/dist/_dev.js
CHANGED
package/dist/_dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_dev.js","names":[],"sources":["../src/_dev.ts"],"sourcesContent":["const isDev = !(globalThis as { __ARSENAL_PROD__?: boolean }).__ARSENAL_PROD__;\n\n/** @internal @security Messages may include user data. */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/arsenal] ${msg}`);\n}\n"],"mappings":"AAGA,SAAgB,KAAK,
|
|
1
|
+
{"version":3,"file":"_dev.js","names":[],"sources":["../src/_dev.ts"],"sourcesContent":["const isDev = !(globalThis as { __ARSENAL_PROD__?: boolean }).__ARSENAL_PROD__;\n\n/** @internal @security Messages may include user data. */\nexport function warn(msg: string): void {\n if (isDev) console.warn(`[@vielzeug/arsenal] ${msg}`);\n}\n"],"mappings":";AAGA,SAAgB,KAAK,GAAmB,CAExC"}
|
package/dist/array/chunk.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk.cjs","names":[],"sources":["../../src/array/chunk.ts"],"sourcesContent":["/**\n * Splits an array or string into chunks of a specified size.\n *\n * @example\n * ```ts\n * chunk([1, 2, 3, 4, 5], 2) // [[1, 2], [3, 4], [5]]\n * chunk('hello', 2) // ['he', 'll', 'o']\n * ```\n *\n * @param input - The input array or string to be chunked.\n * @param size - The size of each chunk (default 2).\n *\n * @returns An array of chunks.\n *\n * @throws {TypeError} If the input is not an array or string.\n * @throws {RangeError} If the chunk size is not a positive integer.\n */\nexport function chunk(input: string, size?: number): string[];\nexport function chunk<T>(input: readonly T[], size?: number): T[][];\nexport function chunk<T>(input: readonly T[] | string, size = 2): string[] | T[][] {\n if (!Array.isArray(input) && typeof input !== 'string')\n throw new TypeError('chunk: argument must be an array or string');\n\n if (!Number.isInteger(size) || size < 1) throw new RangeError('chunk: size must be a positive integer');\n\n return Array.from({ length: Math.ceil(input.length / size) }, (_, i) => input.slice(i * size, i * size + size)) as\n | string[]\n | T[][];\n}\n"],"mappings":"AAmBA,SAAgB,MAAS,EAA8B,EAAO,EAAqB,CACjF,GAAI,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"chunk.cjs","names":["input","size","i"],"sources":["../../src/array/chunk.ts"],"sourcesContent":["/**\n * Splits an array or string into chunks of a specified size.\n *\n * @example\n * ```ts\n * chunk([1, 2, 3, 4, 5], 2) // [[1, 2], [3, 4], [5]]\n * chunk('hello', 2) // ['he', 'll', 'o']\n * ```\n *\n * @param input - The input array or string to be chunked.\n * @param size - The size of each chunk (default 2).\n *\n * @returns An array of chunks.\n *\n * @throws {TypeError} If the input is not an array or string.\n * @throws {RangeError} If the chunk size is not a positive integer.\n */\nexport function chunk(input: string, size?: number): string[];\nexport function chunk<T>(input: readonly T[], size?: number): T[][];\nexport function chunk<T>(input: readonly T[] | string, size = 2): string[] | T[][] {\n if (!Array.isArray(input) && typeof input !== 'string')\n throw new TypeError('chunk: argument must be an array or string');\n\n if (!Number.isInteger(size) || size < 1) throw new RangeError('chunk: size must be a positive integer');\n\n return Array.from({ length: Math.ceil(input.length / size) }, (_, i) => input.slice(i * size, i * size + size)) as\n | string[]\n | T[][];\n}\n"],"mappings":"AAmBA,SAAgB,MAAS,EAA8B,EAAO,EAAqB,CACjF,GAAI,CAAC,MAAM,QAAQA,CAAK,GAAK,OAAOA,GAAU,SAC5C,MAAU,UAAU,4CAA4C,EAElE,GAAI,CAAC,OAAO,UAAUC,CAAI,GAAKA,EAAO,EAAG,MAAU,WAAW,wCAAwC,EAEtG,OAAO,MAAM,KAAK,CAAE,OAAQ,KAAK,KAAKD,EAAM,OAASC,CAAI,CAAE,GAAI,EAAG,IAAMD,EAAM,MAAME,EAAID,EAAMC,EAAID,EAAOA,CAAI,CAAC,CAGhH,C"}
|
package/dist/array/chunk.js
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/array/chunk.ts
|
|
2
|
+
function chunk(e, t = 2) {
|
|
3
|
+
if (!Array.isArray(e) && typeof e != "string") throw TypeError("chunk: argument must be an array or string");
|
|
4
|
+
if (!Number.isInteger(t) || t < 1) throw RangeError("chunk: size must be a positive integer");
|
|
5
|
+
return Array.from({ length: Math.ceil(e.length / t) }, (n, r) => e.slice(r * t, r * t + t));
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { chunk };
|
|
9
|
+
|
|
2
10
|
//# sourceMappingURL=chunk.js.map
|
package/dist/array/chunk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk.js","names":[],"sources":["../../src/array/chunk.ts"],"sourcesContent":["/**\n * Splits an array or string into chunks of a specified size.\n *\n * @example\n * ```ts\n * chunk([1, 2, 3, 4, 5], 2) // [[1, 2], [3, 4], [5]]\n * chunk('hello', 2) // ['he', 'll', 'o']\n * ```\n *\n * @param input - The input array or string to be chunked.\n * @param size - The size of each chunk (default 2).\n *\n * @returns An array of chunks.\n *\n * @throws {TypeError} If the input is not an array or string.\n * @throws {RangeError} If the chunk size is not a positive integer.\n */\nexport function chunk(input: string, size?: number): string[];\nexport function chunk<T>(input: readonly T[], size?: number): T[][];\nexport function chunk<T>(input: readonly T[] | string, size = 2): string[] | T[][] {\n if (!Array.isArray(input) && typeof input !== 'string')\n throw new TypeError('chunk: argument must be an array or string');\n\n if (!Number.isInteger(size) || size < 1) throw new RangeError('chunk: size must be a positive integer');\n\n return Array.from({ length: Math.ceil(input.length / size) }, (_, i) => input.slice(i * size, i * size + size)) as\n | string[]\n | T[][];\n}\n"],"mappings":"AAmBA,SAAgB,MAAS,
|
|
1
|
+
{"version":3,"file":"chunk.js","names":["input","size","i"],"sources":["../../src/array/chunk.ts"],"sourcesContent":["/**\n * Splits an array or string into chunks of a specified size.\n *\n * @example\n * ```ts\n * chunk([1, 2, 3, 4, 5], 2) // [[1, 2], [3, 4], [5]]\n * chunk('hello', 2) // ['he', 'll', 'o']\n * ```\n *\n * @param input - The input array or string to be chunked.\n * @param size - The size of each chunk (default 2).\n *\n * @returns An array of chunks.\n *\n * @throws {TypeError} If the input is not an array or string.\n * @throws {RangeError} If the chunk size is not a positive integer.\n */\nexport function chunk(input: string, size?: number): string[];\nexport function chunk<T>(input: readonly T[], size?: number): T[][];\nexport function chunk<T>(input: readonly T[] | string, size = 2): string[] | T[][] {\n if (!Array.isArray(input) && typeof input !== 'string')\n throw new TypeError('chunk: argument must be an array or string');\n\n if (!Number.isInteger(size) || size < 1) throw new RangeError('chunk: size must be a positive integer');\n\n return Array.from({ length: Math.ceil(input.length / size) }, (_, i) => input.slice(i * size, i * size + size)) as\n | string[]\n | T[][];\n}\n"],"mappings":";AAmBA,SAAgB,MAAS,GAA8B,IAAO,GAAqB;CACjF,IAAI,CAAC,MAAM,QAAQA,CAAK,KAAK,OAAOA,KAAU,UAC5C,MAAU,UAAU,4CAA4C;CAElE,IAAI,CAAC,OAAO,UAAUC,CAAI,KAAKA,IAAO,GAAG,MAAU,WAAW,wCAAwC;CAEtG,OAAO,MAAM,KAAK,EAAE,QAAQ,KAAK,KAAKD,EAAM,SAASC,CAAI,EAAE,IAAI,GAAG,MAAMD,EAAM,MAAME,IAAID,GAAMC,IAAID,IAAOA,CAAI,CAAC;AAGhH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compact.cjs","names":[],"sources":["../../src/array/compact.ts"],"sourcesContent":["type Falsy = false | '' | 0 | 0n | null | undefined;\n\n/**\n * Creates a new array with all falsy values removed.\n */\nexport function compact<T>(array: readonly T[]): Array<Exclude<T, Falsy>> {\n return array.filter(Boolean) as Array<Exclude<T, Falsy>>;\n}\n"],"mappings":"AAKA,SAAgB,QAAW,EAA+C,CACxE,
|
|
1
|
+
{"version":3,"file":"compact.cjs","names":["array"],"sources":["../../src/array/compact.ts"],"sourcesContent":["type Falsy = false | '' | 0 | 0n | null | undefined;\n\n/**\n * Creates a new array with all falsy values removed.\n */\nexport function compact<T>(array: readonly T[]): Array<Exclude<T, Falsy>> {\n return array.filter(Boolean) as Array<Exclude<T, Falsy>>;\n}\n"],"mappings":"AAKA,SAAgB,QAAW,EAA+C,CACxE,OAAOA,EAAM,OAAO,OAAO,CAC7B,C"}
|
package/dist/array/compact.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compact.js","names":[],"sources":["../../src/array/compact.ts"],"sourcesContent":["type Falsy = false | '' | 0 | 0n | null | undefined;\n\n/**\n * Creates a new array with all falsy values removed.\n */\nexport function compact<T>(array: readonly T[]): Array<Exclude<T, Falsy>> {\n return array.filter(Boolean) as Array<Exclude<T, Falsy>>;\n}\n"],"mappings":"AAKA,SAAgB,QAAW,
|
|
1
|
+
{"version":3,"file":"compact.js","names":["array"],"sources":["../../src/array/compact.ts"],"sourcesContent":["type Falsy = false | '' | 0 | 0n | null | undefined;\n\n/**\n * Creates a new array with all falsy values removed.\n */\nexport function compact<T>(array: readonly T[]): Array<Exclude<T, Falsy>> {\n return array.filter(Boolean) as Array<Exclude<T, Falsy>>;\n}\n"],"mappings":";AAKA,SAAgB,QAAW,GAA+C;CACxE,OAAOA,EAAM,OAAO,OAAO;AAC7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compare.cjs","names":[],"sources":["../../src/array/compare.ts"],"sourcesContent":["/**\n * Compares two values and returns a number suitable for use as a sort comparator.\n *\n * - Numbers and Dates: returns `0`, `1`, or `-1`.\n * - Strings: delegates to `String.prototype.localeCompare`, which may return any integer\n * (not just `0`, `1`, `-1`) depending on locale and engine.\n * - `null` sorts before all non-null values; `undefined` sorts last.\n *\n * @example\n * ```ts\n * compare('a', 'b'); // negative (locale-dependent)\n * compare(1, 2); // -1\n * compare(new Date('2023-01-01'), new Date('2023-01-02')); // -1\n * compare('a', 'a'); // 0\n * compare(1, 1); // 0\n * compare(new Date('2023-01-01'), new Date('2023-01-01')); // 0\n * ```\n *\n * @param a - The first value to compare.\n * @param b - The second value to compare.\n *\n * @returns A negative number, zero, or a positive number.\n *\n * Pass directly as an `Array.sort` comparator:\n * ```ts\n * [3, 1, 2].sort(compare); // [1, 2, 3]\n * ['banana', 'apple', 'cherry'].sort(compare); // ['apple', 'banana', 'cherry']\n * ```\n */\nexport const compare = (a: unknown, b: unknown): number => {\n if (a === b) return 0;\n\n if (a === undefined) return 1;\n\n if (b === undefined) return -1;\n\n if (a === null) return b === null ? 0 : -1;\n\n if (b === null) return 1;\n\n if (typeof a === 'string' && typeof b === 'string') {\n return a.localeCompare(b);\n }\n\n if (typeof a === 'number' && typeof b === 'number') {\n return a === b ? 0 : a > b ? 1 : -1;\n }\n\n if (a instanceof Date && b instanceof Date) {\n const at = a.getTime();\n const bt = b.getTime();\n\n return at === bt ? 0 : at > bt ? 1 : -1;\n }\n\n throw new TypeError(\n `compare: unsupported types \"${typeof a}\" and \"${typeof b}\". Supported: number, string, Date, null, undefined.`,\n );\n};\n"],"mappings":"AA6BA,IAAa,SAAW,EAAY,IAAuB,CACzD,
|
|
1
|
+
{"version":3,"file":"compare.cjs","names":["a","b","at","bt"],"sources":["../../src/array/compare.ts"],"sourcesContent":["/**\n * Compares two values and returns a number suitable for use as a sort comparator.\n *\n * - Numbers and Dates: returns `0`, `1`, or `-1`.\n * - Strings: delegates to `String.prototype.localeCompare`, which may return any integer\n * (not just `0`, `1`, `-1`) depending on locale and engine.\n * - `null` sorts before all non-null values; `undefined` sorts last.\n *\n * @example\n * ```ts\n * compare('a', 'b'); // negative (locale-dependent)\n * compare(1, 2); // -1\n * compare(new Date('2023-01-01'), new Date('2023-01-02')); // -1\n * compare('a', 'a'); // 0\n * compare(1, 1); // 0\n * compare(new Date('2023-01-01'), new Date('2023-01-01')); // 0\n * ```\n *\n * @param a - The first value to compare.\n * @param b - The second value to compare.\n *\n * @returns A negative number, zero, or a positive number.\n *\n * Pass directly as an `Array.sort` comparator:\n * ```ts\n * [3, 1, 2].sort(compare); // [1, 2, 3]\n * ['banana', 'apple', 'cherry'].sort(compare); // ['apple', 'banana', 'cherry']\n * ```\n */\nexport const compare = (a: unknown, b: unknown): number => {\n if (a === b) return 0;\n\n if (a === undefined) return 1;\n\n if (b === undefined) return -1;\n\n if (a === null) return b === null ? 0 : -1;\n\n if (b === null) return 1;\n\n if (typeof a === 'string' && typeof b === 'string') {\n return a.localeCompare(b);\n }\n\n if (typeof a === 'number' && typeof b === 'number') {\n return a === b ? 0 : a > b ? 1 : -1;\n }\n\n if (a instanceof Date && b instanceof Date) {\n const at = a.getTime();\n const bt = b.getTime();\n\n return at === bt ? 0 : at > bt ? 1 : -1;\n }\n\n throw new TypeError(\n `compare: unsupported types \"${typeof a}\" and \"${typeof b}\". Supported: number, string, Date, null, undefined.`,\n );\n};\n"],"mappings":"AA6BA,IAAa,SAAW,EAAY,IAAuB,CACzD,GAAIA,IAAMC,EAAG,MAAO,GAEpB,GAAID,IAAM,IAAA,GAAW,MAAO,GAE5B,GAAIC,IAAM,IAAA,GAAW,MAAO,GAE5B,GAAID,IAAM,KAAM,OAAOC,IAAM,KAAO,EAAI,GAExC,GAAIA,IAAM,KAAM,MAAO,GAEvB,GAAI,OAAOD,GAAM,UAAY,OAAOC,GAAM,SACxC,OAAOD,EAAE,cAAcC,CAAC,EAG1B,GAAI,OAAOD,GAAM,UAAY,OAAOC,GAAM,SACxC,OAAOD,IAAMC,EAAI,EAAID,EAAIC,EAAI,EAAI,GAGnC,GAAID,aAAa,MAAQC,aAAa,KAAM,CAC1C,IAAMC,EAAKF,EAAE,QAAQ,EACfG,EAAKF,EAAE,QAAQ,EAErB,OAAOC,IAAOC,EAAK,EAAID,EAAKC,EAAK,EAAI,EACvC,CAEA,MAAU,UACR,+BAA+B,OAAOH,EAAE,SAAS,OAAOC,EAAE,qDAC5D,CACF,E"}
|
package/dist/array/compare.js
CHANGED
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/array/compare.ts
|
|
2
|
+
var compare = (e, t) => {
|
|
3
|
+
if (e === t) return 0;
|
|
4
|
+
if (e === void 0) return 1;
|
|
5
|
+
if (t === void 0) return -1;
|
|
6
|
+
if (e === null) return t === null ? 0 : -1;
|
|
7
|
+
if (t === null) return 1;
|
|
8
|
+
if (typeof e == "string" && typeof t == "string") return e.localeCompare(t);
|
|
9
|
+
if (typeof e == "number" && typeof t == "number") return e === t ? 0 : e > t ? 1 : -1;
|
|
10
|
+
if (e instanceof Date && t instanceof Date) {
|
|
11
|
+
let n = e.getTime(), r = t.getTime();
|
|
12
|
+
return n === r ? 0 : n > r ? 1 : -1;
|
|
13
|
+
}
|
|
14
|
+
throw TypeError(`compare: unsupported types "${typeof e}" and "${typeof t}". Supported: number, string, Date, null, undefined.`);
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { compare };
|
|
18
|
+
|
|
2
19
|
//# sourceMappingURL=compare.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compare.js","names":[],"sources":["../../src/array/compare.ts"],"sourcesContent":["/**\n * Compares two values and returns a number suitable for use as a sort comparator.\n *\n * - Numbers and Dates: returns `0`, `1`, or `-1`.\n * - Strings: delegates to `String.prototype.localeCompare`, which may return any integer\n * (not just `0`, `1`, `-1`) depending on locale and engine.\n * - `null` sorts before all non-null values; `undefined` sorts last.\n *\n * @example\n * ```ts\n * compare('a', 'b'); // negative (locale-dependent)\n * compare(1, 2); // -1\n * compare(new Date('2023-01-01'), new Date('2023-01-02')); // -1\n * compare('a', 'a'); // 0\n * compare(1, 1); // 0\n * compare(new Date('2023-01-01'), new Date('2023-01-01')); // 0\n * ```\n *\n * @param a - The first value to compare.\n * @param b - The second value to compare.\n *\n * @returns A negative number, zero, or a positive number.\n *\n * Pass directly as an `Array.sort` comparator:\n * ```ts\n * [3, 1, 2].sort(compare); // [1, 2, 3]\n * ['banana', 'apple', 'cherry'].sort(compare); // ['apple', 'banana', 'cherry']\n * ```\n */\nexport const compare = (a: unknown, b: unknown): number => {\n if (a === b) return 0;\n\n if (a === undefined) return 1;\n\n if (b === undefined) return -1;\n\n if (a === null) return b === null ? 0 : -1;\n\n if (b === null) return 1;\n\n if (typeof a === 'string' && typeof b === 'string') {\n return a.localeCompare(b);\n }\n\n if (typeof a === 'number' && typeof b === 'number') {\n return a === b ? 0 : a > b ? 1 : -1;\n }\n\n if (a instanceof Date && b instanceof Date) {\n const at = a.getTime();\n const bt = b.getTime();\n\n return at === bt ? 0 : at > bt ? 1 : -1;\n }\n\n throw new TypeError(\n `compare: unsupported types \"${typeof a}\" and \"${typeof b}\". Supported: number, string, Date, null, undefined.`,\n );\n};\n"],"mappings":"AA6BA,IAAa,
|
|
1
|
+
{"version":3,"file":"compare.js","names":["a","b","at","bt"],"sources":["../../src/array/compare.ts"],"sourcesContent":["/**\n * Compares two values and returns a number suitable for use as a sort comparator.\n *\n * - Numbers and Dates: returns `0`, `1`, or `-1`.\n * - Strings: delegates to `String.prototype.localeCompare`, which may return any integer\n * (not just `0`, `1`, `-1`) depending on locale and engine.\n * - `null` sorts before all non-null values; `undefined` sorts last.\n *\n * @example\n * ```ts\n * compare('a', 'b'); // negative (locale-dependent)\n * compare(1, 2); // -1\n * compare(new Date('2023-01-01'), new Date('2023-01-02')); // -1\n * compare('a', 'a'); // 0\n * compare(1, 1); // 0\n * compare(new Date('2023-01-01'), new Date('2023-01-01')); // 0\n * ```\n *\n * @param a - The first value to compare.\n * @param b - The second value to compare.\n *\n * @returns A negative number, zero, or a positive number.\n *\n * Pass directly as an `Array.sort` comparator:\n * ```ts\n * [3, 1, 2].sort(compare); // [1, 2, 3]\n * ['banana', 'apple', 'cherry'].sort(compare); // ['apple', 'banana', 'cherry']\n * ```\n */\nexport const compare = (a: unknown, b: unknown): number => {\n if (a === b) return 0;\n\n if (a === undefined) return 1;\n\n if (b === undefined) return -1;\n\n if (a === null) return b === null ? 0 : -1;\n\n if (b === null) return 1;\n\n if (typeof a === 'string' && typeof b === 'string') {\n return a.localeCompare(b);\n }\n\n if (typeof a === 'number' && typeof b === 'number') {\n return a === b ? 0 : a > b ? 1 : -1;\n }\n\n if (a instanceof Date && b instanceof Date) {\n const at = a.getTime();\n const bt = b.getTime();\n\n return at === bt ? 0 : at > bt ? 1 : -1;\n }\n\n throw new TypeError(\n `compare: unsupported types \"${typeof a}\" and \"${typeof b}\". Supported: number, string, Date, null, undefined.`,\n );\n};\n"],"mappings":";AA6BA,IAAa,WAAW,GAAY,MAAuB;CACzD,IAAIA,MAAMC,GAAG,OAAO;CAEpB,IAAID,MAAM,KAAA,GAAW,OAAO;CAE5B,IAAIC,MAAM,KAAA,GAAW,OAAO;CAE5B,IAAID,MAAM,MAAM,OAAOC,MAAM,OAAO,IAAI;CAExC,IAAIA,MAAM,MAAM,OAAO;CAEvB,IAAI,OAAOD,KAAM,YAAY,OAAOC,KAAM,UACxC,OAAOD,EAAE,cAAcC,CAAC;CAG1B,IAAI,OAAOD,KAAM,YAAY,OAAOC,KAAM,UACxC,OAAOD,MAAMC,IAAI,IAAID,IAAIC,IAAI,IAAI;CAGnC,IAAID,aAAa,QAAQC,aAAa,MAAM;EAC1C,IAAMC,IAAKF,EAAE,QAAQ,GACfG,IAAKF,EAAE,QAAQ;EAErB,OAAOC,MAAOC,IAAK,IAAID,IAAKC,IAAK,IAAI;CACvC;CAEA,MAAU,UACR,+BAA+B,OAAOH,EAAE,SAAS,OAAOC,EAAE,qDAC5D;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compareBy.cjs","names":[],"sources":["../../src/array/compareBy.ts"],"sourcesContent":["import { compare } from './compare';\n\n/**\n * Compares two objects based on multiple selectors.\n * The comparison is done in the order of the selectors provided.\n * Each selector can be 'asc' for ascending or 'desc' for descending order.\n *\n * @example\n * ```ts\n * const compareByNameAndAge = compareBy<{ name: string; age: number }>({\n * name: 'asc',\n * age: 'desc',\n * });\n *\n * const a = { name: 'Alice', age: 30 };\n * const b = { name: 'Bob', age: 25 };\n *\n * console.log(compareByNameAndAge(a, b)); // -1 (Alice < Bob)\n * ```\n *\n * @param selectors - An object where keys are properties to compare and values are 'asc' or 'desc'.\n *\n * @returns A comparator for use with `Array.sort` or `sort()`.\n */\nexport const compareBy = <T>(selectors: Partial<Record<keyof T, 'asc' | 'desc'>>) => {\n const entries = Object.entries(selectors) as [keyof T, 'asc' | 'desc'][];\n\n return (a: T, b: T) => {\n for (const [key, direction] of entries) {\n const v1 = a[key];\n const v2 = b[key];\n const dir = direction === 'desc' ? -1 : 1;\n\n const cmp = compare(v1, v2);\n\n if (cmp !== 0) return cmp * dir;\n }\n\n return 0;\n };\n};\n"],"mappings":"iCAwBA,IAAa,UAAgB,GAAwD,CACnF,
|
|
1
|
+
{"version":3,"file":"compareBy.cjs","names":["compare","require_compare","entries","selectors","key","direction","v1","a","v2","b","dir","cmp"],"sources":["../../src/array/compareBy.ts"],"sourcesContent":["import { compare } from './compare';\n\n/**\n * Compares two objects based on multiple selectors.\n * The comparison is done in the order of the selectors provided.\n * Each selector can be 'asc' for ascending or 'desc' for descending order.\n *\n * @example\n * ```ts\n * const compareByNameAndAge = compareBy<{ name: string; age: number }>({\n * name: 'asc',\n * age: 'desc',\n * });\n *\n * const a = { name: 'Alice', age: 30 };\n * const b = { name: 'Bob', age: 25 };\n *\n * console.log(compareByNameAndAge(a, b)); // -1 (Alice < Bob)\n * ```\n *\n * @param selectors - An object where keys are properties to compare and values are 'asc' or 'desc'.\n *\n * @returns A comparator for use with `Array.sort` or `sort()`.\n */\nexport const compareBy = <T>(selectors: Partial<Record<keyof T, 'asc' | 'desc'>>) => {\n const entries = Object.entries(selectors) as [keyof T, 'asc' | 'desc'][];\n\n return (a: T, b: T) => {\n for (const [key, direction] of entries) {\n const v1 = a[key];\n const v2 = b[key];\n const dir = direction === 'desc' ? -1 : 1;\n\n const cmp = compare(v1, v2);\n\n if (cmp !== 0) return cmp * dir;\n }\n\n return 0;\n };\n};\n"],"mappings":"A,iCAwBA,IAAa,UAAgB,GAAwD,CACnF,IAAME,EAAU,OAAO,QAAQC,CAAS,EAExC,OAAQ,EAAM,IAAS,CACrB,IAAK,GAAM,CAACC,EAAKC,KAAcH,EAAS,CACtC,IAAMI,EAAKC,EAAEH,GACPI,EAAKC,EAAEL,GACPM,EAAML,IAAc,OAAS,GAAK,EAElCM,EAAMX,EAAAA,QAAQM,EAAIE,CAAE,EAE1B,GAAIG,IAAQ,EAAG,OAAOA,EAAMD,CAC9B,CAEA,MAAO,EACT,CACF,E"}
|
package/dist/array/compareBy.js
CHANGED
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
import{compare as e}from"./compare.js";
|
|
1
|
+
import { compare as e } from "./compare.js";
|
|
2
|
+
//#region src/array/compareBy.ts
|
|
3
|
+
var compareBy = (t) => {
|
|
4
|
+
let n = Object.entries(t);
|
|
5
|
+
return (t, r) => {
|
|
6
|
+
for (let [i, a] of n) {
|
|
7
|
+
let n = t[i], o = r[i], s = a === "desc" ? -1 : 1, c = e(n, o);
|
|
8
|
+
if (c !== 0) return c * s;
|
|
9
|
+
}
|
|
10
|
+
return 0;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { compareBy };
|
|
15
|
+
|
|
2
16
|
//# sourceMappingURL=compareBy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compareBy.js","names":[],"sources":["../../src/array/compareBy.ts"],"sourcesContent":["import { compare } from './compare';\n\n/**\n * Compares two objects based on multiple selectors.\n * The comparison is done in the order of the selectors provided.\n * Each selector can be 'asc' for ascending or 'desc' for descending order.\n *\n * @example\n * ```ts\n * const compareByNameAndAge = compareBy<{ name: string; age: number }>({\n * name: 'asc',\n * age: 'desc',\n * });\n *\n * const a = { name: 'Alice', age: 30 };\n * const b = { name: 'Bob', age: 25 };\n *\n * console.log(compareByNameAndAge(a, b)); // -1 (Alice < Bob)\n * ```\n *\n * @param selectors - An object where keys are properties to compare and values are 'asc' or 'desc'.\n *\n * @returns A comparator for use with `Array.sort` or `sort()`.\n */\nexport const compareBy = <T>(selectors: Partial<Record<keyof T, 'asc' | 'desc'>>) => {\n const entries = Object.entries(selectors) as [keyof T, 'asc' | 'desc'][];\n\n return (a: T, b: T) => {\n for (const [key, direction] of entries) {\n const v1 = a[key];\n const v2 = b[key];\n const dir = direction === 'desc' ? -1 : 1;\n\n const cmp = compare(v1, v2);\n\n if (cmp !== 0) return cmp * dir;\n }\n\n return 0;\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"compareBy.js","names":["entries","selectors","key","direction","v1","a","v2","b","dir","cmp","compare"],"sources":["../../src/array/compareBy.ts"],"sourcesContent":["import { compare } from './compare';\n\n/**\n * Compares two objects based on multiple selectors.\n * The comparison is done in the order of the selectors provided.\n * Each selector can be 'asc' for ascending or 'desc' for descending order.\n *\n * @example\n * ```ts\n * const compareByNameAndAge = compareBy<{ name: string; age: number }>({\n * name: 'asc',\n * age: 'desc',\n * });\n *\n * const a = { name: 'Alice', age: 30 };\n * const b = { name: 'Bob', age: 25 };\n *\n * console.log(compareByNameAndAge(a, b)); // -1 (Alice < Bob)\n * ```\n *\n * @param selectors - An object where keys are properties to compare and values are 'asc' or 'desc'.\n *\n * @returns A comparator for use with `Array.sort` or `sort()`.\n */\nexport const compareBy = <T>(selectors: Partial<Record<keyof T, 'asc' | 'desc'>>) => {\n const entries = Object.entries(selectors) as [keyof T, 'asc' | 'desc'][];\n\n return (a: T, b: T) => {\n for (const [key, direction] of entries) {\n const v1 = a[key];\n const v2 = b[key];\n const dir = direction === 'desc' ? -1 : 1;\n\n const cmp = compare(v1, v2);\n\n if (cmp !== 0) return cmp * dir;\n }\n\n return 0;\n };\n};\n"],"mappings":";;AAwBA,IAAa,aAAgB,MAAwD;CACnF,IAAMA,IAAU,OAAO,QAAQC,CAAS;CAExC,QAAQ,GAAM,MAAS;EACrB,KAAK,IAAM,CAACC,GAAKC,MAAcH,GAAS;GACtC,IAAMI,IAAKC,EAAEH,IACPI,IAAKC,EAAEL,IACPM,IAAML,MAAc,SAAS,KAAK,GAElCM,IAAMC,EAAQN,GAAIE,CAAE;GAE1B,IAAIG,MAAQ,GAAG,OAAOA,IAAMD;EAC9B;EAEA,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contains.cjs","names":[],"sources":["../../src/array/contains.ts"],"sourcesContent":["import { isEqual } from '../guards/isEqual';\n\n/**\n * Checks if a value is present in an array.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, { a: 1 }, 'hello'];\n * const value = { a: 1 };\n * contains(arr, value) // true;\n * ```\n *\n * @param array - The array to check.\n * @param value - The value to search for.\n *\n * @returns true if the value is present in the array, else false.\n */\n\nexport function contains<T>(array: readonly T[], value: unknown): boolean {\n // Fast path: reference / primitive equality via Array.includes: avoids\n // deep-equal traversal for the common case of searching for a scalar.\n if (value === null || value === undefined || typeof value !== 'object') {\n return array.includes(value as T);\n }\n\n return array.some((val) => isEqual(val, value));\n}\n"],"mappings":"yCAkBA,SAAgB,SAAY,EAAqB,EAAyB,CAOxE,OAJ6C,
|
|
1
|
+
{"version":3,"file":"contains.cjs","names":["isEqual","require_isEqual","value","array","val"],"sources":["../../src/array/contains.ts"],"sourcesContent":["import { isEqual } from '../guards/isEqual';\n\n/**\n * Checks if a value is present in an array.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, { a: 1 }, 'hello'];\n * const value = { a: 1 };\n * contains(arr, value) // true;\n * ```\n *\n * @param array - The array to check.\n * @param value - The value to search for.\n *\n * @returns true if the value is present in the array, else false.\n */\n\nexport function contains<T>(array: readonly T[], value: unknown): boolean {\n // Fast path: reference / primitive equality via Array.includes: avoids\n // deep-equal traversal for the common case of searching for a scalar.\n if (value === null || value === undefined || typeof value !== 'object') {\n return array.includes(value as T);\n }\n\n return array.some((val) => isEqual(val, value));\n}\n"],"mappings":"A,yCAkBA,SAAgB,SAAY,EAAqB,EAAyB,CAOxE,OAJ6C,OAAOE,GAAU,WAA1DA,EACKC,EAAM,SAASD,CAAU,EAG3BC,EAAM,KAAM,GAAQH,EAAAA,QAAQI,EAAKF,CAAK,CAAC,CAChD,C"}
|
package/dist/array/contains.js
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
import{isEqual as e}from"../guards/isEqual.js";
|
|
1
|
+
import { isEqual as e } from "../guards/isEqual.js";
|
|
2
|
+
//#region src/array/contains.ts
|
|
3
|
+
function contains(t, n) {
|
|
4
|
+
return typeof n != "object" || !n ? t.includes(n) : t.some((t) => e(t, n));
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { contains };
|
|
8
|
+
|
|
2
9
|
//# sourceMappingURL=contains.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contains.js","names":[],"sources":["../../src/array/contains.ts"],"sourcesContent":["import { isEqual } from '../guards/isEqual';\n\n/**\n * Checks if a value is present in an array.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, { a: 1 }, 'hello'];\n * const value = { a: 1 };\n * contains(arr, value) // true;\n * ```\n *\n * @param array - The array to check.\n * @param value - The value to search for.\n *\n * @returns true if the value is present in the array, else false.\n */\n\nexport function contains<T>(array: readonly T[], value: unknown): boolean {\n // Fast path: reference / primitive equality via Array.includes: avoids\n // deep-equal traversal for the common case of searching for a scalar.\n if (value === null || value === undefined || typeof value !== 'object') {\n return array.includes(value as T);\n }\n\n return array.some((val) => isEqual(val, value));\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"contains.js","names":["value","array","isEqual","val"],"sources":["../../src/array/contains.ts"],"sourcesContent":["import { isEqual } from '../guards/isEqual';\n\n/**\n * Checks if a value is present in an array.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, { a: 1 }, 'hello'];\n * const value = { a: 1 };\n * contains(arr, value) // true;\n * ```\n *\n * @param array - The array to check.\n * @param value - The value to search for.\n *\n * @returns true if the value is present in the array, else false.\n */\n\nexport function contains<T>(array: readonly T[], value: unknown): boolean {\n // Fast path: reference / primitive equality via Array.includes: avoids\n // deep-equal traversal for the common case of searching for a scalar.\n if (value === null || value === undefined || typeof value !== 'object') {\n return array.includes(value as T);\n }\n\n return array.some((val) => isEqual(val, value));\n}\n"],"mappings":";;AAkBA,SAAgB,SAAY,GAAqB,GAAyB;CAOxE,OAJ6C,OAAOA,KAAU,aAA1DA,IACKC,EAAM,SAASD,CAAU,IAG3BC,EAAM,MAAM,MAAQC,EAAQC,GAAKH,CAAK,CAAC;AAChD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"countBy.cjs","names":[],"sources":["../../src/array/countBy.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Primitive } from '../types';\n\n/**\n * Counts elements in an array by selector output. Selector results of `null`/`undefined` are\n * bucketed under the key `'_'`, matching `groupBy`'s convention. Dangerous keys (`__proto__`,\n * `constructor`, `prototype`) are skipped.\n */\nexport function countBy<T>(array: readonly T[], selector: (item: T) => Primitive): Record<string, number> {\n const out: Record<string, number> = {};\n\n for (let index = 0; index < array.length; index++) {\n const rawKey = selector(array[index]);\n const key = rawKey === undefined || rawKey === null ? '_' : String(rawKey);\n\n if (isUnsafeKey(key)) continue;\n\n out[key] = (out[key] ?? 0) + 1;\n }\n\n return out;\n}\n"],"mappings":"8CAQA,SAAgB,QAAW,EAAqB,EAA0D,CACxG,
|
|
1
|
+
{"version":3,"file":"countBy.cjs","names":["isUnsafeKey","require_unsafePaths","out","index","array","rawKey","selector","key"],"sources":["../../src/array/countBy.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Primitive } from '../types';\n\n/**\n * Counts elements in an array by selector output. Selector results of `null`/`undefined` are\n * bucketed under the key `'_'`, matching `groupBy`'s convention. Dangerous keys (`__proto__`,\n * `constructor`, `prototype`) are skipped.\n */\nexport function countBy<T>(array: readonly T[], selector: (item: T) => Primitive): Record<string, number> {\n const out: Record<string, number> = {};\n\n for (let index = 0; index < array.length; index++) {\n const rawKey = selector(array[index]);\n const key = rawKey === undefined || rawKey === null ? '_' : String(rawKey);\n\n if (isUnsafeKey(key)) continue;\n\n out[key] = (out[key] ?? 0) + 1;\n }\n\n return out;\n}\n"],"mappings":"A,8CAQA,SAAgB,QAAW,EAAqB,EAA0D,CACxG,IAAME,EAA8B,CAAC,EAErC,IAAK,IAAIC,EAAQ,EAAGA,EAAQC,EAAM,OAAQ,IAAS,CACjD,IAAMC,EAASC,EAASF,EAAMD,EAAM,EAC9BI,EAAMF,GAAmC,KAAO,IAAM,OAAOA,CAAM,EAErEL,EAAAA,YAAYO,CAAG,IAEnB,EAAIA,IAAQL,EAAIK,IAAQ,GAAK,EAC/B,CAEA,OAAOL,CACT,C"}
|
package/dist/array/countBy.js
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
import{isUnsafeKey as e}from"../_common/unsafePaths.js";
|
|
1
|
+
import { isUnsafeKey as e } from "../_common/unsafePaths.js";
|
|
2
|
+
//#region src/array/countBy.ts
|
|
3
|
+
function countBy(t, n) {
|
|
4
|
+
let r = {};
|
|
5
|
+
for (let i = 0; i < t.length; i++) {
|
|
6
|
+
let a = n(t[i]), o = a == null ? "_" : String(a);
|
|
7
|
+
e(o) || (r[o] = (r[o] ?? 0) + 1);
|
|
8
|
+
}
|
|
9
|
+
return r;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { countBy };
|
|
13
|
+
|
|
2
14
|
//# sourceMappingURL=countBy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"countBy.js","names":[],"sources":["../../src/array/countBy.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Primitive } from '../types';\n\n/**\n * Counts elements in an array by selector output. Selector results of `null`/`undefined` are\n * bucketed under the key `'_'`, matching `groupBy`'s convention. Dangerous keys (`__proto__`,\n * `constructor`, `prototype`) are skipped.\n */\nexport function countBy<T>(array: readonly T[], selector: (item: T) => Primitive): Record<string, number> {\n const out: Record<string, number> = {};\n\n for (let index = 0; index < array.length; index++) {\n const rawKey = selector(array[index]);\n const key = rawKey === undefined || rawKey === null ? '_' : String(rawKey);\n\n if (isUnsafeKey(key)) continue;\n\n out[key] = (out[key] ?? 0) + 1;\n }\n\n return out;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"countBy.js","names":["out","index","array","rawKey","selector","key","isUnsafeKey"],"sources":["../../src/array/countBy.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Primitive } from '../types';\n\n/**\n * Counts elements in an array by selector output. Selector results of `null`/`undefined` are\n * bucketed under the key `'_'`, matching `groupBy`'s convention. Dangerous keys (`__proto__`,\n * `constructor`, `prototype`) are skipped.\n */\nexport function countBy<T>(array: readonly T[], selector: (item: T) => Primitive): Record<string, number> {\n const out: Record<string, number> = {};\n\n for (let index = 0; index < array.length; index++) {\n const rawKey = selector(array[index]);\n const key = rawKey === undefined || rawKey === null ? '_' : String(rawKey);\n\n if (isUnsafeKey(key)) continue;\n\n out[key] = (out[key] ?? 0) + 1;\n }\n\n return out;\n}\n"],"mappings":";;AAQA,SAAgB,QAAW,GAAqB,GAA0D;CACxG,IAAMA,IAA8B,CAAC;CAErC,KAAK,IAAIC,IAAQ,GAAGA,IAAQC,EAAM,QAAQ,KAAS;EACjD,IAAMC,IAASC,EAASF,EAAMD,EAAM,GAC9BI,IAAMF,KAAmC,OAAO,MAAM,OAAOA,CAAM;EAEzE,AAAIG,EAAYD,CAAG,MAEnB,EAAIA,MAAQL,EAAIK,MAAQ,KAAK;CAC/B;CAEA,OAAOL;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"difference.cjs","names":[],"sources":["../../src/array/difference.ts"],"sourcesContent":["import { toSelectorSet } from '../_common/_selectorSet';\nimport type { Primitive } from '../types';\n\n/**\n * Returns elements that are in `source` but not in `other`.\n *\n * Allocates a `Set` from `other` for O(1) membership checks, plus a new array for the result.\n */\nexport function difference<T>(source: readonly T[], other: readonly T[], selector?: (item: T) => Primitive): T[] {\n if (!selector) {\n const deny = new Set(other);\n\n return source.filter((item) => !deny.has(item));\n }\n\n const deny = toSelectorSet(other, selector);\n\n return source.filter((item) => !deny.has(selector(item)));\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"difference.cjs","names":["toSelectorSet","require__selectorSet","selector","deny","other","source","item"],"sources":["../../src/array/difference.ts"],"sourcesContent":["import { toSelectorSet } from '../_common/_selectorSet';\nimport type { Primitive } from '../types';\n\n/**\n * Returns elements that are in `source` but not in `other`.\n *\n * Allocates a `Set` from `other` for O(1) membership checks, plus a new array for the result.\n */\nexport function difference<T>(source: readonly T[], other: readonly T[], selector?: (item: T) => Primitive): T[] {\n if (!selector) {\n const deny = new Set(other);\n\n return source.filter((item) => !deny.has(item));\n }\n\n const deny = toSelectorSet(other, selector);\n\n return source.filter((item) => !deny.has(selector(item)));\n}\n"],"mappings":"A,+CAQA,SAAgB,WAAc,EAAsB,EAAqB,EAAwC,CAC/G,GAAI,CAACE,EAAU,CACb,IAAMC,EAAO,IAAI,IAAIC,CAAK,EAE1B,OAAOC,EAAO,OAAQ,GAAS,CAACF,EAAK,IAAIG,CAAI,CAAC,CAChD,CAEA,IAAMH,EAAOH,EAAAA,cAAcI,EAAOF,CAAQ,EAE1C,OAAOG,EAAO,OAAQ,GAAS,CAACF,EAAK,IAAID,EAASI,CAAI,CAAC,CAAC,CAC1D,C"}
|
package/dist/array/difference.js
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
import{toSelectorSet as e}from"../_common/_selectorSet.js";
|
|
1
|
+
import { toSelectorSet as e } from "../_common/_selectorSet.js";
|
|
2
|
+
//#region src/array/difference.ts
|
|
3
|
+
function difference(t, n, r) {
|
|
4
|
+
if (!r) {
|
|
5
|
+
let e = new Set(n);
|
|
6
|
+
return t.filter((t) => !e.has(t));
|
|
7
|
+
}
|
|
8
|
+
let i = e(n, r);
|
|
9
|
+
return t.filter((e) => !i.has(r(e)));
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { difference };
|
|
13
|
+
|
|
2
14
|
//# sourceMappingURL=difference.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"difference.js","names":[],"sources":["../../src/array/difference.ts"],"sourcesContent":["import { toSelectorSet } from '../_common/_selectorSet';\nimport type { Primitive } from '../types';\n\n/**\n * Returns elements that are in `source` but not in `other`.\n *\n * Allocates a `Set` from `other` for O(1) membership checks, plus a new array for the result.\n */\nexport function difference<T>(source: readonly T[], other: readonly T[], selector?: (item: T) => Primitive): T[] {\n if (!selector) {\n const deny = new Set(other);\n\n return source.filter((item) => !deny.has(item));\n }\n\n const deny = toSelectorSet(other, selector);\n\n return source.filter((item) => !deny.has(selector(item)));\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"difference.js","names":["selector","deny","other","source","item","toSelectorSet"],"sources":["../../src/array/difference.ts"],"sourcesContent":["import { toSelectorSet } from '../_common/_selectorSet';\nimport type { Primitive } from '../types';\n\n/**\n * Returns elements that are in `source` but not in `other`.\n *\n * Allocates a `Set` from `other` for O(1) membership checks, plus a new array for the result.\n */\nexport function difference<T>(source: readonly T[], other: readonly T[], selector?: (item: T) => Primitive): T[] {\n if (!selector) {\n const deny = new Set(other);\n\n return source.filter((item) => !deny.has(item));\n }\n\n const deny = toSelectorSet(other, selector);\n\n return source.filter((item) => !deny.has(selector(item)));\n}\n"],"mappings":";;AAQA,SAAgB,WAAc,GAAsB,GAAqB,GAAwC;CAC/G,IAAI,CAACA,GAAU;EACb,IAAMC,IAAO,IAAI,IAAIC,CAAK;EAE1B,OAAOC,EAAO,QAAQ,MAAS,CAACF,EAAK,IAAIG,CAAI,CAAC;CAChD;CAEA,IAAMH,IAAOI,EAAcH,GAAOF,CAAQ;CAE1C,OAAOG,EAAO,QAAQ,MAAS,CAACF,EAAK,IAAID,EAASI,CAAI,CAAC,CAAC;AAC1D"}
|
package/dist/array/drop.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drop.cjs","names":[],"sources":["../../src/array/drop.ts"],"sourcesContent":["/**\n * Drops the first n elements from an array.\n */\nexport function drop<T>(array: readonly T[], n = 1): T[] {\n const count = Math.max(0, Math.floor(n));\n\n return array.slice(count);\n}\n"],"mappings":"AAGA,SAAgB,KAAQ,EAAqB,EAAI,EAAQ,CACvD,
|
|
1
|
+
{"version":3,"file":"drop.cjs","names":["count","n","array"],"sources":["../../src/array/drop.ts"],"sourcesContent":["/**\n * Drops the first n elements from an array.\n */\nexport function drop<T>(array: readonly T[], n = 1): T[] {\n const count = Math.max(0, Math.floor(n));\n\n return array.slice(count);\n}\n"],"mappings":"AAGA,SAAgB,KAAQ,EAAqB,EAAI,EAAQ,CACvD,IAAMA,EAAQ,KAAK,IAAI,EAAG,KAAK,MAAMC,CAAC,CAAC,EAEvC,OAAOC,EAAM,MAAMF,CAAK,CAC1B,C"}
|
package/dist/array/drop.js
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/array/drop.ts
|
|
2
|
+
function drop(e, t = 1) {
|
|
3
|
+
let n = Math.max(0, Math.floor(t));
|
|
4
|
+
return e.slice(n);
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { drop };
|
|
8
|
+
|
|
2
9
|
//# sourceMappingURL=drop.js.map
|
package/dist/array/drop.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drop.js","names":[],"sources":["../../src/array/drop.ts"],"sourcesContent":["/**\n * Drops the first n elements from an array.\n */\nexport function drop<T>(array: readonly T[], n = 1): T[] {\n const count = Math.max(0, Math.floor(n));\n\n return array.slice(count);\n}\n"],"mappings":"AAGA,SAAgB,KAAQ,
|
|
1
|
+
{"version":3,"file":"drop.js","names":["count","n","array"],"sources":["../../src/array/drop.ts"],"sourcesContent":["/**\n * Drops the first n elements from an array.\n */\nexport function drop<T>(array: readonly T[], n = 1): T[] {\n const count = Math.max(0, Math.floor(n));\n\n return array.slice(count);\n}\n"],"mappings":";AAGA,SAAgB,KAAQ,GAAqB,IAAI,GAAQ;CACvD,IAAMA,IAAQ,KAAK,IAAI,GAAG,KAAK,MAAMC,CAAC,CAAC;CAEvC,OAAOC,EAAM,MAAMF,CAAK;AAC1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropLast.cjs","names":[],"sources":["../../src/array/dropLast.ts"],"sourcesContent":["/**\n * Drops the last n elements from an array.\n */\nexport function dropLast<T>(array: readonly T[], n = 1): T[] {\n const count = Math.max(0, Math.floor(n));\n\n if (count === 0) return [...array];\n\n return array.slice(0, Math.max(0, array.length - count));\n}\n"],"mappings":"AAGA,SAAgB,SAAY,EAAqB,EAAI,EAAQ,CAC3D,
|
|
1
|
+
{"version":3,"file":"dropLast.cjs","names":["count","n","array"],"sources":["../../src/array/dropLast.ts"],"sourcesContent":["/**\n * Drops the last n elements from an array.\n */\nexport function dropLast<T>(array: readonly T[], n = 1): T[] {\n const count = Math.max(0, Math.floor(n));\n\n if (count === 0) return [...array];\n\n return array.slice(0, Math.max(0, array.length - count));\n}\n"],"mappings":"AAGA,SAAgB,SAAY,EAAqB,EAAI,EAAQ,CAC3D,IAAMA,EAAQ,KAAK,IAAI,EAAG,KAAK,MAAMC,CAAC,CAAC,EAIvC,OAFID,IAAU,EAAU,CAAC,GAAGE,CAAK,EAE1BA,EAAM,MAAM,EAAG,KAAK,IAAI,EAAGA,EAAM,OAASF,CAAK,CAAC,CACzD,C"}
|
package/dist/array/dropLast.js
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/array/dropLast.ts
|
|
2
|
+
function dropLast(e, t = 1) {
|
|
3
|
+
let n = Math.max(0, Math.floor(t));
|
|
4
|
+
return n === 0 ? [...e] : e.slice(0, Math.max(0, e.length - n));
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { dropLast };
|
|
8
|
+
|
|
2
9
|
//# sourceMappingURL=dropLast.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropLast.js","names":[],"sources":["../../src/array/dropLast.ts"],"sourcesContent":["/**\n * Drops the last n elements from an array.\n */\nexport function dropLast<T>(array: readonly T[], n = 1): T[] {\n const count = Math.max(0, Math.floor(n));\n\n if (count === 0) return [...array];\n\n return array.slice(0, Math.max(0, array.length - count));\n}\n"],"mappings":"AAGA,SAAgB,SAAY,
|
|
1
|
+
{"version":3,"file":"dropLast.js","names":["count","n","array"],"sources":["../../src/array/dropLast.ts"],"sourcesContent":["/**\n * Drops the last n elements from an array.\n */\nexport function dropLast<T>(array: readonly T[], n = 1): T[] {\n const count = Math.max(0, Math.floor(n));\n\n if (count === 0) return [...array];\n\n return array.slice(0, Math.max(0, array.length - count));\n}\n"],"mappings":";AAGA,SAAgB,SAAY,GAAqB,IAAI,GAAQ;CAC3D,IAAMA,IAAQ,KAAK,IAAI,GAAG,KAAK,MAAMC,CAAC,CAAC;CAIvC,OAFID,MAAU,IAAU,CAAC,GAAGE,CAAK,IAE1BA,EAAM,MAAM,GAAG,KAAK,IAAI,GAAGA,EAAM,SAASF,CAAK,CAAC;AACzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterMap.cjs","names":[],"sources":["../../src/array/filterMap.ts"],"sourcesContent":["/**\n * Maps and filters in one pass. Returning `undefined` drops an item.\n *\n * Allocates a new array for the result.\n */\nexport function filterMap<T, R>(\n array: readonly T[],\n callback: (item: T, index: number, array: readonly T[]) => R | undefined,\n): R[] {\n const result: R[] = [];\n\n for (let index = 0; index < array.length; index++) {\n const value = callback(array[index], index, array);\n\n if (value !== undefined) {\n result.push(value);\n }\n }\n\n return result;\n}\n"],"mappings":"AAKA,SAAgB,UACd,EACA,EACK,CACL,
|
|
1
|
+
{"version":3,"file":"filterMap.cjs","names":["result","index","array","value","callback"],"sources":["../../src/array/filterMap.ts"],"sourcesContent":["/**\n * Maps and filters in one pass. Returning `undefined` drops an item.\n *\n * Allocates a new array for the result.\n */\nexport function filterMap<T, R>(\n array: readonly T[],\n callback: (item: T, index: number, array: readonly T[]) => R | undefined,\n): R[] {\n const result: R[] = [];\n\n for (let index = 0; index < array.length; index++) {\n const value = callback(array[index], index, array);\n\n if (value !== undefined) {\n result.push(value);\n }\n }\n\n return result;\n}\n"],"mappings":"AAKA,SAAgB,UACd,EACA,EACK,CACL,IAAMA,EAAc,CAAC,EAErB,IAAK,IAAIC,EAAQ,EAAGA,EAAQC,EAAM,OAAQ,IAAS,CACjD,IAAMC,EAAQC,EAASF,EAAMD,GAAQA,EAAOC,CAAK,EAE7CC,IAAU,IAAA,IACZH,EAAO,KAAKG,CAAK,CAErB,CAEA,OAAOH,CACT,C"}
|
package/dist/array/filterMap.js
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/array/filterMap.ts
|
|
2
|
+
function filterMap(e, t) {
|
|
3
|
+
let n = [];
|
|
4
|
+
for (let r = 0; r < e.length; r++) {
|
|
5
|
+
let i = t(e[r], r, e);
|
|
6
|
+
i !== void 0 && n.push(i);
|
|
7
|
+
}
|
|
8
|
+
return n;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { filterMap };
|
|
12
|
+
|
|
2
13
|
//# sourceMappingURL=filterMap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterMap.js","names":[],"sources":["../../src/array/filterMap.ts"],"sourcesContent":["/**\n * Maps and filters in one pass. Returning `undefined` drops an item.\n *\n * Allocates a new array for the result.\n */\nexport function filterMap<T, R>(\n array: readonly T[],\n callback: (item: T, index: number, array: readonly T[]) => R | undefined,\n): R[] {\n const result: R[] = [];\n\n for (let index = 0; index < array.length; index++) {\n const value = callback(array[index], index, array);\n\n if (value !== undefined) {\n result.push(value);\n }\n }\n\n return result;\n}\n"],"mappings":"AAKA,SAAgB,UACd,
|
|
1
|
+
{"version":3,"file":"filterMap.js","names":["result","index","array","value","callback"],"sources":["../../src/array/filterMap.ts"],"sourcesContent":["/**\n * Maps and filters in one pass. Returning `undefined` drops an item.\n *\n * Allocates a new array for the result.\n */\nexport function filterMap<T, R>(\n array: readonly T[],\n callback: (item: T, index: number, array: readonly T[]) => R | undefined,\n): R[] {\n const result: R[] = [];\n\n for (let index = 0; index < array.length; index++) {\n const value = callback(array[index], index, array);\n\n if (value !== undefined) {\n result.push(value);\n }\n }\n\n return result;\n}\n"],"mappings":";AAKA,SAAgB,UACd,GACA,GACK;CACL,IAAMA,IAAc,CAAC;CAErB,KAAK,IAAIC,IAAQ,GAAGA,IAAQC,EAAM,QAAQ,KAAS;EACjD,IAAMC,IAAQC,EAASF,EAAMD,IAAQA,GAAOC,CAAK;EAEjD,AAAIC,MAAU,KAAA,KACZH,EAAO,KAAKG,CAAK;CAErB;CAEA,OAAOH;AACT"}
|
package/dist/array/first.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"first.cjs","names":[],"sources":["../../src/array/first.ts"],"sourcesContent":["/**\n * Returns the first element or fallback when array is empty.\n */\nexport function first<T>(array: readonly T[], fallback?: T): T | undefined {\n return array.length > 0 ? array[0] : fallback;\n}\n"],"mappings":"AAGA,SAAgB,MAAS,EAAqB,EAA6B,CACzE,
|
|
1
|
+
{"version":3,"file":"first.cjs","names":["array","fallback"],"sources":["../../src/array/first.ts"],"sourcesContent":["/**\n * Returns the first element or fallback when array is empty.\n */\nexport function first<T>(array: readonly T[], fallback?: T): T | undefined {\n return array.length > 0 ? array[0] : fallback;\n}\n"],"mappings":"AAGA,SAAgB,MAAS,EAAqB,EAA6B,CACzE,OAAOA,EAAM,OAAS,EAAIA,EAAM,GAAKC,CACvC,C"}
|
package/dist/array/first.js
CHANGED
package/dist/array/first.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"first.js","names":[],"sources":["../../src/array/first.ts"],"sourcesContent":["/**\n * Returns the first element or fallback when array is empty.\n */\nexport function first<T>(array: readonly T[], fallback?: T): T | undefined {\n return array.length > 0 ? array[0] : fallback;\n}\n"],"mappings":"AAGA,SAAgB,MAAS,
|
|
1
|
+
{"version":3,"file":"first.js","names":["array","fallback"],"sources":["../../src/array/first.ts"],"sourcesContent":["/**\n * Returns the first element or fallback when array is empty.\n */\nexport function first<T>(array: readonly T[], fallback?: T): T | undefined {\n return array.length > 0 ? array[0] : fallback;\n}\n"],"mappings":";AAGA,SAAgB,MAAS,GAAqB,GAA6B;CACzE,OAAOA,EAAM,SAAS,IAAIA,EAAM,KAAKC;AACvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"groupBy.cjs","names":[],"sources":["../../src/array/groupBy.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Primitive } from '../types';\n\n/**\n * Groups elements by a selector function. Dangerous keys (`__proto__`, `constructor`,\n * `prototype`) are skipped.\n */\nexport function groupBy<T>(array: readonly T[], selector: (item: T) => Primitive): Record<string, T[]> {\n const result: Record<string, T[]> = {};\n\n for (const item of array) {\n const rawKey = selector(item);\n const key = rawKey === undefined || rawKey === null ? '_' : String(rawKey);\n\n if (isUnsafeKey(key)) continue;\n\n if (!result[key]) {\n result[key] = [];\n }\n\n result[key].push(item);\n }\n\n return result;\n}\n"],"mappings":"8CAOA,SAAgB,QAAW,EAAqB,EAAuD,CACrG,
|
|
1
|
+
{"version":3,"file":"groupBy.cjs","names":["isUnsafeKey","require_unsafePaths","result","item","array","rawKey","selector","key"],"sources":["../../src/array/groupBy.ts"],"sourcesContent":["import { isUnsafeKey } from '../_common/unsafePaths';\nimport type { Primitive } from '../types';\n\n/**\n * Groups elements by a selector function. Dangerous keys (`__proto__`, `constructor`,\n * `prototype`) are skipped.\n */\nexport function groupBy<T>(array: readonly T[], selector: (item: T) => Primitive): Record<string, T[]> {\n const result: Record<string, T[]> = {};\n\n for (const item of array) {\n const rawKey = selector(item);\n const key = rawKey === undefined || rawKey === null ? '_' : String(rawKey);\n\n if (isUnsafeKey(key)) continue;\n\n if (!result[key]) {\n result[key] = [];\n }\n\n result[key].push(item);\n }\n\n return result;\n}\n"],"mappings":"A,8CAOA,SAAgB,QAAW,EAAqB,EAAuD,CACrG,IAAME,EAA8B,CAAC,EAErC,IAAK,IAAMC,KAAQC,EAAO,CACxB,IAAMC,EAASC,EAASH,CAAI,EACtBI,EAAMF,GAAmC,KAAO,IAAM,OAAOA,CAAM,EAErEL,EAAAA,YAAYO,CAAG,IAEdL,EAAOK,KACV,EAAOA,GAAO,CAAC,GAGjBL,EAAOK,EAAI,CAAC,KAAKJ,CAAI,EACvB,CAEA,OAAOD,CACT,C"}
|
package/dist/array/groupBy.js
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
import{isUnsafeKey as e}from"../_common/unsafePaths.js";
|
|
1
|
+
import { isUnsafeKey as e } from "../_common/unsafePaths.js";
|
|
2
|
+
//#region src/array/groupBy.ts
|
|
3
|
+
function groupBy(t, n) {
|
|
4
|
+
let r = {};
|
|
5
|
+
for (let i of t) {
|
|
6
|
+
let t = n(i), a = t == null ? "_" : String(t);
|
|
7
|
+
e(a) || (r[a] || (r[a] = []), r[a].push(i));
|
|
8
|
+
}
|
|
9
|
+
return r;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { groupBy };
|
|
13
|
+
|
|
2
14
|
//# sourceMappingURL=groupBy.js.map
|