# text-encoder-lite

> A Lite Polyfill for the Encoding Living Standard's API.

Latest version **2.0.0** (published 2019-07-02) · 0 weekly downloads

## Install

```sh
npm install text-encoder-lite
pnpm add text-encoder-lite
yarn add text-encoder-lite
bun add text-encoder-lite
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2019-07-02 |
| First published | 2015-06-13 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 19.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 31 |
| Author | AJ ONeal |
| Maintainers | coolaj86 |
| Keywords | utf8, utf-8, TypedArray, Uint8Array, encoding, decoding, living standard |

## Links

- npm: https://www.npmjs.com/package/text-encoder-lite
- Repository: https://github.com/solderjs/TextEncoderLite
- Issues: https://github.com/solderjs/TextEncoderLite/issues
- npm.io page: https://npm.io/package/text-encoder-lite

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2019-07-02
- 1.0.1 — 2017-10-12
- 1.0.0 — 2015-06-13

## README

TextEncoderLite
==============

Extracted from [Feross' Buffer](https://github.com/feross/buffer) as a lightweight Polyfill
for TextEncoder.

See also
  * [TextEncoder](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder/encode) / [TextDecoder](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder/decode)
  * [DateView](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)
  * [text-encoding](https://github.com/inexorabletash/text-encoding)
  * [Unibabel](https://github.com/coolaj86/unibabel-js)
  * [TextEncoderLite (based on text-encoding)](https://github.com/coolaj86/TextEncoderLite/tree/lite)

### Install ###

There are a few ways you can get the `text-encoder-lite` library.

#### Node ####

`text-encoder-lite` is on `npm`. Simply run:

```js
npm install text-encoder-lite
```

Or add it to your `package.json` dependencies.

You can use it as follows:

```js
var TextDecoder = require('text-encoder-lite').TextDecoderLite;
var TextEncoder = require('text-encoder-lite').TextEncoderLite;
```

#### Bower ####

`text-encoder-lite` is on `bower` as well. Install with bower like so:

```js
bower install text-encoder-lite
```

Or add it to your `bower.json` dependencies.

### HTML Page Usage ###

```html
  <!-- Required for non-UTF encodings -->
  <script src="bower_components/text-encoder-lite/text-encoder-lite.js"></script>
```

And in your scripts:

```js
var TextDecoder = window.TextDecoderLite;
var TextEncoder = window.TextEncoderLite;
```

### API Overview ###

Basic Usage

```js
  var uint8array = new TextEncoderLite('utf-8').encode(string);
  var string = new TextDecoderLite('utf-8').decode(uint8array);
```

### Encodings ###

Only UTF-8 encoding is supported.
See [text-encoding](https://github.com/inexorabletash/text-encoding) for full support,
including multi-lingual non-standard encodings that aren't supported by TextEncoder proper.

If it seems beneficial I could bring in support for utf-16be, utf-16le, and x-user-defined.

---
_Source: https://npm.io/package/text-encoder-lite · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
