brotli-compress icon indicating copy to clipboard operation
brotli-compress copied to clipboard

TypeScript error

Open thdoan opened this issue 1 year ago • 1 comments

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 avatar Feb 26 '24 02:02 thdoan

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))

thdoan avatar Feb 26 '24 02:02 thdoan