randomcryp 1.0.5 → 1.0.6
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 +1 -1
- package/dist/index.d.ts +32 -129
- package/dist/lib/bool.d.ts +5 -0
- package/dist/lib/boolean.d.ts +1 -0
- package/dist/lib/choice.d.ts +7 -0
- package/dist/lib/float.d.ts +5 -0
- package/dist/lib/ifloat.d.ts +7 -0
- package/dist/lib/percentage.d.ts +5 -0
- package/dist/lib/pick.d.ts +1 -0
- package/dist/lib/randInt.d.ts +1 -0
- package/dist/lib/random.d.ts +1 -0
- package/dist/lib/range.d.ts +8 -0
- package/dist/lib/rangeInt.d.ts +8 -0
- package/dist/lib/safeInt.d.ts +8 -0
- package/dist/lib/shuffle.d.ts +4 -0
- package/dist/lib/uSafeInt.d.ts +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# randomcryp
|
|
2
2
|
|
|
3
|
-
A cryptographically secure, feature rich, zero dependency, lightweight and browser friendly random number generator library. Only ~
|
|
3
|
+
A cryptographically secure, feature rich, zero dependency, lightweight and browser friendly random number generator library. Only ~4KB in size.
|
|
4
4
|
Uses [Crypto.getRandomValues()](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues) to get its randomness.
|
|
5
5
|
The spelling is random-creep in case you are wondering.
|
|
6
6
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,129 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
declare
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
export const choice: <E>(choices: ArrayLike<E>) => E | undefined;
|
|
34
|
-
}
|
|
35
|
-
declare module "lib/safeInt" {
|
|
36
|
-
/**
|
|
37
|
-
* Generates a random integer
|
|
38
|
-
* between {@link Number.MIN_SAFE_INTEGER} (inclusive) and {@link Number.MAX_SAFE_INTEGER} (inclusive).
|
|
39
|
-
* +0 and -0 can both appear, and technically 54 bit in precision but not recommended for general usage.
|
|
40
|
-
*
|
|
41
|
-
* Use {@link uSafeInt} for instead.
|
|
42
|
-
**/
|
|
43
|
-
export const safeInt: () => number;
|
|
44
|
-
}
|
|
45
|
-
declare module "lib/ifloat" {
|
|
46
|
-
/**
|
|
47
|
-
* Generates a random number between -1 (inclusive) and 1 (inclusive).
|
|
48
|
-
* Uses {@link safeInt} and thus not recommended for general usage also.
|
|
49
|
-
*
|
|
50
|
-
* Should be somewhat better for calculating PI.
|
|
51
|
-
**/
|
|
52
|
-
export const ifloat: () => number;
|
|
53
|
-
}
|
|
54
|
-
declare module "lib/percentage" {
|
|
55
|
-
/**
|
|
56
|
-
* Generates true with the probability of the percentage value given.
|
|
57
|
-
* @example percentage(20) // should return true 20% of the time and false 80% of the time.
|
|
58
|
-
**/
|
|
59
|
-
export const percentage: (input: number) => boolean;
|
|
60
|
-
}
|
|
61
|
-
declare module "lib/pick" {
|
|
62
|
-
export { choice as pick } from "lib/choice";
|
|
63
|
-
}
|
|
64
|
-
declare module "lib/rangeInt" {
|
|
65
|
-
/**
|
|
66
|
-
* Generates a random number integer
|
|
67
|
-
* between given `min` (inclusive) and `max` (inclusive).
|
|
68
|
-
* Throws if `min` > `max`.
|
|
69
|
-
*
|
|
70
|
-
* @example rangeInt(1, 100) // 35
|
|
71
|
-
*/
|
|
72
|
-
export const rangeInt: (min: number, max: number) => number;
|
|
73
|
-
}
|
|
74
|
-
declare module "lib/randInt" {
|
|
75
|
-
export { rangeInt as randInt } from "lib/rangeInt";
|
|
76
|
-
}
|
|
77
|
-
declare module "lib/random" {
|
|
78
|
-
export { float as random } from "lib/float";
|
|
79
|
-
}
|
|
80
|
-
declare module "lib/range" {
|
|
81
|
-
/**
|
|
82
|
-
* Generates a random number (not integer)
|
|
83
|
-
* between given `min` (inclusive) and `max` (exclusive).
|
|
84
|
-
* Throws if `min` > `max`.
|
|
85
|
-
*
|
|
86
|
-
* @example range(1, 10) // 2.4802525465053487
|
|
87
|
-
*/
|
|
88
|
-
export const range: (min: number, max: number) => number;
|
|
89
|
-
}
|
|
90
|
-
declare module "lib/shuffle" {
|
|
91
|
-
/**
|
|
92
|
-
* Randomly shuffles the elements of an array ***in place***. The original array is modified.
|
|
93
|
-
*/
|
|
94
|
-
export const shuffle: <E>(array: Array<E>) => Array<E>;
|
|
95
|
-
}
|
|
96
|
-
declare module "index" {
|
|
97
|
-
import { bool } from "lib/bool";
|
|
98
|
-
import { boolean } from "lib/boolean";
|
|
99
|
-
import { choice } from "lib/choice";
|
|
100
|
-
import { float } from "lib/float";
|
|
101
|
-
import { ifloat } from "lib/ifloat";
|
|
102
|
-
import { percentage } from "lib/percentage";
|
|
103
|
-
import { pick } from "lib/pick";
|
|
104
|
-
import { randInt } from "lib/randInt";
|
|
105
|
-
import { random } from "lib/random";
|
|
106
|
-
import { range } from "lib/range";
|
|
107
|
-
import { rangeInt } from "lib/rangeInt";
|
|
108
|
-
import { safeInt } from "lib/safeInt";
|
|
109
|
-
import { shuffle } from "lib/shuffle";
|
|
110
|
-
import { uSafeInt } from "lib/uSafeInt";
|
|
111
|
-
export { bool, boolean, choice, float, ifloat, percentage, pick, randInt, random, range, rangeInt, safeInt, shuffle, uSafeInt, };
|
|
112
|
-
const _default: {
|
|
113
|
-
bool: () => boolean;
|
|
114
|
-
boolean: () => boolean;
|
|
115
|
-
choice: <E>(choices: ArrayLike<E>) => E | undefined;
|
|
116
|
-
float: () => number;
|
|
117
|
-
ifloat: () => number;
|
|
118
|
-
percentage: (input: number) => boolean;
|
|
119
|
-
pick: <E>(choices: ArrayLike<E>) => E | undefined;
|
|
120
|
-
randInt: (min: number, max: number) => number;
|
|
121
|
-
random: () => number;
|
|
122
|
-
range: (min: number, max: number) => number;
|
|
123
|
-
rangeInt: (min: number, max: number) => number;
|
|
124
|
-
safeInt: () => number;
|
|
125
|
-
shuffle: <E>(array: Array<E>) => Array<E>;
|
|
126
|
-
uSafeInt: () => number;
|
|
127
|
-
};
|
|
128
|
-
export default _default;
|
|
129
|
-
}
|
|
1
|
+
import { bool } from "./lib/bool";
|
|
2
|
+
import { boolean } from "./lib/boolean";
|
|
3
|
+
import { choice } from "./lib/choice";
|
|
4
|
+
import { float } from "./lib/float";
|
|
5
|
+
import { ifloat } from "./lib/ifloat";
|
|
6
|
+
import { percentage } from "./lib/percentage";
|
|
7
|
+
import { pick } from "./lib/pick";
|
|
8
|
+
import { randInt } from "./lib/randInt";
|
|
9
|
+
import { random } from "./lib/random";
|
|
10
|
+
import { range } from "./lib/range";
|
|
11
|
+
import { rangeInt } from "./lib/rangeInt";
|
|
12
|
+
import { safeInt } from "./lib/safeInt";
|
|
13
|
+
import { shuffle } from "./lib/shuffle";
|
|
14
|
+
import { uSafeInt } from "./lib/uSafeInt";
|
|
15
|
+
export { bool, boolean, choice, float, ifloat, percentage, pick, randInt, random, range, rangeInt, safeInt, shuffle, uSafeInt, };
|
|
16
|
+
declare const _default: {
|
|
17
|
+
bool: () => boolean;
|
|
18
|
+
boolean: () => boolean;
|
|
19
|
+
choice: <E>(choices: ArrayLike<E>) => E | undefined;
|
|
20
|
+
float: () => number;
|
|
21
|
+
ifloat: () => number;
|
|
22
|
+
percentage: (input: number) => boolean;
|
|
23
|
+
pick: <E>(choices: ArrayLike<E>) => E | undefined;
|
|
24
|
+
randInt: (min: number, max: number) => number;
|
|
25
|
+
random: () => number;
|
|
26
|
+
range: (min: number, max: number) => number;
|
|
27
|
+
rangeInt: (min: number, max: number) => number;
|
|
28
|
+
safeInt: () => number;
|
|
29
|
+
shuffle: <E>(array: Array<E>) => Array<E>;
|
|
30
|
+
uSafeInt: () => number;
|
|
31
|
+
};
|
|
32
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { bool as boolean } from "./bool";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Randomly choose an element from an array-like object.
|
|
3
|
+
* @returns undefined if the array is empty.
|
|
4
|
+
* @returns a random element from the array if at least one element is present.
|
|
5
|
+
* @example choice([1, 2, 3]) // 2
|
|
6
|
+
*/
|
|
7
|
+
export declare const choice: <E>(choices: ArrayLike<E>) => E | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { choice as pick } from "./choice";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { rangeInt as randInt } from "./rangeInt";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { float as random } from "./float";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a random integer
|
|
3
|
+
* between {@link Number.MIN_SAFE_INTEGER} (inclusive) and {@link Number.MAX_SAFE_INTEGER} (inclusive).
|
|
4
|
+
* +0 and -0 can both appear, and technically 54 bit in precision but not recommended for general usage.
|
|
5
|
+
*
|
|
6
|
+
* Use {@link uSafeInt} for instead.
|
|
7
|
+
**/
|
|
8
|
+
export declare const safeInt: () => number;
|
package/package.json
CHANGED