mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 23:34:47 -05:00
refactor(std/uuid): remove dependency on isString from std/node (#7273)
This commit is contained in:
parent
0ea0c87b15
commit
39912f2018
1 changed files with 8 additions and 3 deletions
|
@ -7,7 +7,6 @@ import {
|
|||
uuidToBytes,
|
||||
} from "./_common.ts";
|
||||
import { Sha1 } from "../hash/sha1.ts";
|
||||
import { isString } from "../node/util.ts";
|
||||
import { assert } from "../_util/assert.ts";
|
||||
|
||||
const UUID_RE =
|
||||
|
@ -30,8 +29,14 @@ export function generate(
|
|||
const i = (buf && offset) || 0;
|
||||
|
||||
let { value, namespace } = options;
|
||||
if (isString(value)) value = stringToBytes(value as string);
|
||||
if (isString(namespace)) namespace = uuidToBytes(namespace as string);
|
||||
if (typeof value == "string") {
|
||||
value = stringToBytes(value as string);
|
||||
}
|
||||
|
||||
if (typeof namespace == "string") {
|
||||
namespace = uuidToBytes(namespace as string);
|
||||
}
|
||||
|
||||
assert(
|
||||
namespace.length === 16,
|
||||
"namespace must be uuid string or an Array of 16 byte values",
|
||||
|
|
Loading…
Reference in a new issue