Skip to content

An isomorphic TextEncoder for Javascript in Node and the browser

License

Notifications You must be signed in to change notification settings

TopGunBuild/textencoder

Repository files navigation

✨ @topgunbuild/textencoder

An isomorphic TextEncoder for Javascript in Node and the browser, used in TopGun

npm bundlephobia License: MIT

What?

Encode/decode Uint8Arrays to strings.

This is just a thin wrapper that provides an isomorphic API.

  • To perform UTF8 conversion in the browser it uses the native TextEncoder.
  • In Node it uses Buffer and Uint8Array.

Install

npm install @topgunbuild/textencoder

Usage

const textencoder = require('@topgunbuild/textencoder')
// or
import textencoder from '@topgunbuild/textencoder';

textencoder.encode('Hello') // Uint8Array [ 72, 101, 108, 108, 111 ]

License

MIT