zlib#brotliDecompress TypeScript Examples
The following examples show how to use
zlib#brotliDecompress.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: mmdb.ts From posthog-foss with MIT License | 6 votes |
/** Decompress a Brotli-compressed MMDB buffer and open a reader from it. */
async function decompressAndOpenMmdb(brotliContents: Buffer, filename: string): Promise<ReaderModel> {
return await new Promise((resolve, reject) => {
brotliDecompress(brotliContents, (error, result) => {
if (error) {
reject(error)
} else {
status.info(
'?',
`Decompressed ${filename} from ${prettyBytes(brotliContents.byteLength)} into ${prettyBytes(
result.byteLength
)}`
)
try {
resolve(Reader.openBuffer(result))
} catch (e) {
reject(e)
}
}
})
})
}