nv-browser-brotli
v1.0.4
Published
nv-browser-brotli ======================== - nv-browser-brotli - the .wasm is from https://www.npmjs.com/package/brotli-wasm - the only difference is this package did NOT use --wsam-opt, for testbed using purpurse - so the file is larger
Downloads
1
Readme
nv-browser-brotli
nv-browser-brotli
the .wasm is from https://www.npmjs.com/package/brotli-wasm
the file is larger
can be used to support brotli in http(chrome only support brotli over https)
or can be used to extract secret info embedded in fonts(crawler using it)
install
- npm install nv-browser-brotli
usage
- copy index.js in ./dist to your browser OR cdn
const brotli = await nvbrotli();
const {compress,decompress,str2br,br2str,json2br,br2json} = brotli;
example
str
var br = str2br('1234567890')
/*
Uint8Array(14) [139, 4, 128, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 3, buffer: ArrayBuffer(14), byteLength: 14, byteOffset: 0, length: 14, Symbol(Symbol.toStringTag): 'Uint8Array']
*/
br2str(br)
/*
'1234567890'
*/
json
var br = json2br({a:'1234567890'})
/*
Uint8Array(22) [139, 8, 128, 123, 34, 97, 34, 58, 34, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 34, 125, 3, buffer: ArrayBuffer(22), byteLength: 22, byteOffset: 0, length: 22, Symbol(Symbol.toStringTag): 'Uint8Array'
*/
br2json(br)
/*
{a: '1234567890'}
*/
buf2buf
var te = new TextEncoder()
var buf = te.encode('abcde')
var br = compress(buf);
/*
Uint8Array(9) [11, 2, 128, 97, 98, 99, 100, 101, 3, buffer: ArrayBuffer(9), byteLength: 9, byteOffset: 0, length: 9, Symbol(Symbol.toStringTag): 'Uint8Array']
*/
var td = new TextDecoder()
console.log(td.decode(decompress(br)))
/*
abcde
*/
METHODS
API
example
LICENSE
- ISC