You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+5-31Lines changed: 5 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,12 +5,8 @@ This is a fast polyfill for [`TextEncoder`][1] and [`TextDecoder`][2], which let
5
5
It is fast partially as it does not support^ any encodings aside UTF-8 (and note that natively, only `TextDecoder` supports alternative encodings anyway).
6
6
See [some benchmarks](https://github.com/samthor/fast-text-encoding/tree/master/bench).
7
7
8
-
<small>
9
-
10
8
^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.
@@ -22,7 +18,7 @@ You only need this polyfill if you're supporting older browsers like IE, legacy
22
18
23
19
## Browser
24
20
25
-
Include the minified code inside a `script` tag or as an ES6 Module for its side effects.
21
+
Include the minified code inside a `<script>` tag or as an ES6 Module for its side effects.
26
22
It will create `TextEncoder` and `TextDecoder` if the symbols are missing on `window` or `global.`
27
23
28
24
```html
@@ -34,31 +30,9 @@ It will create `TextEncoder` and `TextDecoder` if the symbols are missing on `wi
34
30
</script>
35
31
```
36
32
37
-
⚠️ You'll probably want to depend on `text.min.js`, as it's compiled to ES5 for older environments.
38
-
39
-
## Node
40
-
41
-
You only need this polyfill in Node before v11.
42
-
However, you can use `Buffer` to provide the same functionality (but not conforming to any spec) in versions even older than that.
43
-
44
-
```js
45
-
require('fast-text-encoding'); // just require me before use
46
-
47
-
constbuffer=newTextEncoder().encode('Turn me into UTF-8!');
48
-
// buffer is now a Uint8Array of [84, 117, 114, 110, ...]
49
-
```
50
-
51
-
In Node v5.1 and above, this polyfill uses `Buffer` to implement `TextDecoder`.
52
-
53
-
# Release
33
+
⚠️ You'll probably want to depend on "text.min.js", as it's compiled to ES5 for older environments.
54
34
55
-
Compile code with [Closure Compiler](https://closure-compiler.appspot.com/home).
35
+
## Not Including Polyfill
56
36
57
-
```
58
-
// ==ClosureCompiler==
59
-
// @compilation_level ADVANCED_OPTIMIZATIONS
60
-
// @output_file_name text.min.js
61
-
// ==/ClosureCompiler==
62
-
63
-
// code here
64
-
```
37
+
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.
0 commit comments