brotli-wasm
Advanced tools
Comparing version 3.0.0 to 3.0.1
// In pure ESM web bundles, you must call init() and wait for the promised result before you can | ||
// call any module methods. To make that as easy as possible, this module directly exposes the | ||
// init() promise result, and returns the methods at the end of the promise. | ||
import init, * as brotliWasm from "./pkg.web/brotli_wasm"; | ||
// https://github.com/WICG/import-maps?tab=readme-ov-file#extension-less-imports | ||
// For usage with an importmap, it's convenient to add the ".js" extension here, because browsers | ||
// don't try to guess the file extension. | ||
import init, * as brotliWasm from "./pkg.web/brotli_wasm.js"; | ||
export default init().then(() => brotliWasm); |
{ | ||
"name": "brotli-wasm", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "A reliable compressor and decompressor for Brotli, supporting node & browsers via wasm", | ||
@@ -5,0 +5,0 @@ "types": "./index.d.ts", |
@@ -66,3 +66,3 @@ # brotli-wasm [![Build Status](https://github.com/httptoolkit/brotli-wasm/workflows/CI/badge.svg)](https://github.com/httptoolkit/brotli-wasm/actions) [![Available on NPM](https://img.shields.io/npm/v/brotli-wasm.svg)](https://npmjs.com/package/brotli-wasm) | ||
```javascript | ||
let brotli = await import("https://unpkg.com/brotli-wasm@1.3.1/index.web.js?module").then(m => m.default); | ||
const brotli = await import("https://unpkg.com/brotli-wasm@3.0.0/index.web.js?module").then(m => m.default); | ||
``` | ||
@@ -72,2 +72,36 @@ | ||
##### Using an importmap | ||
If you've installed `brotli-wasm` as an NPM package, you can load it from your `node_modules` subfolder: | ||
```html | ||
<!-- index.html --> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head></head> | ||
<body> | ||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"brotli-wasm": "/node_modules/brotli-wasm/index.web.js" | ||
} | ||
} | ||
</script> | ||
<script type="module" src="/main.js"></script> | ||
</body> | ||
</html> | ||
``` | ||
```javascript | ||
// main.js | ||
import brotliPromise from 'brotli-wasm'; | ||
const brotli = await brotliPromise; | ||
const input = 'some input'; | ||
const uncompressedData = new TextEncoder().encode(input); | ||
const compressedData = brotli.compress(uncompressedData); | ||
const decompressedData = brotli.decompress(compressedData); | ||
console.log(new TextDecoder().decode(decompressedData)); // Prints 'some input' | ||
``` | ||
#### In browser with streams: | ||
@@ -74,0 +108,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3248275
1625
222