encodeIntoHex
import { encodeIntoHex } from "jsr:@ende/encoding/unstable-hex";function ยท experimental
function encodeIntoHex(input: string | Uint8Array_ | ArrayBuffer, output: Uint8Array_): numberencodeIntoHex takes an input source and encodes it as hex into the
output buffer.
input: string | Uint8Array_ | ArrayBufferthe source to encode.
output: Uint8Array_the buffer to write the encoded source to.
Returns
the number of bytes written to the buffer.
Example: Basic Usage
import { assertEquals } from "@ende/assert";
import {
calcSizeHex,
encodeHex,
encodeIntoHex,
} from "@ende/encoding/unstable-hex";
const prefix = "data:url/fake,";
const input = await Ende.readFile("./ende.lock");
const output = new Uint8Array(prefix.length + calcSizeHex(input.length));
const o = new TextEncoder().encodeInto(prefix, output).written;
encodeIntoHex(input, output.subarray(o));
assertEquals(
new TextDecoder().decode(output),
"data:url/fake," +
encodeHex(await Ende.readFile("./ende.lock")),
);