Common interface for TextEncoder & TextDecoder. In node uses util module. In browser uses classes from global scope and shim if they are not available. Typings included.
import {TextEncoder, TextDecoder} from "text-coder";
let text = "Some text";
let te = new TextEncoder();
let array = te.encode(text);
let td = new TextDecoder();
let res = td.decode(array);
console.log(text == res, text, array, res);
The MIT License (MIT)