Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

brotli-wasm

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

brotli-wasm - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

2

package.json
{
"name": "brotli-wasm",
"version": "1.1.1",
"version": "1.2.0",
"description": "A reliable compressor and decompressor for Brotli, supporting node & browsers via wasm",

@@ -5,0 +5,0 @@ "main": "./pkg.node/brotli_wasm.js",

@@ -9,8 +9,4 @@ import * as wasm from './brotli_wasm_bg.wasm';

const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
let WASM_VECTOR_LEN = 0;
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
let cachegetUint8Memory0 = null;

@@ -24,19 +20,2 @@ function getUint8Memory0() {

function getStringFromWasm0(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
let heap_next = heap.length;
function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx];
heap[idx] = obj;
return idx;
}
let WASM_VECTOR_LEN = 0;
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;

@@ -105,2 +84,23 @@

const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
function getStringFromWasm0(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
let heap_next = heap.length;
function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx];
heap[idx] = obj;
return idx;
}
function dropObject(idx) {

@@ -188,2 +188,176 @@ if (idx < 36) return;

function isLikeNone(x) {
return x === undefined || x === null;
}
/**
*/
export const BrotliStreamResult = Object.freeze({
/**
* The stream is just initialized and no input is provided currently.
* `BrotliResult` uses `ResultFailure = 0`, but as we will convert `ResultFailure` to a negative actual error code,
* 0 is reused as no input currently.
* As for Brotli compressing, since offical API does not provide a way to retrieve a detailed error code, -1 is used.
*/
Init:0,"0":"Init",ResultSuccess:1,"1":"ResultSuccess",NeedsMoreInput:2,"2":"NeedsMoreInput",NeedsMoreOutput:3,"3":"NeedsMoreOutput", });
/**
*/
export class CompressStream {
static __wrap(ptr) {
const obj = Object.create(CompressStream.prototype);
obj.ptr = ptr;
return obj;
}
__destroy_into_raw() {
const ptr = this.ptr;
this.ptr = 0;
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_compressstream_free(ptr);
}
/**
* @param {number | undefined} quality
*/
constructor(quality) {
const ret = wasm.compressstream_new(!isLikeNone(quality), isLikeNone(quality) ? 0 : quality);
return CompressStream.__wrap(ret);
}
/**
* @param {Uint8Array | undefined} input_opt
* @param {number} output_size
* @returns {Uint8Array}
*/
compress(input_opt, output_size) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
var ptr0 = isLikeNone(input_opt) ? 0 : passArray8ToWasm0(input_opt, wasm.__wbindgen_malloc);
var len0 = WASM_VECTOR_LEN;
wasm.compressstream_compress(retptr, this.ptr, ptr0, len0, output_size);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var r2 = getInt32Memory0()[retptr / 4 + 2];
var r3 = getInt32Memory0()[retptr / 4 + 3];
if (r3) {
throw takeObject(r2);
}
var v1 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1);
return v1;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* @returns {number}
*/
total_out() {
const ret = wasm.compressstream_total_out(this.ptr);
return ret >>> 0;
}
/**
* @returns {number}
*/
result() {
const ret = wasm.compressstream_result(this.ptr);
return ret;
}
/**
* @returns {number}
*/
last_input_offset() {
const ret = wasm.compressstream_last_input_offset(this.ptr);
return ret >>> 0;
}
}
/**
*/
export class DecompressStream {
static __wrap(ptr) {
const obj = Object.create(DecompressStream.prototype);
obj.ptr = ptr;
return obj;
}
__destroy_into_raw() {
const ptr = this.ptr;
this.ptr = 0;
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_decompressstream_free(ptr);
}
/**
*/
constructor() {
const ret = wasm.decompressstream_new();
return DecompressStream.__wrap(ret);
}
/**
* @param {Uint8Array} input
* @param {number} output_size
* @returns {Uint8Array}
*/
decompress(input, output_size) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
wasm.decompressstream_decompress(retptr, this.ptr, ptr0, len0, output_size);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var r2 = getInt32Memory0()[retptr / 4 + 2];
var r3 = getInt32Memory0()[retptr / 4 + 3];
if (r3) {
throw takeObject(r2);
}
var v1 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1);
return v1;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* @returns {number}
*/
total_out() {
const ret = wasm.decompressstream_total_out(this.ptr);
return ret >>> 0;
}
/**
* @returns {number}
*/
result() {
const ret = wasm.decompressstream_result(this.ptr);
return ret;
}
/**
* @returns {number}
*/
last_input_offset() {
const ret = wasm.decompressstream_last_input_offset(this.ptr);
return ret >>> 0;
}
}
export function __wbindgen_json_serialize(arg0, arg1) {
const obj = getObject(arg1);
const ret = JSON.stringify(obj === undefined ? null : obj);
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len0;
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
};
export function __wbindgen_is_undefined(arg0) {

@@ -205,11 +379,2 @@ const ret = getObject(arg0) === undefined;

export function __wbindgen_json_serialize(arg0, arg1) {
const obj = getObject(arg1);
const ret = JSON.stringify(obj === undefined ? null : obj);
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len0;
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
};
export function __wbg_new_693216e109162396() {

@@ -240,1 +405,5 @@ const ret = new Error();

export function __wbindgen_throw(arg0, arg1) {
throw new Error(getStringFromWasm0(arg0, arg1));
};

@@ -6,2 +6,14 @@ /* tslint:disable */

export function decompress(a: number, b: number, c: number): void;
export function __wbg_compressstream_free(a: number): void;
export function compressstream_new(a: number, b: number): number;
export function compressstream_compress(a: number, b: number, c: number, d: number, e: number): void;
export function compressstream_total_out(a: number): number;
export function compressstream_result(a: number): number;
export function compressstream_last_input_offset(a: number): number;
export function __wbg_decompressstream_free(a: number): void;
export function decompressstream_new(): number;
export function decompressstream_decompress(a: number, b: number, c: number, d: number, e: number): void;
export function decompressstream_total_out(a: number): number;
export function decompressstream_result(a: number): number;
export function decompressstream_last_input_offset(a: number): number;
export function BrotliDecoderCreateInstance(a: number, b: number, c: number): number;

@@ -8,0 +20,0 @@ export function BrotliDecoderSetParameter(a: number, b: number, c: number): void;

@@ -8,2 +8,16 @@ /* tslint:disable */

export function decompress(buf: Uint8Array): Uint8Array;
/**
*/
export enum BrotliStreamResult {
/**
* The stream is just initialized and no input is provided currently.
* `BrotliResult` uses `ResultFailure = 0`, but as we will convert `ResultFailure` to a negative actual error code,
* 0 is reused as no input currently.
* As for Brotli compressing, since offical API does not provide a way to retrieve a detailed error code, -1 is used.
*/
Init,
ResultSuccess,
NeedsMoreInput,
NeedsMoreOutput,
}

@@ -18,1 +32,54 @@

/**
*/
export class CompressStream {
free(): void;
/**
* @param {number | undefined} quality
*/
constructor(quality?: number);
/**
* @param {Uint8Array | undefined} input_opt
* @param {number} output_size
* @returns {Uint8Array}
*/
compress(input_opt: Uint8Array | undefined, output_size: number): Uint8Array;
/**
* @returns {number}
*/
total_out(): number;
/**
* @returns {number}
*/
result(): number;
/**
* @returns {number}
*/
last_input_offset(): number;
}
/**
*/
export class DecompressStream {
free(): void;
/**
*/
constructor();
/**
* @param {Uint8Array} input
* @param {number} output_size
* @returns {Uint8Array}
*/
decompress(input: Uint8Array, output_size: number): Uint8Array;
/**
* @returns {number}
*/
total_out(): number;
/**
* @returns {number}
*/
result(): number;
/**
* @returns {number}
*/
last_input_offset(): number;
}

@@ -6,2 +6,14 @@ /* tslint:disable */

export function decompress(a: number, b: number, c: number): void;
export function __wbg_compressstream_free(a: number): void;
export function compressstream_new(a: number, b: number): number;
export function compressstream_compress(a: number, b: number, c: number, d: number, e: number): void;
export function compressstream_total_out(a: number): number;
export function compressstream_result(a: number): number;
export function compressstream_last_input_offset(a: number): number;
export function __wbg_decompressstream_free(a: number): void;
export function decompressstream_new(): number;
export function decompressstream_decompress(a: number, b: number, c: number, d: number, e: number): void;
export function decompressstream_total_out(a: number): number;
export function decompressstream_result(a: number): number;
export function decompressstream_last_input_offset(a: number): number;
export function BrotliDecoderCreateInstance(a: number, b: number, c: number): number;

@@ -8,0 +20,0 @@ export function BrotliDecoderSetParameter(a: number, b: number, c: number): void;

@@ -8,2 +8,16 @@ /* tslint:disable */

export function decompress(buf: Uint8Array): Uint8Array;
/**
*/
export enum BrotliStreamResult {
/**
* The stream is just initialized and no input is provided currently.
* `BrotliResult` uses `ResultFailure = 0`, but as we will convert `ResultFailure` to a negative actual error code,
* 0 is reused as no input currently.
* As for Brotli compressing, since offical API does not provide a way to retrieve a detailed error code, -1 is used.
*/
Init,
ResultSuccess,
NeedsMoreInput,
NeedsMoreOutput,
}

@@ -18,1 +32,54 @@

/**
*/
export class CompressStream {
free(): void;
/**
* @param {number | undefined} quality
*/
constructor(quality?: number);
/**
* @param {Uint8Array | undefined} input_opt
* @param {number} output_size
* @returns {Uint8Array}
*/
compress(input_opt: Uint8Array | undefined, output_size: number): Uint8Array;
/**
* @returns {number}
*/
total_out(): number;
/**
* @returns {number}
*/
result(): number;
/**
* @returns {number}
*/
last_input_offset(): number;
}
/**
*/
export class DecompressStream {
free(): void;
/**
*/
constructor();
/**
* @param {Uint8Array} input
* @param {number} output_size
* @returns {Uint8Array}
*/
decompress(input: Uint8Array, output_size: number): Uint8Array;
/**
* @returns {number}
*/
total_out(): number;
/**
* @returns {number}
*/
result(): number;
/**
* @returns {number}
*/
last_input_offset(): number;
}
let imports = {};
imports['__wbindgen_placeholder__'] = module.exports;
let wasm;
const { TextDecoder, TextEncoder } = require(`util`);
const { TextEncoder, TextDecoder } = require(`util`);

@@ -12,6 +12,4 @@ const heap = new Array(32).fill(undefined);

let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
let WASM_VECTOR_LEN = 0;
cachedTextDecoder.decode();
let cachegetUint8Memory0 = null;

@@ -25,19 +23,2 @@ function getUint8Memory0() {

function getStringFromWasm0(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
let heap_next = heap.length;
function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx];
heap[idx] = obj;
return idx;
}
let WASM_VECTOR_LEN = 0;
let cachedTextEncoder = new TextEncoder('utf-8');

@@ -104,2 +85,21 @@

let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
function getStringFromWasm0(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
let heap_next = heap.length;
function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx];
heap[idx] = obj;
return idx;
}
function dropObject(idx) {

@@ -187,2 +187,178 @@ if (idx < 36) return;

function isLikeNone(x) {
return x === undefined || x === null;
}
/**
*/
module.exports.BrotliStreamResult = Object.freeze({
/**
* The stream is just initialized and no input is provided currently.
* `BrotliResult` uses `ResultFailure = 0`, but as we will convert `ResultFailure` to a negative actual error code,
* 0 is reused as no input currently.
* As for Brotli compressing, since offical API does not provide a way to retrieve a detailed error code, -1 is used.
*/
Init:0,"0":"Init",ResultSuccess:1,"1":"ResultSuccess",NeedsMoreInput:2,"2":"NeedsMoreInput",NeedsMoreOutput:3,"3":"NeedsMoreOutput", });
/**
*/
class CompressStream {
static __wrap(ptr) {
const obj = Object.create(CompressStream.prototype);
obj.ptr = ptr;
return obj;
}
__destroy_into_raw() {
const ptr = this.ptr;
this.ptr = 0;
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_compressstream_free(ptr);
}
/**
* @param {number | undefined} quality
*/
constructor(quality) {
const ret = wasm.compressstream_new(!isLikeNone(quality), isLikeNone(quality) ? 0 : quality);
return CompressStream.__wrap(ret);
}
/**
* @param {Uint8Array | undefined} input_opt
* @param {number} output_size
* @returns {Uint8Array}
*/
compress(input_opt, output_size) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
var ptr0 = isLikeNone(input_opt) ? 0 : passArray8ToWasm0(input_opt, wasm.__wbindgen_malloc);
var len0 = WASM_VECTOR_LEN;
wasm.compressstream_compress(retptr, this.ptr, ptr0, len0, output_size);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var r2 = getInt32Memory0()[retptr / 4 + 2];
var r3 = getInt32Memory0()[retptr / 4 + 3];
if (r3) {
throw takeObject(r2);
}
var v1 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1);
return v1;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* @returns {number}
*/
total_out() {
const ret = wasm.compressstream_total_out(this.ptr);
return ret >>> 0;
}
/**
* @returns {number}
*/
result() {
const ret = wasm.compressstream_result(this.ptr);
return ret;
}
/**
* @returns {number}
*/
last_input_offset() {
const ret = wasm.compressstream_last_input_offset(this.ptr);
return ret >>> 0;
}
}
module.exports.CompressStream = CompressStream;
/**
*/
class DecompressStream {
static __wrap(ptr) {
const obj = Object.create(DecompressStream.prototype);
obj.ptr = ptr;
return obj;
}
__destroy_into_raw() {
const ptr = this.ptr;
this.ptr = 0;
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_decompressstream_free(ptr);
}
/**
*/
constructor() {
const ret = wasm.decompressstream_new();
return DecompressStream.__wrap(ret);
}
/**
* @param {Uint8Array} input
* @param {number} output_size
* @returns {Uint8Array}
*/
decompress(input, output_size) {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_malloc);
const len0 = WASM_VECTOR_LEN;
wasm.decompressstream_decompress(retptr, this.ptr, ptr0, len0, output_size);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
var r2 = getInt32Memory0()[retptr / 4 + 2];
var r3 = getInt32Memory0()[retptr / 4 + 3];
if (r3) {
throw takeObject(r2);
}
var v1 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1);
return v1;
} finally {
wasm.__wbindgen_add_to_stack_pointer(16);
}
}
/**
* @returns {number}
*/
total_out() {
const ret = wasm.decompressstream_total_out(this.ptr);
return ret >>> 0;
}
/**
* @returns {number}
*/
result() {
const ret = wasm.decompressstream_result(this.ptr);
return ret;
}
/**
* @returns {number}
*/
last_input_offset() {
const ret = wasm.decompressstream_last_input_offset(this.ptr);
return ret >>> 0;
}
}
module.exports.DecompressStream = DecompressStream;
module.exports.__wbindgen_json_serialize = function(arg0, arg1) {
const obj = getObject(arg1);
const ret = JSON.stringify(obj === undefined ? null : obj);
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len0;
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
};
module.exports.__wbindgen_is_undefined = function(arg0) {

@@ -204,11 +380,2 @@ const ret = getObject(arg0) === undefined;

module.exports.__wbindgen_json_serialize = function(arg0, arg1) {
const obj = getObject(arg1);
const ret = JSON.stringify(obj === undefined ? null : obj);
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
getInt32Memory0()[arg0 / 4 + 1] = len0;
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
};
module.exports.__wbg_new_693216e109162396 = function() {

@@ -239,2 +406,6 @@ const ret = new Error();

module.exports.__wbindgen_throw = function(arg0, arg1) {
throw new Error(getStringFromWasm0(arg0, arg1));
};
const path = require('path').join(__dirname, 'brotli_wasm_bg.wasm');

@@ -241,0 +412,0 @@ const bytes = require('fs').readFileSync(path);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc