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

Function validateBinaryLike

encoding/_validate_binary_like.ts:16–29  ·  view source on GitHub ↗
(source: unknown)

Source from the content-addressed store, hash-verified

14}
15
16export function validateBinaryLike(source: unknown): Uint8Array {
17 if (typeof source === "string") {
18 return encoder.encode(source);
19 } else if (source instanceof Uint8Array) {
20 return source;
21 } else if (source instanceof ArrayBuffer) {
22 return new Uint8Array(source);
23 }
24 throw new TypeError(
25 `Cannot validate the input as it must be a Uint8Array, a string, or an ArrayBuffer: received a value of the type ${
26 getTypeName(source)
27 }`,
28 );
29}

Callers 3

encodeBase58Function · 0.90
encodeAscii85Function · 0.90

Calls 1

getTypeNameFunction · 0.85

Tested by

no test coverage detected