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
console.log(textDecoder.decode(decompressedData)) // Prints 'some input'
63
-
// console.log(Buffer.from(decompressedData).toString('utf8')); // Prints 'some input' with Buffer polyfill
61
+
console.log(textDecoder.decode(decompressedData)); // Prints 'some input'
64
62
```
65
63
66
-
The package itself has no runtime dependencies, you will need [browser Buffer polyfill](https://www.npmjs.com/package/browserify-zlib) if you prefer using `Buffer` over using `TextEncoder/TextDecoder`.
64
+
The package itself has no runtime dependencies, although if you prefer using `Buffer` over using `TextEncoder/TextDecoder` you may want a [browser Buffer polyfill](https://www.npmjs.com/package/browserify-zlib).
67
65
68
66
#### In browser with streams:
69
-
```
70
-
import brotliPromise from 'brotli-wasm' // Import the default export
71
67
72
-
const brotli = await brotliPromise // Import is async in browsers due to wasm requirements!
68
+
```javascript
69
+
importbrotliPromisefrom'brotli-wasm'; // Import the default export
73
70
74
-
const input = 'some input'
71
+
constbrotli=await brotliPromise; // Import is async in browsers due to wasm requirements!
72
+
73
+
constinput='some input';
75
74
76
75
constinputStream=newReadableStream({
77
-
start (controller) {
78
-
controller.enqueue(input)
79
-
controller.close()
80
-
}
81
-
})
82
-
const textEncoderStream = new TextEncoderStream()
83
-
const compressStream = new brotli.CompressStream()
0 commit comments