kyr0 / brotli-compress

WASM based, asynchronous Brotli compression and decompression package that works in browsers and Node.js; CommonJS and ESM
Apache License 2.0
18 stars 1 forks source link

TypeScript error #3

Open thdoan opened 8 months ago

thdoan commented 8 months ago

Given this code:

const oneBlockInput = 'Hello🤖!'
const compressed = await compress(oneBlockInput)

I'm getting this TypeScript error: Argument of type 'string' is not assignable to parameter of type 'Uint8Array'.

thdoan commented 8 months ago

I managed to fixed the error. Please update documentation to this:

const textEncoder = new TextEncoder();
const oneBlockInput = 'Hello🤖!'

// it takes a Uint8Array and returns a Uint8Array
const compressed = await compress(textEncoder.encode(oneBlockInput))