diff options
author | Casper Beyer <caspervonb@pm.me> | 2021-02-02 19:05:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-02 12:05:46 +0100 |
commit | 6abf126c2a7a451cded8c6b5e6ddf1b69c84055d (patch) | |
tree | fd94c013a19fcb38954844085821ec1601c20e18 /std/uuid/_common.ts | |
parent | a2b5d44f1aa9d64f448a2a3cc2001272e2f60b98 (diff) |
chore: remove std directory (#9361)
This removes the std folder from the tree.
Various parts of the tests are pretty tightly dependent
on std (47 direct imports and 75 indirect imports, not
counting the cli tests that use them as fixtures) so I've
added std as a submodule for now.
Diffstat (limited to 'std/uuid/_common.ts')
-rw-r--r-- | std/uuid/_common.ts | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/std/uuid/_common.ts b/std/uuid/_common.ts deleted file mode 100644 index 1f3228aea..000000000 --- a/std/uuid/_common.ts +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -/** - * Converts the byte array to a UUID string - * @param bytes Used to convert Byte to Hex - */ -export function bytesToUuid(bytes: number[] | Uint8Array): string { - const bits: string[] = [...bytes].map((bit): string => { - const s: string = bit.toString(16); - return bit < 0x10 ? "0" + s : s; - }); - return [ - ...bits.slice(0, 4), - "-", - ...bits.slice(4, 6), - "-", - ...bits.slice(6, 8), - "-", - ...bits.slice(8, 10), - "-", - ...bits.slice(10, 16), - ].join(""); -} - -/** - * Converts a string to a byte array by converting the hex value to a number - * @param uuid Value that gets converted - */ -export function uuidToBytes(uuid: string): number[] { - const bytes: number[] = []; - - uuid.replace(/[a-fA-F0-9]{2}/g, (hex: string): string => { - bytes.push(parseInt(hex, 16)); - return ""; - }); - - return bytes; -} - -/** - * Converts a string to a byte array using the char code - * @param str Value that gets converted - */ -export function stringToBytes(str: string): number[] { - str = unescape(encodeURIComponent(str)); - const bytes = new Array(str.length); - for (let i = 0; i < str.length; i++) { - bytes[i] = str.charCodeAt(i); - } - return bytes; -} - -/** - * Creates a buffer for creating a SHA-1 hash - * @param content Buffer for SHA-1 hash - */ -export function createBuffer(content: number[]): ArrayBuffer { - const arrayBuffer = new ArrayBuffer(content.length); - const uint8Array = new Uint8Array(arrayBuffer); - for (let i = 0; i < content.length; i++) { - uint8Array[i] = content[i]; - } - return arrayBuffer; -} |