forked from samthor/fast-text-encoding
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
This is a fast polyfill for `[TextEncoder][1]` and `TextDecoder[2]`. | ||
|
||
It is fast partially as it does not support any encodings aside UTF-8 (and note that natively, only `TextDecoder` supports alternative encodings). | ||
|
||
[1]: https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder | ||
[2]: https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder | ||
|
||
# Usage | ||
|
||
Include the minified 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`. | ||
|
||
```html | ||
<script src="node_modules/fast-text-encoding/text.min.js"></script> | ||
<script type="module"> | ||
import './node_modules/fast-text-encoding/text.min.js'; | ||
// do something with TextEncoder | ||
</script> | ||
|
||
**Note**: Always include `text.min.js`, as it's compiled to ES5 for older environments. | ||
|
||
## Node | ||
|
||
Install via NPM or Yarn: | ||
|
||
```bash | ||
yarn add fast-text-encoding | ||
``` | ||
|
||
And then import purely for side effects: | ||
|
||
```js | ||
require('fast-text-encoding'); | ||
``` | ||
|
||
# Supports | ||
|
||
Built for IE11, Edge and Node environments. | ||
Not required for Chrome, Firefox etc, which have native implementations. | ||
|
||
# Release | ||
|
||
Compile code with [Closure Compiler](https://closure-compiler.appspot.com/home). | ||
|
||
``` | ||
// ==ClosureCompiler== | ||
// @compilation_level ADVANCED_OPTIMIZATIONS | ||
// @output_file_name text.min.js | ||
// ==/ClosureCompiler== | ||
// code here | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "fast-text-encoding", | ||
"version": "1.0.0", | ||
"description": "Fast polyfill for TextEncoder and TextDecoder, only supports utf-8 Edit", | ||
"main": "text.min.js", | ||
"repository": "[email protected]:samthor/text.git", | ||
"author": "Sam Thorogood <[email protected]>", | ||
"license": "Apache-2" | ||
} |