From 39912f201836e945a66583f62bfcae72655382f1 Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Mon, 31 Aug 2020 04:46:58 +0800 Subject: [PATCH] refactor(std/uuid): remove dependency on isString from std/node (#7273) --- std/uuid/v5.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/std/uuid/v5.ts b/std/uuid/v5.ts index 6375e7bab0..e940f0c68f 100644 --- a/std/uuid/v5.ts +++ b/std/uuid/v5.ts @@ -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",