JSPM

brotli-js

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1212
  • Score
    100M100P100Q103113F
  • License MIT

compressor and decompressor for Brotli

Package Exports

  • brotli-js
  • brotli-js/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (brotli-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

brotli-js

compressor and decompressor for Brotli in Javascript, retrofit based on this repo, supporting node and browser

Installation and usage

npm i brotli-js -S
const brotli = require('brotli-js')

const str = 'test txt'
const buf = new ArrayBuffer(str.length)
const bufView = new Uint8Array(buf)

for (let i = 0, strLen = str.length; i < strLen; i++) {
  bufView[i] = str.charCodeAt(i)
}

const compressed = brotli.compressArray(bufView, 6)
const decompressed = brotli.decompressArray(compressed)
const restoredStr = String.fromCharCode.apply(null, decompressed)

API

brotli.compressArray(buffer, level)

Decompresses the given buffer to produce the original input to the compressor. The level parameter accept 0 - 11

brotli.compressArray(bufView, 6)

brotli.decompressArray(buffer)

Compresses the given buffer.

brotli.decompressArray(compressedData)