1
0
Fork 0
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:
Casper Beyer 2020-08-31 04:46:58 +08:00 committed by GitHub
parent 0ea0c87b15
commit 39912f2018
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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",