UNPKG

web-encoding

Version:

TextEncoder and TextDecoder APIs from Encoding Standard APIs in a universal package

18 lines (14 loc) 319 B
// @ts-check import { TextEncoder, TextDecoder } from "web-encoding" /** * @param {string} text * @returns {Uint8Array} */ export const encode = (text) => new TextEncoder().encode(text) /** * @param {Uint8Array} bytes * @returns {string} */ export const decode = (bytes) => new TextDecoder().decode(bytes)