@xtia/alea-rc 0.0.2 → 0.0.4
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 +2 -2
- package/browser.js +1 -1
- package/common.d.ts +6 -3
- package/common.js +6 -3
- package/internal/charsets.d.ts +14 -0
- package/internal/charsets.js +22 -0
- package/internal/factories.d.ts +1 -1
- package/internal/factories.js +2 -2
- package/internal/util.d.ts +0 -14
- package/internal/util.js +0 -22
- package/node.js +1 -1
- package/other.d.ts +2 -2
- package/other.js +2 -2
- package/package.json +1 -1
- package/prng/index.d.ts +3 -3
- package/prng/index.js +3 -3
- package/prng/mulberry32.d.ts +1 -1
- package/prng/mulberry32.js +2 -2
- package/prng/sfc32.d.ts +1 -1
- package/prng/sfc32.js +2 -2
- package/prng/xoshiro128pp.d.ts +1 -1
- package/prng/xoshiro128pp.js +2 -2
package/README.md
CHANGED
|
@@ -7,8 +7,8 @@ Alea is a utility wrapper for turning random numbers into useful values. Give it
|
|
|
7
7
|
* Fully typed
|
|
8
8
|
* Crypto-safe and seeded algorithms out-of-the-box
|
|
9
9
|
* No dependencies
|
|
10
|
-
* ~2.3kb minified
|
|
11
|
-
* Ranged int, array shuffling, dice roll, weighted sampling, phrase generation,
|
|
10
|
+
* ~2.3kb minified core
|
|
11
|
+
* Ranged int, array shuffling, dice roll, weighted sampling, phrase generation, UUID, bytes and many more
|
|
12
12
|
|
|
13
13
|
## Brief:
|
|
14
14
|
|
package/browser.js
CHANGED
package/common.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { Alea } from "./internal/alea";
|
|
1
|
+
import { Alea } from "./internal/alea.js";
|
|
2
2
|
export type { Alea };
|
|
3
|
-
export { createAleaFromByteSource, createAleaFromSeed, createAleaFromFunc, } from "./internal/factories";
|
|
4
|
-
export { charsets } from "./internal/
|
|
3
|
+
export { createAleaFromByteSource, createAleaFromSeed, createAleaFromFunc, } from "./internal/factories.js";
|
|
4
|
+
export { charsets } from "./internal/charsets.js";
|
|
5
|
+
/**
|
|
6
|
+
* An Alea instance that uses Math.random() as a source
|
|
7
|
+
*/
|
|
5
8
|
export declare const alea: Alea;
|
package/common.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { Alea } from "./internal/alea";
|
|
2
|
-
export { createAleaFromByteSource, createAleaFromSeed, createAleaFromFunc, } from "./internal/factories";
|
|
3
|
-
export { charsets } from "./internal/
|
|
1
|
+
import { Alea } from "./internal/alea.js";
|
|
2
|
+
export { createAleaFromByteSource, createAleaFromSeed, createAleaFromFunc, } from "./internal/factories.js";
|
|
3
|
+
export { charsets } from "./internal/charsets.js";
|
|
4
|
+
/**
|
|
5
|
+
* An Alea instance that uses Math.random() as a source
|
|
6
|
+
*/
|
|
4
7
|
export const alea = new Alea(Math.random);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const charsets: {
|
|
2
|
+
lowercase: string;
|
|
3
|
+
uppercase: string;
|
|
4
|
+
numbers: string;
|
|
5
|
+
hexadecimalUppercase: string;
|
|
6
|
+
hexadecimalLowercase: string;
|
|
7
|
+
alphanumericUppercase: string;
|
|
8
|
+
alphanumericLowercase: string;
|
|
9
|
+
alphanumericMixedCase: string;
|
|
10
|
+
urlSafe: string;
|
|
11
|
+
wide: string;
|
|
12
|
+
exclude: (charset: string, excluded: string) => string;
|
|
13
|
+
unique: (charset: string) => string;
|
|
14
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const lowercase = "abcdefghijklmnopqrstuvwxyz";
|
|
2
|
+
const uppercase = lowercase.toUpperCase();
|
|
3
|
+
const numbers = "0123456789";
|
|
4
|
+
export const charsets = {
|
|
5
|
+
lowercase,
|
|
6
|
+
uppercase,
|
|
7
|
+
numbers,
|
|
8
|
+
hexadecimalUppercase: numbers + "ABCDEF",
|
|
9
|
+
hexadecimalLowercase: numbers + "abcdef",
|
|
10
|
+
alphanumericUppercase: uppercase + numbers,
|
|
11
|
+
alphanumericLowercase: lowercase + numbers,
|
|
12
|
+
alphanumericMixedCase: lowercase + uppercase + numbers,
|
|
13
|
+
urlSafe: uppercase + lowercase + numbers + "_-.~",
|
|
14
|
+
wide: uppercase + lowercase + numbers + "_-+=[]{};#:@~,./<>?!$%^&*()",
|
|
15
|
+
exclude: (charset, excluded) => {
|
|
16
|
+
const excludedSet = new Set([...excluded]);
|
|
17
|
+
return [...charset].filter(c => !excludedSet.has(c)).join("");
|
|
18
|
+
},
|
|
19
|
+
unique: (charset) => {
|
|
20
|
+
return [...new Set([...charset])].join("");
|
|
21
|
+
},
|
|
22
|
+
};
|
package/internal/factories.d.ts
CHANGED
package/internal/factories.js
CHANGED
package/internal/util.d.ts
CHANGED
|
@@ -1,15 +1 @@
|
|
|
1
1
|
export declare function murmur3_32(key: string, seed?: number): number;
|
|
2
|
-
export declare const charsets: {
|
|
3
|
-
lowercase: string;
|
|
4
|
-
uppercase: string;
|
|
5
|
-
numbers: string;
|
|
6
|
-
hexadecimalUppercase: string;
|
|
7
|
-
hexadecimalLowercase: string;
|
|
8
|
-
alphanumericUppercase: string;
|
|
9
|
-
alphanumericLowercase: string;
|
|
10
|
-
alphanumericMixedCase: string;
|
|
11
|
-
urlSafe: string;
|
|
12
|
-
wide: string;
|
|
13
|
-
exclude: (charset: string, excluded: string) => string;
|
|
14
|
-
unique: (charset: string) => string;
|
|
15
|
-
};
|
package/internal/util.js
CHANGED
|
@@ -39,25 +39,3 @@ export function murmur3_32(key, seed = 0) {
|
|
|
39
39
|
h1 ^= h1 >>> 16;
|
|
40
40
|
return h1 >>> 0;
|
|
41
41
|
}
|
|
42
|
-
const lowercase = "abcdefghijklmnopqrstuvwxyz";
|
|
43
|
-
const uppercase = lowercase.toUpperCase();
|
|
44
|
-
const numbers = "0123456789";
|
|
45
|
-
export const charsets = {
|
|
46
|
-
lowercase,
|
|
47
|
-
uppercase,
|
|
48
|
-
numbers,
|
|
49
|
-
hexadecimalUppercase: numbers + "ABCDEF",
|
|
50
|
-
hexadecimalLowercase: numbers + "abcdef",
|
|
51
|
-
alphanumericUppercase: uppercase + numbers,
|
|
52
|
-
alphanumericLowercase: lowercase + numbers,
|
|
53
|
-
alphanumericMixedCase: lowercase + uppercase + numbers,
|
|
54
|
-
urlSafe: uppercase + lowercase + numbers + "_-.~",
|
|
55
|
-
wide: uppercase + lowercase + numbers + "_-+=[]{};#:@~,./<>?!$%^&*()",
|
|
56
|
-
exclude: (charset, excluded) => {
|
|
57
|
-
const excludedSet = new Set([...excluded]);
|
|
58
|
-
return [...charset].filter(c => !excludedSet.has(c)).join("");
|
|
59
|
-
},
|
|
60
|
-
unique: (charset) => {
|
|
61
|
-
return [...new Set([...charset])].join("");
|
|
62
|
-
},
|
|
63
|
-
};
|
package/node.js
CHANGED
package/other.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Alea } from "./internal/alea";
|
|
1
|
+
import { Alea } from "./internal/alea.js";
|
|
2
2
|
export * from "./common";
|
|
3
3
|
/**
|
|
4
|
-
* An Alea instance that uses the
|
|
4
|
+
* An Alea instance that uses the runtime environment's `crypto` provider as a source
|
|
5
5
|
*/
|
|
6
6
|
export declare const cryptoAlea: Alea;
|
package/other.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Alea } from "./internal/alea";
|
|
1
|
+
import { Alea } from "./internal/alea.js";
|
|
2
2
|
export * from "./common";
|
|
3
3
|
/**
|
|
4
|
-
* An Alea instance that uses the
|
|
4
|
+
* An Alea instance that uses the runtime environment's `crypto` provider as a source
|
|
5
5
|
*/
|
|
6
6
|
export const cryptoAlea = new Alea(() => {
|
|
7
7
|
throw new Error("cryptoAlea is not available in this environment. Consider using createAleaFromByteSource() with your environment's crypto API.");
|
package/package.json
CHANGED
package/prng/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { mulberry32 } from "./mulberry32";
|
|
2
|
-
export { sfc32 } from "./sfc32";
|
|
3
|
-
export { xoshiro128pp } from "./xoshiro128pp";
|
|
1
|
+
export { mulberry32 } from "./mulberry32.js";
|
|
2
|
+
export { sfc32 } from "./sfc32.js";
|
|
3
|
+
export { xoshiro128pp } from "./xoshiro128pp.js";
|
package/prng/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { mulberry32 } from "./mulberry32";
|
|
2
|
-
export { sfc32 } from "./sfc32";
|
|
3
|
-
export { xoshiro128pp } from "./xoshiro128pp";
|
|
1
|
+
export { mulberry32 } from "./mulberry32.js";
|
|
2
|
+
export { sfc32 } from "./sfc32.js";
|
|
3
|
+
export { xoshiro128pp } from "./xoshiro128pp.js";
|
package/prng/mulberry32.d.ts
CHANGED
package/prng/mulberry32.js
CHANGED
package/prng/sfc32.d.ts
CHANGED
package/prng/sfc32.js
CHANGED
package/prng/xoshiro128pp.d.ts
CHANGED
package/prng/xoshiro128pp.js
CHANGED