diff options
Diffstat (limited to 'std/uuid')
-rw-r--r-- | std/uuid/v1.ts | 12 | ||||
-rw-r--r-- | std/uuid/v4.ts | 2 | ||||
-rw-r--r-- | std/uuid/v5.ts | 7 |
3 files changed, 11 insertions, 10 deletions
diff --git a/std/uuid/v1.ts b/std/uuid/v1.ts index cbfce576a..6e48fa55f 100644 --- a/std/uuid/v1.ts +++ b/std/uuid/v1.ts @@ -4,7 +4,7 @@ import { bytesToUuid } from "./_common.ts"; const UUID_RE = new RegExp( "^[0-9a-f]{8}-[0-9a-f]{4}-1[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$", - "i" + "i", ); export function validate(id: string): boolean { @@ -29,7 +29,7 @@ type V1Options = { export function generate( options?: V1Options | null, buf?: number[], - offset?: number + offset?: number, ): string | number[] { let i = (buf && offset) || 0; const b = buf || []; @@ -40,8 +40,7 @@ export function generate( if (node == null || clockseq == null) { // eslint-disable-next-line @typescript-eslint/no-explicit-any - const seedBytes: any = - options.random || + const seedBytes: any = options.random || options.rng || crypto.getRandomValues(new Uint8Array(16)); if (node == null) { @@ -58,8 +57,9 @@ export function generate( clockseq = _clockseq = ((seedBytes[6] << 8) | seedBytes[7]) & 0x3fff; } } - let msecs = - options.msecs !== undefined ? options.msecs : new Date().getTime(); + let msecs = options.msecs !== undefined + ? options.msecs + : new Date().getTime(); let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; diff --git a/std/uuid/v4.ts b/std/uuid/v4.ts index 83fc6d86e..53fbc92e3 100644 --- a/std/uuid/v4.ts +++ b/std/uuid/v4.ts @@ -4,7 +4,7 @@ import { bytesToUuid } from "./_common.ts"; const UUID_RE = new RegExp( "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$", - "i" + "i", ); export function validate(id: string): boolean { diff --git a/std/uuid/v5.ts b/std/uuid/v5.ts index f982d9745..6375e7bab 100644 --- a/std/uuid/v5.ts +++ b/std/uuid/v5.ts @@ -10,7 +10,8 @@ import { Sha1 } from "../hash/sha1.ts"; import { isString } from "../node/util.ts"; import { assert } from "../_util/assert.ts"; -const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i; +const UUID_RE = + /^[0-9a-f]{8}-[0-9a-f]{4}-[5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i; export function validate(id: string): boolean { return UUID_RE.test(id); @@ -24,7 +25,7 @@ interface V5Options { export function generate( options: V5Options, buf?: number[], - offset?: number + offset?: number, ): string | number[] { const i = (buf && offset) || 0; @@ -33,7 +34,7 @@ export function generate( if (isString(namespace)) namespace = uuidToBytes(namespace as string); assert( namespace.length === 16, - "namespace must be uuid string or an Array of 16 byte values" + "namespace must be uuid string or an Array of 16 byte values", ); const content = (namespace as number[]).concat(value as number[]); |