mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17: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,
|
uuidToBytes,
|
||||||
} from "./_common.ts";
|
} from "./_common.ts";
|
||||||
import { Sha1 } from "../hash/sha1.ts";
|
import { Sha1 } from "../hash/sha1.ts";
|
||||||
import { isString } from "../node/util.ts";
|
|
||||||
import { assert } from "../_util/assert.ts";
|
import { assert } from "../_util/assert.ts";
|
||||||
|
|
||||||
const UUID_RE =
|
const UUID_RE =
|
||||||
|
@ -30,8 +29,14 @@ export function generate(
|
||||||
const i = (buf && offset) || 0;
|
const i = (buf && offset) || 0;
|
||||||
|
|
||||||
let { value, namespace } = options;
|
let { value, namespace } = options;
|
||||||
if (isString(value)) value = stringToBytes(value as string);
|
if (typeof value == "string") {
|
||||||
if (isString(namespace)) namespace = uuidToBytes(namespace as string);
|
value = stringToBytes(value as string);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof namespace == "string") {
|
||||||
|
namespace = uuidToBytes(namespace as string);
|
||||||
|
}
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
namespace.length === 16,
|
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",
|
||||||
|
|
Loading…
Add table
Reference in a new issue