MCPcopy Create free account
hub / github.com/denoland/std / encodeHex

Function encodeHex

encoding/unstable_hex.ts:60–74  ·  view source on GitHub ↗
(
  input: string | Uint8Array_ | ArrayBuffer,
)

Source from the content-addressed store, hash-verified

58 * ```
59 */
60export function encodeHex(
61 input: string | Uint8Array_ | ArrayBuffer,
62): string {
63 if (typeof input === "string") {
64 input = new TextEncoder().encode(input) as Uint8Array_;
65 } else if (input instanceof ArrayBuffer) {
66 input = new Uint8Array(input);
67 }
68 const [output, i] = detach(
69 input as Uint8Array_,
70 calcSizeHex((input as Uint8Array_).length),
71 );
72 encode(output, i, 0, alphabet);
73 return new TextDecoder().decode(output);
74}
75
76/**
77 * `encodeIntoHex` takes an input source and encodes it as hex into the

Callers

nothing calls this directly

Calls 3

detachFunction · 0.90
calcSizeHexFunction · 0.90
encodeFunction · 0.90

Tested by

no test coverage detected