Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/esm/bytes.js>text

A JavaScript extension package for building strong and modern applications.
Latest
function text
import { text } from "https://deno.land/x/ayonli_jsext@v0.9.72/esm/bytes.js";

Converts the byte array (or Uint8Array) to a string.

Examples

Example 1

import { text } from "@ayonli/jsext/bytes";

const arr = new Uint8Array([72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]);

console.log(text(arr)); // "Hello, World!"
console.log(text(arr, "hex")); // "48656c6c6f2c20576f726c6421"
console.log(text(arr, "base64")); // "SGVsbG8sIFdvcmxkIQ=="

Parameters

bytes

Default value: utf8.

optional
encoding = [UNSUPPORTED]