@vielzeug/arsenal 1.1.1 → 2.0.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 +31 -75
- package/dist/_dev.cjs +1 -1
- package/dist/_dev.cjs.map +1 -1
- package/dist/_dev.js +2 -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 +2 -1
- package/dist/array/chunk.d.ts.map +1 -1
- package/dist/array/chunk.js +5 -7
- package/dist/array/chunk.js.map +1 -1
- package/dist/array/compare.cjs +1 -1
- package/dist/array/compare.cjs.map +1 -1
- package/dist/array/compare.d.ts.map +1 -1
- package/dist/array/compare.js +13 -14
- package/dist/array/compare.js.map +1 -1
- package/dist/array/index.cjs +1 -0
- package/dist/array/index.js +29 -0
- package/dist/array/search.cjs +1 -1
- package/dist/array/search.cjs.map +1 -1
- package/dist/array/search.d.ts +8 -77
- package/dist/array/search.d.ts.map +1 -1
- package/dist/array/search.js +21 -38
- 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 +1 -1
- package/dist/array/sort.d.ts.map +1 -1
- package/dist/array/sort.js +9 -10
- package/dist/array/sort.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/attempt.cjs +1 -1
- package/dist/async/attempt.cjs.map +1 -1
- package/dist/async/attempt.d.ts +3 -8
- package/dist/async/attempt.d.ts.map +1 -1
- package/dist/async/attempt.js +3 -10
- package/dist/async/attempt.js.map +1 -1
- package/dist/async/index.cjs +1 -0
- package/dist/async/index.d.ts +1 -1
- package/dist/async/index.d.ts.map +1 -1
- package/dist/async/index.js +9 -0
- package/dist/async/parallel.cjs +1 -1
- package/dist/async/parallel.cjs.map +1 -1
- package/dist/async/parallel.d.ts +1 -1
- package/dist/async/parallel.d.ts.map +1 -1
- package/dist/async/parallel.js +15 -16
- 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 +1 -1
- package/dist/async/retry.d.ts.map +1 -1
- package/dist/async/retry.js +14 -15
- package/dist/async/retry.js.map +1 -1
- package/dist/async/taskPool.cjs +2 -0
- package/dist/async/taskPool.cjs.map +1 -0
- package/dist/async/taskPool.d.ts +14 -0
- package/dist/async/taskPool.d.ts.map +1 -0
- package/dist/async/taskPool.js +51 -0
- package/dist/async/taskPool.js.map +1 -0
- package/dist/cache/cache.cjs +2 -0
- package/dist/cache/cache.cjs.map +1 -0
- package/dist/cache/cache.d.ts +17 -0
- package/dist/cache/cache.d.ts.map +1 -0
- package/dist/cache/cache.js +59 -0
- package/dist/cache/cache.js.map +1 -0
- package/dist/cache/index.cjs +1 -0
- package/dist/cache/index.d.ts +1 -1
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +3 -0
- package/dist/cache/memo.cjs +1 -1
- package/dist/cache/memo.cjs.map +1 -1
- package/dist/cache/memo.d.ts +2 -2
- package/dist/cache/memo.js +24 -23
- package/dist/cache/memo.js.map +1 -1
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +0 -7
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +2 -2
- package/dist/errors.js.map +1 -1
- package/dist/function/debounce.cjs +1 -1
- package/dist/function/debounce.cjs.map +1 -1
- package/dist/function/debounce.js +15 -17
- package/dist/function/debounce.js.map +1 -1
- package/dist/function/index.cjs +1 -0
- package/dist/function/index.d.ts +0 -2
- package/dist/function/index.d.ts.map +1 -1
- package/dist/function/index.js +8 -0
- package/dist/function/pipe.cjs +1 -1
- package/dist/function/pipe.cjs.map +1 -1
- package/dist/function/pipe.js +1 -1
- package/dist/function/pipe.js.map +1 -1
- package/dist/guards/index.cjs +1 -0
- package/dist/guards/index.d.ts +0 -3
- package/dist/guards/index.d.ts.map +1 -1
- package/dist/guards/index.js +17 -0
- package/dist/guards/isEqual.cjs.map +1 -1
- package/dist/guards/isEqual.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -91
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -118
- package/dist/math/allocate.cjs +1 -1
- package/dist/math/allocate.cjs.map +1 -1
- package/dist/math/allocate.d.ts +1 -1
- package/dist/math/allocate.d.ts.map +1 -1
- package/dist/math/allocate.js +13 -14
- package/dist/math/allocate.js.map +1 -1
- package/dist/math/index.cjs +1 -0
- package/dist/math/index.d.ts +0 -3
- package/dist/math/index.d.ts.map +1 -1
- package/dist/math/index.js +17 -0
- package/dist/math/mod.cjs +1 -1
- package/dist/math/mod.cjs.map +1 -1
- package/dist/math/mod.d.ts +1 -1
- package/dist/math/mod.d.ts.map +1 -1
- package/dist/math/mod.js +4 -5
- package/dist/math/mod.js.map +1 -1
- package/dist/math/range.cjs +1 -1
- package/dist/math/range.cjs.map +1 -1
- package/dist/math/range.d.ts +1 -1
- package/dist/math/range.d.ts.map +1 -1
- package/dist/math/range.js +14 -15
- package/dist/math/range.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 +2 -2
- package/dist/math/sum.d.ts.map +1 -1
- package/dist/math/sum.js +6 -7
- package/dist/math/sum.js.map +1 -1
- package/dist/object/getPath.cjs +1 -1
- package/dist/object/getPath.cjs.map +1 -1
- package/dist/object/getPath.d.ts +12 -42
- package/dist/object/getPath.d.ts.map +1 -1
- package/dist/object/getPath.js +21 -22
- package/dist/object/getPath.js.map +1 -1
- package/dist/object/index.cjs +1 -0
- package/dist/object/index.d.ts +1 -1
- package/dist/object/index.d.ts.map +1 -1
- package/dist/object/index.js +15 -0
- package/dist/object/merge.cjs +1 -1
- package/dist/object/merge.cjs.map +1 -1
- package/dist/object/merge.d.ts +1 -1
- package/dist/object/merge.d.ts.map +1 -1
- package/dist/object/merge.js +2 -3
- package/dist/object/merge.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 +22 -23
- package/dist/object/prune.js.map +1 -1
- package/dist/object/tryParseJson.cjs +2 -0
- package/dist/object/tryParseJson.cjs.map +1 -0
- package/dist/object/tryParseJson.d.ts +9 -0
- package/dist/object/tryParseJson.d.ts.map +1 -0
- package/dist/object/tryParseJson.js +18 -0
- package/dist/object/tryParseJson.js.map +1 -0
- package/dist/random/_index.cjs +2 -0
- package/dist/random/_index.cjs.map +1 -0
- package/dist/random/_index.d.ts +3 -0
- package/dist/random/_index.d.ts.map +1 -0
- package/dist/random/_index.js +10 -0
- package/dist/random/_index.js.map +1 -0
- package/dist/random/draw.cjs +1 -1
- package/dist/random/draw.cjs.map +1 -1
- package/dist/random/draw.d.ts +3 -2
- package/dist/random/draw.d.ts.map +1 -1
- package/dist/random/draw.js +12 -12
- package/dist/random/draw.js.map +1 -1
- package/dist/random/index.cjs +1 -0
- package/dist/random/index.d.ts +1 -0
- package/dist/random/index.d.ts.map +1 -1
- package/dist/random/index.js +5 -0
- package/dist/random/random.cjs +1 -1
- package/dist/random/random.cjs.map +1 -1
- package/dist/random/random.d.ts +2 -1
- package/dist/random/random.d.ts.map +1 -1
- package/dist/random/random.js +5 -6
- 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.d.ts +2 -1
- package/dist/random/shuffle.d.ts.map +1 -1
- package/dist/random/shuffle.js +7 -7
- package/dist/random/shuffle.js.map +1 -1
- package/dist/random/source.d.ts +4 -0
- package/dist/random/source.d.ts.map +1 -0
- package/dist/string/index.cjs +1 -0
- package/dist/string/index.d.ts +0 -2
- package/dist/string/index.d.ts.map +1 -1
- package/dist/string/index.js +12 -0
- package/dist/string/similarity.cjs +1 -1
- package/dist/string/similarity.cjs.map +1 -1
- package/dist/string/similarity.d.ts.map +1 -1
- package/dist/string/similarity.js +16 -17
- package/dist/string/similarity.js.map +1 -1
- package/dist/string/truncate.cjs +1 -1
- package/dist/string/truncate.cjs.map +1 -1
- package/dist/string/truncate.d.ts +2 -1
- package/dist/string/truncate.d.ts.map +1 -1
- package/dist/string/truncate.js +10 -11
- package/dist/string/truncate.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +14 -19
- package/dist/_common/_secureRandomIndex.cjs +0 -2
- package/dist/_common/_secureRandomIndex.cjs.map +0 -1
- package/dist/_common/_secureRandomIndex.d.ts +0 -2
- package/dist/_common/_secureRandomIndex.d.ts.map +0 -1
- package/dist/_common/_secureRandomIndex.js +0 -9
- package/dist/_common/_secureRandomIndex.js.map +0 -1
- package/dist/async/queue.cjs +0 -2
- package/dist/async/queue.cjs.map +0 -1
- package/dist/async/queue.d.ts +0 -42
- package/dist/async/queue.d.ts.map +0 -1
- package/dist/async/queue.js +0 -72
- package/dist/async/queue.js.map +0 -1
- package/dist/cache/stash.cjs +0 -2
- package/dist/cache/stash.cjs.map +0 -1
- package/dist/cache/stash.d.ts +0 -111
- package/dist/cache/stash.d.ts.map +0 -1
- package/dist/cache/stash.js +0 -92
- package/dist/cache/stash.js.map +0 -1
- package/dist/function/constant.cjs +0 -2
- package/dist/function/constant.cjs.map +0 -1
- package/dist/function/constant.d.ts +0 -5
- package/dist/function/constant.d.ts.map +0 -1
- package/dist/function/constant.js +0 -8
- package/dist/function/constant.js.map +0 -1
- package/dist/function/identity.cjs +0 -2
- package/dist/function/identity.cjs.map +0 -1
- package/dist/function/identity.d.ts +0 -5
- package/dist/function/identity.d.ts.map +0 -1
- package/dist/function/identity.js +0 -8
- package/dist/function/identity.js.map +0 -1
- package/dist/guards/isArray.cjs +0 -2
- package/dist/guards/isArray.cjs.map +0 -1
- package/dist/guards/isArray.d.ts +0 -16
- package/dist/guards/isArray.d.ts.map +0 -1
- package/dist/guards/isArray.js +0 -8
- package/dist/guards/isArray.js.map +0 -1
- package/dist/guards/isBoolean.cjs +0 -2
- package/dist/guards/isBoolean.cjs.map +0 -1
- package/dist/guards/isBoolean.d.ts +0 -23
- package/dist/guards/isBoolean.d.ts.map +0 -1
- package/dist/guards/isBoolean.js +0 -8
- package/dist/guards/isBoolean.js.map +0 -1
- package/dist/guards/isString.cjs +0 -2
- package/dist/guards/isString.cjs.map +0 -1
- package/dist/guards/isString.d.ts +0 -15
- package/dist/guards/isString.d.ts.map +0 -1
- package/dist/guards/isString.js +0 -8
- package/dist/guards/isString.js.map +0 -1
- package/dist/math/abs.cjs +0 -2
- package/dist/math/abs.cjs.map +0 -1
- package/dist/math/abs.d.ts +0 -17
- package/dist/math/abs.d.ts.map +0 -1
- package/dist/math/abs.js +0 -8
- package/dist/math/abs.js.map +0 -1
- package/dist/math/max.cjs +0 -2
- package/dist/math/max.cjs.map +0 -1
- package/dist/math/max.d.ts +0 -21
- package/dist/math/max.d.ts.map +0 -1
- package/dist/math/max.js +0 -12
- package/dist/math/max.js.map +0 -1
- package/dist/math/min.cjs +0 -2
- package/dist/math/min.cjs.map +0 -1
- package/dist/math/min.d.ts +0 -21
- package/dist/math/min.d.ts.map +0 -1
- package/dist/math/min.js +0 -12
- package/dist/math/min.js.map +0 -1
- package/dist/object/parseJSON.cjs +0 -2
- package/dist/object/parseJSON.cjs.map +0 -1
- package/dist/object/parseJSON.d.ts +0 -32
- package/dist/object/parseJSON.d.ts.map +0 -1
- package/dist/object/parseJSON.js +0 -16
- package/dist/object/parseJSON.js.map +0 -1
- package/dist/string/endsWith.cjs +0 -2
- package/dist/string/endsWith.cjs.map +0 -1
- package/dist/string/endsWith.d.ts +0 -5
- package/dist/string/endsWith.d.ts.map +0 -1
- package/dist/string/endsWith.js +0 -8
- package/dist/string/endsWith.js.map +0 -1
- package/dist/string/startsWith.cjs +0 -2
- package/dist/string/startsWith.cjs.map +0 -1
- package/dist/string/startsWith.d.ts +0 -5
- package/dist/string/startsWith.d.ts.map +0 -1
- package/dist/string/startsWith.js +0 -8
- package/dist/string/startsWith.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_index.js","names":[],"sources":["../../src/random/_index.ts"],"sourcesContent":["import type { RandomSource } from './source';\n\nexport function randomIndex(exclusiveMax: number, source?: RandomSource): number {\n const value = source?.next() ?? crypto.getRandomValues(new Uint32Array(1))[0]! / 0x100000000;\n\n if (!Number.isFinite(value) || value < 0 || value >= 1) {\n throw new RangeError('random source must return a finite number in [0, 1)');\n }\n\n return Math.floor(value * exclusiveMax);\n}\n"],"mappings":";AAEA,SAAgB,EAAY,GAAsB,GAA+B;CAC/E,IAAM,IAAQ,GAAQ,KAAK,KAAK,OAAO,gCAAgB,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,KAAM;CAEjF,IAAI,CAAC,OAAO,SAAS,CAAK,KAAK,IAAQ,KAAK,KAAS,GACnD,MAAU,WAAW,qDAAqD;CAG5E,OAAO,KAAK,MAAM,IAAQ,CAAY;AACxC"}
|
package/dist/random/draw.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("
|
|
1
|
+
const e=require("./_index.cjs"),t=require("./random.cjs");function n(e,n){if(e.length!==0)return e[t.random(0,e.length-1,n)]}function r(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=n,exports.drawMany=r;
|
|
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 {
|
|
1
|
+
{"version":3,"file":"draw.cjs","names":[],"sources":["../../src/random/draw.ts"],"sourcesContent":["import type { RandomSource } from './source';\n\nimport { randomIndex } from './_index';\nimport { random } from './random';\n\n/**\n * Picks a single random item from an array.\n * Returns `undefined` if the array is empty.\n *\n * @example\n * ```ts\n * draw([1, 2, 3]); // e.g. 2\n * draw([]); // undefined\n * ```\n */\nexport function draw<T>(array: T[], 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":"0DAeA,SAAgB,EAAQ,EAAY,EAAsC,CACpE,KAAM,SAAW,EAErB,OAAO,EAAM,EAAA,OAAO,EAAG,EAAM,OAAS,EAAG,CAAM,EACjD,CAaA,SAAgB,EAAY,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.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RandomSource } from './source';
|
|
1
2
|
/**
|
|
2
3
|
* Picks a single random item from an array.
|
|
3
4
|
* Returns `undefined` if the array is empty.
|
|
@@ -8,7 +9,7 @@
|
|
|
8
9
|
* draw([]); // undefined
|
|
9
10
|
* ```
|
|
10
11
|
*/
|
|
11
|
-
export declare function draw<T>(array: T[]): T | undefined;
|
|
12
|
+
export declare function draw<T>(array: T[], source?: RandomSource): T | undefined;
|
|
12
13
|
/**
|
|
13
14
|
* Picks up to `n` unique random items from an array using a cryptographically
|
|
14
15
|
* random shuffle (Fisher-Yates via `crypto.getRandomValues`).
|
|
@@ -20,5 +21,5 @@ export declare function draw<T>(array: T[]): T | undefined;
|
|
|
20
21
|
* drawMany([1, 2], 10); // [1, 2] (clamped to array length)
|
|
21
22
|
* ```
|
|
22
23
|
*/
|
|
23
|
-
export declare function drawMany<T>(array: T[], n: number): T[];
|
|
24
|
+
export declare function drawMany<T>(array: T[], n: number, source?: RandomSource): T[];
|
|
24
25
|
//# sourceMappingURL=draw.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draw.d.ts","sourceRoot":"","sources":["../../src/random/draw.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"draw.d.ts","sourceRoot":"","sources":["../../src/random/draw.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAK7C;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,CAAC,GAAG,SAAS,CAIxE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,CAAC,EAAE,CAkB7E"}
|
package/dist/random/draw.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { randomIndex as e } from "./_index.js";
|
|
2
2
|
import { random as t } from "./random.js";
|
|
3
3
|
//#region src/random/draw.ts
|
|
4
|
-
function n(e) {
|
|
5
|
-
if (e.length !== 0) return e[t(0, e.length - 1)];
|
|
4
|
+
function n(e, n) {
|
|
5
|
+
if (e.length !== 0) return e[t(0, e.length - 1, n)];
|
|
6
6
|
}
|
|
7
|
-
function r(t, n) {
|
|
8
|
-
let
|
|
9
|
-
if (
|
|
10
|
-
if (
|
|
11
|
-
let
|
|
12
|
-
for (let t =
|
|
13
|
-
let n = e(t + 1
|
|
14
|
-
|
|
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
15
|
}
|
|
16
|
-
return
|
|
16
|
+
return a.slice(0, i);
|
|
17
17
|
}
|
|
18
18
|
//#endregion
|
|
19
19
|
export { n as draw, r as drawMany };
|
package/dist/random/draw.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draw.js","names":[],"sources":["../../src/random/draw.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"draw.js","names":[],"sources":["../../src/random/draw.ts"],"sourcesContent":["import type { RandomSource } from './source';\n\nimport { randomIndex } from './_index';\nimport { random } from './random';\n\n/**\n * Picks a single random item from an array.\n * Returns `undefined` if the array is empty.\n *\n * @example\n * ```ts\n * draw([1, 2, 3]); // e.g. 2\n * draw([]); // undefined\n * ```\n */\nexport function draw<T>(array: T[], 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":";;;AAeA,SAAgB,EAAQ,GAAY,GAAsC;CACpE,MAAM,WAAW,GAErB,OAAO,EAAM,EAAO,GAAG,EAAM,SAAS,GAAG,CAAM;AACjD;AAaA,SAAgB,EAAY,GAAY,GAAW,GAA4B;CAC7E,IAAM,IAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,EAAM,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC;CAE/D,IAAI,MAAU,GAAG,OAAO,CAAC;CAEzB,IAAI,MAAU,EAAM,QAAQ,OAAO,CAAC,GAAG,CAAK;CAE5C,IAAM,IAAO,CAAC,GAAG,CAAK;CAEtB,KAAK,IAAI,IAAQ,EAAK,SAAS,GAAG,IAAQ,GAAG,KAAS;EACpD,IAAM,IAAgB,EAAY,IAAQ,GAAG,CAAM,GAC7C,IAAO,EAAK;EAGlB,AADA,EAAK,KAAS,EAAK,IACnB,EAAK,KAAiB;CACxB;CAEA,OAAO,EAAK,MAAM,GAAG,CAAK;AAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./uuid.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.shuffle=r.shuffle,exports.uuid=e.uuid;
|
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,QAAQ,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;AACzB,cAAc,QAAQ,CAAC"}
|
package/dist/random/random.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("
|
|
1
|
+
const e=require("./_index.cjs");function t(t,n,r){if(t>n)throw RangeError(`random: minimum value must not be greater than maximum value`);return e.randomIndex(n-t+1,r)+t}exports.random=t;
|
|
2
2
|
//# sourceMappingURL=random.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.cjs","names":[],"sources":["../../src/random/random.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"random.cjs","names":[],"sources":["../../src/random/random.ts"],"sourcesContent":["import type { RandomSource } from './source';\n\nimport { randomIndex } from './_index';\n\n/**\n * Generates a random integer between two values, inclusive.\n *\n * @example\n * ```ts\n * random(1, 10); // a random integer between 1 and 10\n * ```\n *\n * @param min - The minimum value.\n * @param max - The maximum value.\n * @returns A random integer between min and max.\n */\nexport function random(min: number, max: number, source?: RandomSource): number {\n if (min > max) throw new RangeError('random: minimum value must not be greater than maximum value');\n\n return randomIndex(max - min + 1, source) + min;\n}\n"],"mappings":"gCAgBA,SAAgB,EAAO,EAAa,EAAa,EAA+B,CAC9E,GAAI,EAAM,EAAK,MAAU,WAAW,8DAA8D,EAElG,OAAO,EAAA,YAAY,EAAM,EAAM,EAAG,CAAM,EAAI,CAC9C"}
|
package/dist/random/random.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RandomSource } from './source';
|
|
1
2
|
/**
|
|
2
3
|
* Generates a random integer between two values, inclusive.
|
|
3
4
|
*
|
|
@@ -10,5 +11,5 @@
|
|
|
10
11
|
* @param max - The maximum value.
|
|
11
12
|
* @returns A random integer between min and max.
|
|
12
13
|
*/
|
|
13
|
-
export declare function random(min: number, max: number): number;
|
|
14
|
+
export declare function random(min: number, max: number, source?: RandomSource): number;
|
|
14
15
|
//# sourceMappingURL=random.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../src/random/random.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../src/random/random.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI7C;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAI9E"}
|
package/dist/random/random.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { secureRandomIndex as t } from "../_common/_secureRandomIndex.js";
|
|
1
|
+
import { randomIndex as e } from "./_index.js";
|
|
3
2
|
//#region src/random/random.ts
|
|
4
|
-
function
|
|
5
|
-
if (
|
|
6
|
-
return
|
|
3
|
+
function t(t, n, r) {
|
|
4
|
+
if (t > n) throw RangeError("random: minimum value must not be greater than maximum value");
|
|
5
|
+
return e(n - t + 1, r) + t;
|
|
7
6
|
}
|
|
8
7
|
//#endregion
|
|
9
|
-
export {
|
|
8
|
+
export { t as random };
|
|
10
9
|
|
|
11
10
|
//# sourceMappingURL=random.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.js","names":[],"sources":["../../src/random/random.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"random.js","names":[],"sources":["../../src/random/random.ts"],"sourcesContent":["import type { RandomSource } from './source';\n\nimport { randomIndex } from './_index';\n\n/**\n * Generates a random integer between two values, inclusive.\n *\n * @example\n * ```ts\n * random(1, 10); // a random integer between 1 and 10\n * ```\n *\n * @param min - The minimum value.\n * @param max - The maximum value.\n * @returns A random integer between min and max.\n */\nexport function random(min: number, max: number, source?: RandomSource): number {\n if (min > max) throw new RangeError('random: minimum value must not be greater than maximum value');\n\n return randomIndex(max - min + 1, source) + min;\n}\n"],"mappings":";;AAgBA,SAAgB,EAAO,GAAa,GAAa,GAA+B;CAC9E,IAAI,IAAM,GAAK,MAAU,WAAW,8DAA8D;CAElG,OAAO,EAAY,IAAM,IAAM,GAAG,CAAM,IAAI;AAC9C"}
|
package/dist/random/shuffle.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("
|
|
1
|
+
const e=require("./_index.cjs");function t(t,n){let r=[...t];for(let t=r.length-1;t>0;t--){let i=e.randomIndex(t+1,n);[r[t],r[i]]=[r[i],r[t]]}return r}exports.shuffle=t;
|
|
2
2
|
//# sourceMappingURL=shuffle.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shuffle.cjs","names":[],"sources":["../../src/random/shuffle.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"shuffle.cjs","names":[],"sources":["../../src/random/shuffle.ts"],"sourcesContent":["import type { RandomSource } from './source';\n\nimport { randomIndex } from './_index';\n\n/**\n * Returns a new randomly-shuffled copy of the array using Fisher-Yates\n * with `crypto.getRandomValues`. Does not mutate the input.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4];\n * shuffle(arr); // e.g. [3, 1, 4, 2]\n * ```\n */\nexport function shuffle<T>(array: T[], source?: RandomSource): T[] {\n const result = [...array];\n\n for (let i = result.length - 1; i > 0; i--) {\n const j = randomIndex(i + 1, source);\n\n [result[i], result[j]] = [result[j], result[i]];\n }\n\n return result;\n}\n"],"mappings":"gCAcA,SAAgB,EAAW,EAAY,EAA4B,CACjE,IAAM,EAAS,CAAC,GAAG,CAAK,EAExB,IAAK,IAAI,EAAI,EAAO,OAAS,EAAG,EAAI,EAAG,IAAK,CAC1C,IAAM,EAAI,EAAA,YAAY,EAAI,EAAG,CAAM,EAEnC,CAAC,EAAO,GAAI,EAAO,IAAM,CAAC,EAAO,GAAI,EAAO,EAAE,CAChD,CAEA,OAAO,CACT"}
|
package/dist/random/shuffle.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RandomSource } from './source';
|
|
1
2
|
/**
|
|
2
3
|
* Returns a new randomly-shuffled copy of the array using Fisher-Yates
|
|
3
4
|
* with `crypto.getRandomValues`. Does not mutate the input.
|
|
@@ -8,5 +9,5 @@
|
|
|
8
9
|
* shuffle(arr); // e.g. [3, 1, 4, 2]
|
|
9
10
|
* ```
|
|
10
11
|
*/
|
|
11
|
-
export declare function shuffle<T>(array: T[]): T[];
|
|
12
|
+
export declare function shuffle<T>(array: T[], source?: RandomSource): T[];
|
|
12
13
|
//# sourceMappingURL=shuffle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shuffle.d.ts","sourceRoot":"","sources":["../../src/random/shuffle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shuffle.d.ts","sourceRoot":"","sources":["../../src/random/shuffle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI7C;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,CAAC,EAAE,CAUjE"}
|
package/dist/random/shuffle.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { randomIndex as e } from "./_index.js";
|
|
2
2
|
//#region src/random/shuffle.ts
|
|
3
|
-
function t(t) {
|
|
4
|
-
let
|
|
5
|
-
for (let t =
|
|
6
|
-
let
|
|
7
|
-
[
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
let r = [...t];
|
|
5
|
+
for (let t = r.length - 1; t > 0; t--) {
|
|
6
|
+
let i = e(t + 1, n);
|
|
7
|
+
[r[t], r[i]] = [r[i], r[t]];
|
|
8
8
|
}
|
|
9
|
-
return
|
|
9
|
+
return r;
|
|
10
10
|
}
|
|
11
11
|
//#endregion
|
|
12
12
|
export { t as shuffle };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shuffle.js","names":[],"sources":["../../src/random/shuffle.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"shuffle.js","names":[],"sources":["../../src/random/shuffle.ts"],"sourcesContent":["import type { RandomSource } from './source';\n\nimport { randomIndex } from './_index';\n\n/**\n * Returns a new randomly-shuffled copy of the array using Fisher-Yates\n * with `crypto.getRandomValues`. Does not mutate the input.\n *\n * @example\n * ```ts\n * const arr = [1, 2, 3, 4];\n * shuffle(arr); // e.g. [3, 1, 4, 2]\n * ```\n */\nexport function shuffle<T>(array: T[], source?: RandomSource): T[] {\n const result = [...array];\n\n for (let i = result.length - 1; i > 0; i--) {\n const j = randomIndex(i + 1, source);\n\n [result[i], result[j]] = [result[j], result[i]];\n }\n\n return result;\n}\n"],"mappings":";;AAcA,SAAgB,EAAW,GAAY,GAA4B;CACjE,IAAM,IAAS,CAAC,GAAG,CAAK;CAExB,KAAK,IAAI,IAAI,EAAO,SAAS,GAAG,IAAI,GAAG,KAAK;EAC1C,IAAM,IAAI,EAAY,IAAI,GAAG,CAAM;EAEnC,CAAC,EAAO,IAAI,EAAO,MAAM,CAAC,EAAO,IAAI,EAAO,EAAE;CAChD;CAEA,OAAO;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/random/source.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,IAAI,MAAM,CAAC;CAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./similarity.cjs"),t=require("./camelCase.cjs"),n=require("./escape.cjs"),r=require("./kebabCase.cjs"),i=require("./pad.cjs"),a=require("./pascalCase.cjs"),o=require("./snakeCase.cjs"),s=require("./words.cjs"),c=require("./titleCase.cjs"),l=require("./truncate.cjs"),u=require("./unescape.cjs");exports.camelCase=t.camelCase,exports.escape=n.escape,exports.kebabCase=r.kebabCase,exports.pad=i.pad,exports.pascalCase=a.pascalCase,exports.similarity=e.similarity,exports.snakeCase=o.snakeCase,exports.titleCase=c.titleCase,exports.truncate=l.truncate,exports.unescape=u.unescape,exports.words=s.words;
|
package/dist/string/index.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
export * from './camelCase';
|
|
2
|
-
export * from './endsWith';
|
|
3
2
|
export * from './escape';
|
|
4
3
|
export * from './kebabCase';
|
|
5
4
|
export * from './pad';
|
|
6
5
|
export * from './pascalCase';
|
|
7
6
|
export * from './similarity';
|
|
8
7
|
export * from './snakeCase';
|
|
9
|
-
export * from './startsWith';
|
|
10
8
|
export * from './titleCase';
|
|
11
9
|
export * from './truncate';
|
|
12
10
|
export * from './unescape';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/string/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/string/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { similarity as e } from "./similarity.js";
|
|
2
|
+
import { camelCase as t } from "./camelCase.js";
|
|
3
|
+
import { escape as n } from "./escape.js";
|
|
4
|
+
import { kebabCase as r } from "./kebabCase.js";
|
|
5
|
+
import { pad as i } from "./pad.js";
|
|
6
|
+
import { pascalCase as a } from "./pascalCase.js";
|
|
7
|
+
import { snakeCase as o } from "./snakeCase.js";
|
|
8
|
+
import { words as s } from "./words.js";
|
|
9
|
+
import { titleCase as c } from "./titleCase.js";
|
|
10
|
+
import { truncate as l } from "./truncate.js";
|
|
11
|
+
import { unescape as u } from "./unescape.js";
|
|
12
|
+
export { t as camelCase, n as escape, r as kebabCase, i as pad, a as pascalCase, e as similarity, o as snakeCase, c as titleCase, l as truncate, u as unescape, s as words };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
var e=1e4;function t(t,n){if(t.length>e||n.length>e)throw RangeError(`similarity: input strings must not exceed ${e} characters to prevent excessive memory usage`);let r=t.toLowerCase(),i=n.toLowerCase();if(r===i)return 1;if(r.length===0)return+(i.length===0);if(i.length===0)return 0;let[a,o]=r.length<i.length?[r,i]:[i,r],s=a.length,c=o.length,l=Array.from({length:s+1},(e,t)=>t),u=Array(s+1);for(let e=1;e<=c;e++){u[0]=e;for(let t=1;t<=s;t++){let n=o[e-1]===a[t-1]?0:1;u[t]=Math.min(u[t-1]+1,l[t]+1,l[t-1]+n)}[l,u]=[u,l]}return 1-l[s]/Math.max(r.length,i.length)}exports.similarity=t;
|
|
2
2
|
//# sourceMappingURL=similarity.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"similarity.cjs","names":[],"sources":["../../src/string/similarity.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"similarity.cjs","names":[],"sources":["../../src/string/similarity.ts"],"sourcesContent":["/**\n * Calculate the similarity between two strings using the Levenshtein distance algorithm.\n *\n * @example\n * ```ts\n * similarity('abc', 'abc') // 1\n * similarity('a', 'b') // 0\n * similarity('ab', 'ac') // 0.5\n * similarity('doe', 'John Doe') // 0.25\n * similarity('abc', 'axc') // 0.6666666666666667\n * similarity('kitten', 'sitting') // 0.5714285714285714\n * ```\n *\n * @param str1 - The first string.\n * @param str2 - The second string.\n *\n * @returns A number between 0 and 1 representing the similarity between the two strings.\n *\n * @throws {RangeError} If either input string exceeds 10 000 characters.\n */\nconst MAX_SIMILARITY_LENGTH = 10_000;\n\nexport function similarity(str1: string, str2: string): number {\n if (str1.length > MAX_SIMILARITY_LENGTH || str2.length > MAX_SIMILARITY_LENGTH) {\n throw new RangeError(\n `similarity: input strings must not exceed ${MAX_SIMILARITY_LENGTH} characters to prevent excessive memory usage`,\n );\n }\n\n const a = str1.toLowerCase();\n const b = str2.toLowerCase();\n\n if (a === b) return 1;\n\n if (a.length === 0) return b.length === 0 ? 1 : 0;\n\n if (b.length === 0) return 0;\n\n // Swap to ensure we use the smaller string for columns (O(min(A,B)) space)\n const [shorter, longer] = a.length < b.length ? [a, b] : [b, a];\n const shorterLength = shorter.length;\n const longerLength = longer.length;\n\n let prevRow = Array.from({ length: shorterLength + 1 }, (_, i) => i);\n let currRow = new Array(shorterLength + 1);\n\n for (let i = 1; i <= longerLength; i++) {\n currRow[0] = i;\n for (let j = 1; j <= shorterLength; j++) {\n const cost = longer[i - 1] === shorter[j - 1] ? 0 : 1;\n\n currRow[j] = Math.min(\n currRow[j - 1] + 1, // insertion\n prevRow[j] + 1, // deletion\n prevRow[j - 1] + cost, // substitution\n );\n }\n // Swap rows for the next iteration (avoid allocation)\n [prevRow, currRow] = [currRow, prevRow];\n }\n\n // After the loop, a result is in prevRow because of the swap\n const distance = prevRow[shorterLength];\n\n return 1 - distance / Math.max(a.length, b.length);\n}\n"],"mappings":"AAoBA,IAAM,EAAwB,IAE9B,SAAgB,EAAW,EAAc,EAAsB,CAC7D,GAAI,EAAK,OAAS,GAAyB,EAAK,OAAS,EACvD,MAAU,WACR,6CAA6C,EAAsB,8CACrE,EAGF,IAAM,EAAI,EAAK,YAAY,EACrB,EAAI,EAAK,YAAY,EAE3B,GAAI,IAAM,EAAG,MAAO,GAEpB,GAAI,EAAE,SAAW,EAAG,MAAO,IAAE,SAAW,GAExC,GAAI,EAAE,SAAW,EAAG,MAAO,GAG3B,GAAM,CAAC,EAAS,GAAU,EAAE,OAAS,EAAE,OAAS,CAAC,EAAG,CAAC,EAAI,CAAC,EAAG,CAAC,EACxD,EAAgB,EAAQ,OACxB,EAAe,EAAO,OAExB,EAAU,MAAM,KAAK,CAAE,OAAQ,EAAgB,CAAE,GAAI,EAAG,IAAM,CAAC,EAC/D,EAAc,MAAM,EAAgB,CAAC,EAEzC,IAAK,IAAI,EAAI,EAAG,GAAK,EAAc,IAAK,CACtC,EAAQ,GAAK,EACb,IAAK,IAAI,EAAI,EAAG,GAAK,EAAe,IAAK,CACvC,IAAM,EAAO,EAAO,EAAI,KAAO,EAAQ,EAAI,GAAK,EAAI,EAEpD,EAAQ,GAAK,KAAK,IAChB,EAAQ,EAAI,GAAK,EACjB,EAAQ,GAAK,EACb,EAAQ,EAAI,GAAK,CACnB,CACF,CAEA,CAAC,EAAS,GAAW,CAAC,EAAS,CAAO,CACxC,CAKA,MAAO,GAFU,EAAQ,GAEH,KAAK,IAAI,EAAE,OAAQ,EAAE,MAAM,CACnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"similarity.d.ts","sourceRoot":"","sources":["../../src/string/similarity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"similarity.d.ts","sourceRoot":"","sources":["../../src/string/similarity.ts"],"names":[],"mappings":"AAsBA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CA2C7D"}
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import { ArsenalValidationError as e } from "../errors.js";
|
|
2
1
|
//#region src/string/similarity.ts
|
|
3
|
-
var
|
|
4
|
-
function
|
|
5
|
-
if (
|
|
6
|
-
let
|
|
7
|
-
if (
|
|
8
|
-
if (
|
|
9
|
-
if (
|
|
10
|
-
let [
|
|
11
|
-
for (let e = 1; e <=
|
|
12
|
-
|
|
13
|
-
for (let t = 1; t <=
|
|
14
|
-
let n =
|
|
15
|
-
|
|
2
|
+
var e = 1e4;
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
if (t.length > e || n.length > e) throw RangeError(`similarity: input strings must not exceed ${e} characters to prevent excessive memory usage`);
|
|
5
|
+
let r = t.toLowerCase(), i = n.toLowerCase();
|
|
6
|
+
if (r === i) return 1;
|
|
7
|
+
if (r.length === 0) return +(i.length === 0);
|
|
8
|
+
if (i.length === 0) return 0;
|
|
9
|
+
let [a, o] = r.length < i.length ? [r, i] : [i, r], s = a.length, c = o.length, l = Array.from({ length: s + 1 }, (e, t) => t), u = Array(s + 1);
|
|
10
|
+
for (let e = 1; e <= c; e++) {
|
|
11
|
+
u[0] = e;
|
|
12
|
+
for (let t = 1; t <= s; t++) {
|
|
13
|
+
let n = o[e - 1] === a[t - 1] ? 0 : 1;
|
|
14
|
+
u[t] = Math.min(u[t - 1] + 1, l[t] + 1, l[t - 1] + n);
|
|
16
15
|
}
|
|
17
|
-
[
|
|
16
|
+
[l, u] = [u, l];
|
|
18
17
|
}
|
|
19
|
-
return 1 -
|
|
18
|
+
return 1 - l[s] / Math.max(r.length, i.length);
|
|
20
19
|
}
|
|
21
20
|
//#endregion
|
|
22
|
-
export {
|
|
21
|
+
export { t as similarity };
|
|
23
22
|
|
|
24
23
|
//# sourceMappingURL=similarity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"similarity.js","names":[],"sources":["../../src/string/similarity.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"similarity.js","names":[],"sources":["../../src/string/similarity.ts"],"sourcesContent":["/**\n * Calculate the similarity between two strings using the Levenshtein distance algorithm.\n *\n * @example\n * ```ts\n * similarity('abc', 'abc') // 1\n * similarity('a', 'b') // 0\n * similarity('ab', 'ac') // 0.5\n * similarity('doe', 'John Doe') // 0.25\n * similarity('abc', 'axc') // 0.6666666666666667\n * similarity('kitten', 'sitting') // 0.5714285714285714\n * ```\n *\n * @param str1 - The first string.\n * @param str2 - The second string.\n *\n * @returns A number between 0 and 1 representing the similarity between the two strings.\n *\n * @throws {RangeError} If either input string exceeds 10 000 characters.\n */\nconst MAX_SIMILARITY_LENGTH = 10_000;\n\nexport function similarity(str1: string, str2: string): number {\n if (str1.length > MAX_SIMILARITY_LENGTH || str2.length > MAX_SIMILARITY_LENGTH) {\n throw new RangeError(\n `similarity: input strings must not exceed ${MAX_SIMILARITY_LENGTH} characters to prevent excessive memory usage`,\n );\n }\n\n const a = str1.toLowerCase();\n const b = str2.toLowerCase();\n\n if (a === b) return 1;\n\n if (a.length === 0) return b.length === 0 ? 1 : 0;\n\n if (b.length === 0) return 0;\n\n // Swap to ensure we use the smaller string for columns (O(min(A,B)) space)\n const [shorter, longer] = a.length < b.length ? [a, b] : [b, a];\n const shorterLength = shorter.length;\n const longerLength = longer.length;\n\n let prevRow = Array.from({ length: shorterLength + 1 }, (_, i) => i);\n let currRow = new Array(shorterLength + 1);\n\n for (let i = 1; i <= longerLength; i++) {\n currRow[0] = i;\n for (let j = 1; j <= shorterLength; j++) {\n const cost = longer[i - 1] === shorter[j - 1] ? 0 : 1;\n\n currRow[j] = Math.min(\n currRow[j - 1] + 1, // insertion\n prevRow[j] + 1, // deletion\n prevRow[j - 1] + cost, // substitution\n );\n }\n // Swap rows for the next iteration (avoid allocation)\n [prevRow, currRow] = [currRow, prevRow];\n }\n\n // After the loop, a result is in prevRow because of the swap\n const distance = prevRow[shorterLength];\n\n return 1 - distance / Math.max(a.length, b.length);\n}\n"],"mappings":";AAoBA,IAAM,IAAwB;AAE9B,SAAgB,EAAW,GAAc,GAAsB;CAC7D,IAAI,EAAK,SAAS,KAAyB,EAAK,SAAS,GACvD,MAAU,WACR,6CAA6C,EAAsB,8CACrE;CAGF,IAAM,IAAI,EAAK,YAAY,GACrB,IAAI,EAAK,YAAY;CAE3B,IAAI,MAAM,GAAG,OAAO;CAEpB,IAAI,EAAE,WAAW,GAAG,OAAO,IAAE,WAAW;CAExC,IAAI,EAAE,WAAW,GAAG,OAAO;CAG3B,IAAM,CAAC,GAAS,KAAU,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GACxD,IAAgB,EAAQ,QACxB,IAAe,EAAO,QAExB,IAAU,MAAM,KAAK,EAAE,QAAQ,IAAgB,EAAE,IAAI,GAAG,MAAM,CAAC,GAC/D,IAAc,MAAM,IAAgB,CAAC;CAEzC,KAAK,IAAI,IAAI,GAAG,KAAK,GAAc,KAAK;EACtC,EAAQ,KAAK;EACb,KAAK,IAAI,IAAI,GAAG,KAAK,GAAe,KAAK;GACvC,IAAM,IAAO,EAAO,IAAI,OAAO,EAAQ,IAAI,KAAK,IAAI;GAEpD,EAAQ,KAAK,KAAK,IAChB,EAAQ,IAAI,KAAK,GACjB,EAAQ,KAAK,GACb,EAAQ,IAAI,KAAK,CACnB;EACF;EAEA,CAAC,GAAS,KAAW,CAAC,GAAS,CAAO;CACxC;CAKA,OAAO,IAFU,EAAQ,KAEH,KAAK,IAAI,EAAE,QAAQ,EAAE,MAAM;AACnD"}
|
package/dist/string/truncate.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
function e(e,t=25,{completeWords:n=!1,ellipsis:r=`…`}={}){if(typeof e!=`string`)throw TypeError(`truncate: str must be a string`);if(typeof t!=`number`||!Number.isFinite(t)||t<0)throw RangeError(`truncate: limit must be a non-negative finite number`);if(e.length<=t)return e;let i=t;if(n){let n=e.substring(0,t).lastIndexOf(` `);n>0&&(i=n)}return`${e.substring(0,i).trim()}${r}`}exports.truncate=e;
|
|
2
2
|
//# sourceMappingURL=truncate.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"truncate.cjs","names":[],"sources":["../../src/string/truncate.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"truncate.cjs","names":[],"sources":["../../src/string/truncate.ts"],"sourcesContent":["export type TruncateOptions = {\n completeWords?: boolean;\n ellipsis?: string;\n};\n\n/**\n * Truncates a string if it is longer than the given maximum string length. The last characters of the truncated string are replaced with the ellipsis sign \"…\".\n *\n * @example\n * ```ts\n * const text = 'Hello World';\n * truncate(text, 5); // 'Hello…'\n * truncate(text, 8, { completeWords: true }); // 'Hello…'\n * truncate(text, 5, { ellipsis: '...' }); // 'Hello...'\n * ```\n *\n * @param str - The string to truncate.\n * @param limit - The maximum string length.\n * @param options - Options for truncation.\n * @param [options.completeWords] - If true, truncate to the nearest word boundary.\n * @param [options.ellipsis] - Suffix appended after truncation (default: '…').\n *\n * @returns The truncated string.\n *\n * @throws {TypeError} If str is not a string.\n * @throws {RangeError} If limit is not a non-negative finite number.\n */\nexport function truncate(\n str: string,\n limit = 25,\n { completeWords = false, ellipsis = '…' }: TruncateOptions = {},\n): string {\n if (typeof str !== 'string') {\n throw new TypeError('truncate: str must be a string');\n }\n\n if (typeof limit !== 'number' || !Number.isFinite(limit) || limit < 0) {\n throw new RangeError('truncate: limit must be a non-negative finite number');\n }\n\n if (str.length <= limit) {\n return str;\n }\n\n let end = limit;\n\n if (completeWords) {\n const wordEnd = str.substring(0, limit).lastIndexOf(' ');\n\n if (wordEnd > 0) end = wordEnd;\n }\n\n return `${str.substring(0, end).trim()}${ellipsis}`;\n}\n"],"mappings":"AA2BA,SAAgB,EACd,EACA,EAAQ,GACR,CAAE,gBAAgB,GAAO,WAAW,KAAyB,CAAC,EACtD,CACR,GAAI,OAAO,GAAQ,SACjB,MAAU,UAAU,gCAAgC,EAGtD,GAAI,OAAO,GAAU,UAAY,CAAC,OAAO,SAAS,CAAK,GAAK,EAAQ,EAClE,MAAU,WAAW,sDAAsD,EAG7E,GAAI,EAAI,QAAU,EAChB,OAAO,EAGT,IAAI,EAAM,EAEV,GAAI,EAAe,CACjB,IAAM,EAAU,EAAI,UAAU,EAAG,CAAK,CAAC,CAAC,YAAY,GAAG,EAEnD,EAAU,IAAG,EAAM,EACzB,CAEA,MAAO,GAAG,EAAI,UAAU,EAAG,CAAG,CAAC,CAAC,KAAK,IAAI,GAC3C"}
|
|
@@ -21,7 +21,8 @@ export type TruncateOptions = {
|
|
|
21
21
|
*
|
|
22
22
|
* @returns The truncated string.
|
|
23
23
|
*
|
|
24
|
-
* @throws {
|
|
24
|
+
* @throws {TypeError} If str is not a string.
|
|
25
|
+
* @throws {RangeError} If limit is not a non-negative finite number.
|
|
25
26
|
*/
|
|
26
27
|
export declare function truncate(str: string, limit?: number, { completeWords, ellipsis }?: TruncateOptions): string;
|
|
27
28
|
//# sourceMappingURL=truncate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"truncate.d.ts","sourceRoot":"","sources":["../../src/string/truncate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"truncate.d.ts","sourceRoot":"","sources":["../../src/string/truncate.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,QAAQ,CACtB,GAAG,EAAE,MAAM,EACX,KAAK,SAAK,EACV,EAAE,aAAqB,EAAE,QAAc,EAAE,GAAE,eAAoB,GAC9D,MAAM,CAsBR"}
|
package/dist/string/truncate.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { ArsenalValidationError as e } from "../errors.js";
|
|
2
1
|
//#region src/string/truncate.ts
|
|
3
|
-
function
|
|
4
|
-
if (typeof
|
|
5
|
-
if (typeof
|
|
6
|
-
if (
|
|
7
|
-
let
|
|
8
|
-
if (
|
|
9
|
-
let
|
|
10
|
-
|
|
2
|
+
function e(e, t = 25, { completeWords: n = !1, ellipsis: r = "…" } = {}) {
|
|
3
|
+
if (typeof e != "string") throw TypeError("truncate: str must be a string");
|
|
4
|
+
if (typeof t != "number" || !Number.isFinite(t) || t < 0) throw RangeError("truncate: limit must be a non-negative finite number");
|
|
5
|
+
if (e.length <= t) return e;
|
|
6
|
+
let i = t;
|
|
7
|
+
if (n) {
|
|
8
|
+
let n = e.substring(0, t).lastIndexOf(" ");
|
|
9
|
+
n > 0 && (i = n);
|
|
11
10
|
}
|
|
12
|
-
return `${
|
|
11
|
+
return `${e.substring(0, i).trim()}${r}`;
|
|
13
12
|
}
|
|
14
13
|
//#endregion
|
|
15
|
-
export {
|
|
14
|
+
export { e as truncate };
|
|
16
15
|
|
|
17
16
|
//# sourceMappingURL=truncate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"truncate.js","names":[],"sources":["../../src/string/truncate.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"truncate.js","names":[],"sources":["../../src/string/truncate.ts"],"sourcesContent":["export type TruncateOptions = {\n completeWords?: boolean;\n ellipsis?: string;\n};\n\n/**\n * Truncates a string if it is longer than the given maximum string length. The last characters of the truncated string are replaced with the ellipsis sign \"…\".\n *\n * @example\n * ```ts\n * const text = 'Hello World';\n * truncate(text, 5); // 'Hello…'\n * truncate(text, 8, { completeWords: true }); // 'Hello…'\n * truncate(text, 5, { ellipsis: '...' }); // 'Hello...'\n * ```\n *\n * @param str - The string to truncate.\n * @param limit - The maximum string length.\n * @param options - Options for truncation.\n * @param [options.completeWords] - If true, truncate to the nearest word boundary.\n * @param [options.ellipsis] - Suffix appended after truncation (default: '…').\n *\n * @returns The truncated string.\n *\n * @throws {TypeError} If str is not a string.\n * @throws {RangeError} If limit is not a non-negative finite number.\n */\nexport function truncate(\n str: string,\n limit = 25,\n { completeWords = false, ellipsis = '…' }: TruncateOptions = {},\n): string {\n if (typeof str !== 'string') {\n throw new TypeError('truncate: str must be a string');\n }\n\n if (typeof limit !== 'number' || !Number.isFinite(limit) || limit < 0) {\n throw new RangeError('truncate: limit must be a non-negative finite number');\n }\n\n if (str.length <= limit) {\n return str;\n }\n\n let end = limit;\n\n if (completeWords) {\n const wordEnd = str.substring(0, limit).lastIndexOf(' ');\n\n if (wordEnd > 0) end = wordEnd;\n }\n\n return `${str.substring(0, end).trim()}${ellipsis}`;\n}\n"],"mappings":";AA2BA,SAAgB,EACd,GACA,IAAQ,IACR,EAAE,mBAAgB,IAAO,cAAW,QAAyB,CAAC,GACtD;CACR,IAAI,OAAO,KAAQ,UACjB,MAAU,UAAU,gCAAgC;CAGtD,IAAI,OAAO,KAAU,YAAY,CAAC,OAAO,SAAS,CAAK,KAAK,IAAQ,GAClE,MAAU,WAAW,sDAAsD;CAG7E,IAAI,EAAI,UAAU,GAChB,OAAO;CAGT,IAAI,IAAM;CAEV,IAAI,GAAe;EACjB,IAAM,IAAU,EAAI,UAAU,GAAG,CAAK,CAAC,CAAC,YAAY,GAAG;EAEvD,AAAI,IAAU,MAAG,IAAM;CACzB;CAEA,OAAO,GAAG,EAAI,UAAU,GAAG,CAAG,CAAC,CAAC,KAAK,IAAI;AAC3C"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** A function that tears down a subscription or listener registration. */
|
|
2
2
|
export type Unsubscribe = () => void;
|
|
3
|
-
export type Fn<Args extends unknown[] =
|
|
3
|
+
export type Fn<Args extends unknown[] = never[], Result = unknown> = (...args: Args) => Result;
|
|
4
4
|
export type Obj = Record<string, unknown>;
|
|
5
5
|
/**
|
|
6
6
|
* A predicate that takes a single value and returns a boolean.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;AAErC,MAAM,MAAM,EAAE,CAAC,IAAI,SAAS,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;AAErC,MAAM,MAAM,EAAE,CAAC,IAAI,SAAS,OAAO,EAAE,GAAG,KAAK,EAAE,EAAE,MAAM,GAAG,OAAO,IAAI,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC;AAE/F,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C;;;;GAIG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC;AAEjD,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC;AAE/C,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vielzeug/arsenal",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Tree-shakeable TypeScript utility library — array, object, string, async, cache, math, and more",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -41,18 +41,18 @@
|
|
|
41
41
|
"import": "./dist/function/index.js",
|
|
42
42
|
"require": "./dist/function/index.cjs"
|
|
43
43
|
},
|
|
44
|
-
"./math": {
|
|
45
|
-
"source": "./src/math/index.ts",
|
|
46
|
-
"types": "./dist/math/index.d.ts",
|
|
47
|
-
"import": "./dist/math/index.js",
|
|
48
|
-
"require": "./dist/math/index.cjs"
|
|
49
|
-
},
|
|
50
44
|
"./guards": {
|
|
51
45
|
"source": "./src/guards/index.ts",
|
|
52
46
|
"types": "./dist/guards/index.d.ts",
|
|
53
47
|
"import": "./dist/guards/index.js",
|
|
54
48
|
"require": "./dist/guards/index.cjs"
|
|
55
49
|
},
|
|
50
|
+
"./math": {
|
|
51
|
+
"source": "./src/math/index.ts",
|
|
52
|
+
"types": "./dist/math/index.d.ts",
|
|
53
|
+
"import": "./dist/math/index.js",
|
|
54
|
+
"require": "./dist/math/index.cjs"
|
|
55
|
+
},
|
|
56
56
|
"./object": {
|
|
57
57
|
"source": "./src/object/index.ts",
|
|
58
58
|
"types": "./dist/object/index.d.ts",
|
|
@@ -70,12 +70,6 @@
|
|
|
70
70
|
"types": "./dist/string/index.d.ts",
|
|
71
71
|
"import": "./dist/string/index.js",
|
|
72
72
|
"require": "./dist/string/index.cjs"
|
|
73
|
-
},
|
|
74
|
-
"./typed": {
|
|
75
|
-
"source": "./src/typed/index.ts",
|
|
76
|
-
"types": "./dist/typed/index.d.ts",
|
|
77
|
-
"import": "./dist/typed/index.js",
|
|
78
|
-
"require": "./dist/typed/index.cjs"
|
|
79
73
|
}
|
|
80
74
|
},
|
|
81
75
|
"scripts": {
|
|
@@ -86,7 +80,8 @@
|
|
|
86
80
|
"prepublishOnly": "pnpm run build",
|
|
87
81
|
"preview": "vite preview",
|
|
88
82
|
"test": "pnpm run verify:exports && vitest",
|
|
89
|
-
"
|
|
83
|
+
"sync:exports": "node ./scripts/sync-exports.mjs",
|
|
84
|
+
"verify:exports": "node ./scripts/sync-exports.mjs --check",
|
|
90
85
|
"build:bundle": "vite build --config vite.bundle.config.ts"
|
|
91
86
|
},
|
|
92
87
|
"publishConfig": {
|
|
@@ -94,12 +89,12 @@
|
|
|
94
89
|
"registry": "https://registry.npmjs.org/"
|
|
95
90
|
},
|
|
96
91
|
"engines": {
|
|
97
|
-
"node": ">=
|
|
92
|
+
"node": ">=22"
|
|
98
93
|
},
|
|
99
94
|
"devDependencies": {
|
|
100
|
-
"@types/node": "^26.1.
|
|
101
|
-
"typescript": "
|
|
102
|
-
"vite": "^8.
|
|
103
|
-
"vitest": "^4.1.
|
|
95
|
+
"@types/node": "^26.1.2",
|
|
96
|
+
"typescript": "^6.0.3",
|
|
97
|
+
"vite": "^8.2.0",
|
|
98
|
+
"vitest": "^4.1.10"
|
|
104
99
|
}
|
|
105
100
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_secureRandomIndex.cjs","names":[],"sources":["../../src/_common/_secureRandomIndex.ts"],"sourcesContent":["/**\n * Returns a cryptographically random integer in `[0, exclusiveMax)` via `crypto.getRandomValues`.\n * Shared by `random()`, `shuffle()`, and `drawMany()` — the single source of truth for converting\n * a random `Uint32` into a bounded index.\n *\n * Module-private: underscore-prefixed file is excluded from barrel exports.\n * @internal\n */\nexport function secureRandomIndex(exclusiveMax: number): number {\n // Divide by 0x100000000 (not 0xffffffff) to produce [0, 1) instead of [0, 1]\n const randomValue = crypto.getRandomValues(new Uint32Array(1))[0]! / 0x100000000;\n\n return Math.floor(randomValue * exclusiveMax);\n}\n"],"mappings":"AAQA,SAAgB,EAAkB,EAA8B,CAE9D,IAAM,EAAc,OAAO,gBAAgB,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,GAAM,WAErE,OAAO,KAAK,MAAM,EAAc,CAAY,CAC9C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_secureRandomIndex.d.ts","sourceRoot":"","sources":["../../src/_common/_secureRandomIndex.ts"],"names":[],"mappings":""}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
//#region src/_common/_secureRandomIndex.ts
|
|
2
|
-
function e(e) {
|
|
3
|
-
let t = crypto.getRandomValues(/* @__PURE__ */ new Uint32Array(1))[0] / 4294967296;
|
|
4
|
-
return Math.floor(t * e);
|
|
5
|
-
}
|
|
6
|
-
//#endregion
|
|
7
|
-
export { e as secureRandomIndex };
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=_secureRandomIndex.js.map
|