diff options
author | aakhtar3 <aakhtar3@users.noreply.github.com> | 2020-10-01 05:40:40 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-01 11:40:40 +0200 |
commit | da29ccece5e357b893ce9a5cf145fd6e939c1fb5 (patch) | |
tree | 6216d4ab8da666ae7539c1899d4c55de320a67d0 /std/uuid/_common.ts | |
parent | 326ccb1095adeb9b8c86d42cc9d9d8566bba2788 (diff) |
docs(std/uuid): Added JSdocs for the std/uuid module (#7735)
Diffstat (limited to 'std/uuid/_common.ts')
-rw-r--r-- | std/uuid/_common.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/std/uuid/_common.ts b/std/uuid/_common.ts index 8f13ac7e3..ef0bb42be 100644 --- a/std/uuid/_common.ts +++ b/std/uuid/_common.ts @@ -1,4 +1,8 @@ // Copyright 2018-2020 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); @@ -17,6 +21,10 @@ export function bytesToUuid(bytes: number[] | Uint8Array): string { ].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[] = []; @@ -28,6 +36,10 @@ export function uuidToBytes(uuid: string): number[] { 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); @@ -37,6 +49,10 @@ export function stringToBytes(str: string): number[] { 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); |