Skip to content

Commit

Permalink
empty
Browse files Browse the repository at this point in the history
  • Loading branch information
samthor committed Aug 30, 2022
1 parent b344268 commit 8d283dd
Showing 1 changed file with 5 additions and 31 deletions.
36 changes: 5 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ This is a fast polyfill for [`TextEncoder`][1] and [`TextDecoder`][2], which let
It is fast partially as it does not support^ any encodings aside UTF-8 (and note that natively, only `TextDecoder` supports alternative encodings anyway).
See [some benchmarks](https://github.com/samthor/fast-text-encoding/tree/master/bench).

<small>

^If this polyfill used on Node v5.1 through v11 (when `Text...` was introduced), then this simply wraps `Buffer`, which supports many encodings and is native code.

</small>

[1]: https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder
[2]: https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder

Expand All @@ -22,7 +18,7 @@ You only need this polyfill if you're supporting older browsers like IE, legacy

## Browser

Include the minified code inside a `script` tag or as an ES6 Module for its side effects.
Include the minified code inside a `<script>` tag or as an ES6 Module for its side effects.
It will create `TextEncoder` and `TextDecoder` if the symbols are missing on `window` or `global.`

```html
Expand All @@ -34,31 +30,9 @@ It will create `TextEncoder` and `TextDecoder` if the symbols are missing on `wi
</script>
```

⚠️ You'll probably want to depend on `text.min.js`, as it's compiled to ES5 for older environments.

## Node

You only need this polyfill in Node before v11.
However, you can use `Buffer` to provide the same functionality (but not conforming to any spec) in versions even older than that.

```js
require('fast-text-encoding'); // just require me before use

const buffer = new TextEncoder().encode('Turn me into UTF-8!');
// buffer is now a Uint8Array of [84, 117, 114, 110, ...]
```

In Node v5.1 and above, this polyfill uses `Buffer` to implement `TextDecoder`.

# Release
⚠️ You'll probably want to depend on "text.min.js", as it's compiled to ES5 for older environments.

Compile code with [Closure Compiler](https://closure-compiler.appspot.com/home).
## Not Including Polyfill

```
// ==ClosureCompiler==
// @compilation_level ADVANCED_OPTIMIZATIONS
// @output_file_name text.min.js
// ==/ClosureCompiler==
// code here
```
If your project doesn't need the polyfill, but is included as a transitive dependency, we publish [an empty version](https://www.npmjs.com/package/fast-text-encoding/v/0.0.0-empty) that you could pin NPM or similar's version algorithm to.
Use "fast-text-encoding@empty".

0 comments on commit 8d283dd

Please sign in to comment.