shelving 1.50.0 → 1.50.1
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/package.json +6 -6
- package/util/random.d.ts +2 -1
- package/util/random.js +3 -2
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"state-management",
|
|
12
12
|
"query-builder"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.50.
|
|
14
|
+
"version": "1.50.1",
|
|
15
15
|
"repository": "https://github.com/dhoulb/shelving",
|
|
16
16
|
"author": "Dave Houlbrooke <dave@shax.com>",
|
|
17
17
|
"license": "0BSD",
|
|
@@ -61,16 +61,16 @@
|
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@google-cloud/firestore": "^4.15.1",
|
|
63
63
|
"@types/jest": "^27.4.0",
|
|
64
|
-
"@types/react": "^17.0.
|
|
64
|
+
"@types/react": "^17.0.39",
|
|
65
65
|
"@types/react-dom": "^17.0.11",
|
|
66
|
-
"@typescript-eslint/eslint-plugin": "^5.10.
|
|
67
|
-
"@typescript-eslint/parser": "^5.10.
|
|
66
|
+
"@typescript-eslint/eslint-plugin": "^5.10.2",
|
|
67
|
+
"@typescript-eslint/parser": "^5.10.2",
|
|
68
68
|
"eslint": "^8.8.0",
|
|
69
69
|
"eslint-config-prettier": "^8.3.0",
|
|
70
70
|
"eslint-plugin-import": "^2.25.4",
|
|
71
71
|
"eslint-plugin-prettier": "^4.0.0",
|
|
72
|
-
"firebase": "^9.6.
|
|
73
|
-
"jest": "^27.
|
|
72
|
+
"firebase": "^9.6.6",
|
|
73
|
+
"jest": "^27.5.0",
|
|
74
74
|
"jest-ts-webcompat-resolver": "^1.0.0",
|
|
75
75
|
"prettier": "^2.5.1",
|
|
76
76
|
"react": "^17.0.2",
|
package/util/random.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ import type { ImmutableArray } from "./array.js";
|
|
|
2
2
|
/** Generate a random integer between two numbers. */
|
|
3
3
|
export declare const getRandom: (min: number, max: number) => number;
|
|
4
4
|
/**
|
|
5
|
-
* Make a random key, e.g.
|
|
5
|
+
* Make a random key, e.g. `xs23r34hhsdx` or `e4m29klrugef`
|
|
6
6
|
* - Not designed to be cryptographically random!
|
|
7
7
|
* - Will probably clash — if you're making a random ID, check for existence of the record before saving.
|
|
8
|
+
* - Designed to be semi-readable, doesn't use capital letters or `i` or `o` or `l` or `u`
|
|
8
9
|
*/
|
|
9
10
|
export declare const getRandomKey: (length?: number) => string;
|
|
10
11
|
/** Get a random character from a string. */
|
package/util/random.js
CHANGED
|
@@ -4,11 +4,12 @@ import { getDefined } from "./undefined.js";
|
|
|
4
4
|
/** Generate a random integer between two numbers. */
|
|
5
5
|
export const getRandom = (min, max) => Math.round(Math.random() * (max - min) + min);
|
|
6
6
|
/**
|
|
7
|
-
* Make a random key, e.g.
|
|
7
|
+
* Make a random key, e.g. `xs23r34hhsdx` or `e4m29klrugef`
|
|
8
8
|
* - Not designed to be cryptographically random!
|
|
9
9
|
* - Will probably clash — if you're making a random ID, check for existence of the record before saving.
|
|
10
|
+
* - Designed to be semi-readable, doesn't use capital letters or `i` or `o` or `l` or `u`
|
|
10
11
|
*/
|
|
11
|
-
export const getRandomKey = (length =
|
|
12
|
+
export const getRandomKey = (length = 12) => joinStrings(yieldUntilLimit(yieldCall(getRandomCharacter, KEY_CHARS), length));
|
|
12
13
|
const KEY_CHARS = "0123456789abcdefghjkmnpqrstvwxyz";
|
|
13
14
|
/** Get a random character from a string. */
|
|
14
15
|
export const getRandomCharacter = (str) => str[getRandom(0, str.length - 1)];
|