@augment-vir/common 29.1.10 → 29.3.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/dist/cjs/augments/random.js +0 -5
- package/dist/cjs/augments/string/uuid.js +6 -0
- package/dist/esm/augments/random.js +0 -4
- package/dist/esm/augments/string/uuid.js +5 -0
- package/dist/types/augments/random.d.ts +0 -2
- package/dist/types/augments/string/uuid.d.ts +4 -0
- package/dist/types/augments/type.d.ts +1 -0
- package/package.json +1 -1
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.randomInteger = randomInteger;
|
|
4
4
|
exports.randomBoolean = randomBoolean;
|
|
5
|
-
exports.createUuid = createUuid;
|
|
6
5
|
exports.randomString = randomString;
|
|
7
6
|
const common_number_1 = require("./common-number");
|
|
8
7
|
function accessCrypto() {
|
|
@@ -63,10 +62,6 @@ function randomBoolean(percentLikelyToBeTrue = 50) {
|
|
|
63
62
|
max: 100,
|
|
64
63
|
}));
|
|
65
64
|
}
|
|
66
|
-
/** Creates a cryptographically secure uuid. */
|
|
67
|
-
function createUuid() {
|
|
68
|
-
return crypto.randomUUID();
|
|
69
|
-
}
|
|
70
65
|
const validStringCharacters = [
|
|
71
66
|
'a',
|
|
72
67
|
'b',
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isUuid = isUuid;
|
|
4
|
+
exports.createUuid = createUuid;
|
|
4
5
|
const uuidRegExp = /[\d\w]{8}-[\d\w]{4}-[\d\w]{4}-[\d\w]{4}-[\d\w]{12}/;
|
|
6
|
+
/** Checks if the input string is a valid v4 UUID. */
|
|
5
7
|
function isUuid(maybeUuid) {
|
|
6
8
|
return !!maybeUuid.match(uuidRegExp);
|
|
7
9
|
}
|
|
10
|
+
/** Creates a cryptographically secure v4 UUID using `crypto.randomUUID`. */
|
|
11
|
+
function createUuid() {
|
|
12
|
+
return crypto.randomUUID();
|
|
13
|
+
}
|
|
@@ -57,10 +57,6 @@ export function randomBoolean(percentLikelyToBeTrue = 50) {
|
|
|
57
57
|
max: 100,
|
|
58
58
|
}));
|
|
59
59
|
}
|
|
60
|
-
/** Creates a cryptographically secure uuid. */
|
|
61
|
-
export function createUuid() {
|
|
62
|
-
return crypto.randomUUID();
|
|
63
|
-
}
|
|
64
60
|
const validStringCharacters = [
|
|
65
61
|
'a',
|
|
66
62
|
'b',
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
const uuidRegExp = /[\d\w]{8}-[\d\w]{4}-[\d\w]{4}-[\d\w]{4}-[\d\w]{12}/;
|
|
2
|
+
/** Checks if the input string is a valid v4 UUID. */
|
|
2
3
|
export function isUuid(maybeUuid) {
|
|
3
4
|
return !!maybeUuid.match(uuidRegExp);
|
|
4
5
|
}
|
|
6
|
+
/** Creates a cryptographically secure v4 UUID using `crypto.randomUUID`. */
|
|
7
|
+
export function createUuid() {
|
|
8
|
+
return crypto.randomUUID();
|
|
9
|
+
}
|
|
@@ -29,8 +29,6 @@ export declare function randomInteger({ min: rawMin, max: rawMax }: {
|
|
|
29
29
|
* randomBoolean(59.67; // 59% chance of being true
|
|
30
30
|
*/
|
|
31
31
|
export declare function randomBoolean(percentLikelyToBeTrue?: number): boolean;
|
|
32
|
-
/** Creates a cryptographically secure uuid. */
|
|
33
|
-
export declare function createUuid(): `${string}-${string}-${string}-${string}-${string}`;
|
|
34
32
|
/**
|
|
35
33
|
* Creates a random string (including letters and numbers) of a given length.
|
|
36
34
|
*
|
|
@@ -1 +1,5 @@
|
|
|
1
|
+
export type UuidV4 = ReturnType<typeof createUuid>;
|
|
2
|
+
/** Checks if the input string is a valid v4 UUID. */
|
|
1
3
|
export declare function isUuid(maybeUuid: string): boolean;
|
|
4
|
+
/** Creates a cryptographically secure v4 UUID using `crypto.randomUUID`. */
|
|
5
|
+
export declare function createUuid(): `${string}-${string}-${string}-${string}-${string}`;
|