import { default } from "https://deno.land/x/ayonli_jsext@v0.9.72/uint8array/index.ts";
Converts the given data to a byte array.
Examples
Example 1
Example 1
import bytes from "@ayonli/jsext/bytes";
const arr = bytes("Hello, World!");
console.log(arr);
// ByteArray(13) [Uint8Array] [ 72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33 ]
console.log(String(arr)); // "Hello, World!"
// from hex
const arr2 = bytes("48656c6c6f2c20576f726c6421", "hex");
// from base64
const arr3 = bytes("SGVsbG8sIFdvcmxkIQ==", "base64");
Creates a byte array with the specified length.
Examples
Example 1
Example 1
import bytes from "@ayonli/jsext/bytes";
const arr = bytes(10);
console.log(arr);
// ByteArray(10) [Uint8Array] [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]