diff --git a/lib/node.js b/lib/node.js index 24983fd028b..dfcef62362e 100644 --- a/lib/node.js +++ b/lib/node.js @@ -2402,15 +2402,38 @@ type zlib$options = { ... }; +type zlib$brotliOptions = { + flush?: number, + finishFlush?: number, + chunkSize?: number, + params?: { + [number]: boolean | number, + ... + }, + maxOutputLength?: number, + ... +} + type zlib$syncFn = ( - buffer: string | Buffer, + buffer: Buffer | $TypedArray | DataView | ArrayBuffer | string, options?: zlib$options ) => Buffer; type zlib$asyncFn = ( - buffer: string | Buffer, + buffer: Buffer | $TypedArray | DataView | ArrayBuffer | string, options?: zlib$options, - callback?: ((error: ?Error, result: any) => void) + callback?: (error: ?Error, result: Buffer) => void +) => void; + +type zlib$brotliSyncFn = ( + buffer: Buffer | $TypedArray | DataView | ArrayBuffer | string, + options?: zlib$brotliOptions +) => Buffer; + +type zlib$brotliAsyncFn = ( + buffer: Buffer | $TypedArray | DataView | ArrayBuffer | string, + options?: zlib$brotliOptions, + callback?: (error: ?Error, result: Buffer) => void ) => void; // Accessing the constants directly from the module is currently still @@ -2504,6 +2527,70 @@ declare module "zlib" { Z_MIN_LEVEL: number, Z_MIN_MEMLEVEL: number, Z_MIN_WINDOWBITS: number, + + BROTLI_DECODE: number, + BROTLI_ENCODE: number, + BROTLI_OPERATION_PROCESS: number, + BROTLI_OPERATION_FLUSH: number, + BROTLI_OPERATION_FINISH: number, + BROTLI_OPERATION_EMIT_METADATA: number, + BROTLI_PARAM_MODE: number, + BROTLI_MODE_GENERIC: number, + BROTLI_MODE_TEXT: number, + BROTLI_MODE_FONT: number, + BROTLI_DEFAULT_MODE: number, + BROTLI_PARAM_QUALITY: number, + BROTLI_MIN_QUALITY: number, + BROTLI_MAX_QUALITY: number, + BROTLI_DEFAULT_QUALITY: number, + BROTLI_PARAM_LGWIN: number, + BROTLI_MIN_WINDOW_BITS: number, + BROTLI_MAX_WINDOW_BITS: number, + BROTLI_LARGE_MAX_WINDOW_BITS: number, + BROTLI_DEFAULT_WINDOW: number, + BROTLI_PARAM_LGBLOCK: number, + BROTLI_MIN_INPUT_BLOCK_BITS: number, + BROTLI_MAX_INPUT_BLOCK_BITS: number, + BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: number, + BROTLI_PARAM_SIZE_HINT: number, + BROTLI_PARAM_LARGE_WINDOW: number, + BROTLI_PARAM_NPOSTFIX: number, + BROTLI_PARAM_NDIRECT: number, + BROTLI_DECODER_RESULT_ERROR: number, + BROTLI_DECODER_RESULT_SUCCESS: number, + BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: number, + BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT: number, + BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION: number, + BROTLI_DECODER_PARAM_LARGE_WINDOW: number, + BROTLI_DECODER_NO_ERROR: number, + BROTLI_DECODER_SUCCESS: number, + BROTLI_DECODER_NEEDS_MORE_INPUT: number, + BROTLI_DECODER_NEEDS_MORE_OUTPUT: number, + BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE: number, + BROTLI_DECODER_ERROR_FORMAT_RESERVED: number, + BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE: number, + BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET: number, + BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME: number, + BROTLI_DECODER_ERROR_FORMAT_CL_SPACE: number, + BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE: number, + BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT: number, + BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1: number, + BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2: number, + BROTLI_DECODER_ERROR_FORMAT_TRANSFORM: number, + BROTLI_DECODER_ERROR_FORMAT_DICTIONARY: number, + BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: number, + BROTLI_DECODER_ERROR_FORMAT_PADDING_1: number, + BROTLI_DECODER_ERROR_FORMAT_PADDING_2: number, + BROTLI_DECODER_ERROR_FORMAT_DISTANCE: number, + BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET: number, + BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: number, + BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: number, + BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS: number, + BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP: number, + BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1: number, + BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: number, + BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: number, + BROTLI_DECODER_ERROR_UNREACHABL: number, ... }; declare var codes: { @@ -2521,6 +2608,8 @@ declare module "zlib" { declare class Zlib extends stream$Duplex { // TODO } + declare class BrotliCompress extends Zlib {} + declare class BrotliDecompress extends Zlib {} declare class Deflate extends Zlib {} declare class Inflate extends Zlib {} declare class Gzip extends Zlib {} @@ -2528,6 +2617,8 @@ declare module "zlib" { declare class DeflateRaw extends Zlib {} declare class InflateRaw extends Zlib {} declare class Unzip extends Zlib {} + declare function createBrotliCompress(options?: zlib$brotliOptions): BrotliCompress; + declare function createBrotliDecompress(options?: zlib$brotliOptions): BrotliDecompress; declare function createDeflate(options?: zlib$options): Deflate; declare function createInflate(options?: zlib$options): Inflate; declare function createDeflateRaw(options?: zlib$options): DeflateRaw; @@ -2535,6 +2626,10 @@ declare module "zlib" { declare function createGzip(options?: zlib$options): Gzip; declare function createGunzip(options?: zlib$options): Gunzip; declare function createUnzip(options?: zlib$options): Unzip; + declare var brotliCompress: zlib$brotliAsyncFn; + declare var brotliCompressSync: zlib$brotliSyncFn; + declare var brotliDeompress: zlib$brotliAsyncFn; + declare var brotliDecompressSync: zlib$brotliSyncFn; declare var deflate: zlib$asyncFn; declare var deflateSync: zlib$syncFn; declare var gzip: zlib$asyncFn; diff --git a/tests/node_tests/node_tests.exp b/tests/node_tests/node_tests.exp index 12ddbebacf2..bbabba2c840 100644 --- a/tests/node_tests/node_tests.exp +++ b/tests/node_tests/node_tests.exp @@ -1636,26 +1636,26 @@ References: process/emitWarning.js:10:1 10| process.emitWarning(); // error ^^^^^^^^^^^^^^^^^^^^^ [1] - /node.js:2676:24 - 2676| emitWarning(warning: string | Error): void; + /node.js:2771:24 + 2771| emitWarning(warning: string | Error): void; ^^^^^^ [2] - /node.js:2676:33 - 2676| emitWarning(warning: string | Error): void; + /node.js:2771:33 + 2771| emitWarning(warning: string | Error): void; ^^^^^ [3] - /node.js:2677:3 - 2677| emitWarning(warning: string, typeOrCtor: string | (...empty) => mixed): void; + /node.js:2772:3 + 2772| emitWarning(warning: string, typeOrCtor: string | (...empty) => mixed): void; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [4] - /node.js:2678:3 - 2678| emitWarning(warning: string, type: string, codeOrCtor: string | (...empty) => mixed): void; + /node.js:2773:3 + 2773| emitWarning(warning: string, type: string, codeOrCtor: string | (...empty) => mixed): void; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [5] - /node.js:2679:3 + /node.js:2774:3 v----------- - 2679| emitWarning( - 2680| warning: string, - 2681| type: string, - 2682| code: string, - 2683| ctor?: (...empty) => mixed - 2684| ): void; + 2774| emitWarning( + 2775| warning: string, + 2776| type: string, + 2777| code: string, + 2778| ctor?: (...empty) => mixed + 2779| ): void; ------^ [6] @@ -1674,14 +1674,14 @@ References: process/emitWarning.js:11:21 11| process.emitWarning(42); // error ^^ [1] - /node.js:2677:24 - 2677| emitWarning(warning: string, typeOrCtor: string | (...empty) => mixed): void; + /node.js:2772:24 + 2772| emitWarning(warning: string, typeOrCtor: string | (...empty) => mixed): void; ^^^^^^ [2] - /node.js:2678:24 - 2678| emitWarning(warning: string, type: string, codeOrCtor: string | (...empty) => mixed): void; + /node.js:2773:24 + 2773| emitWarning(warning: string, type: string, codeOrCtor: string | (...empty) => mixed): void; ^^^^^^ [3] - /node.js:2680:14 - 2680| warning: string, + /node.js:2775:14 + 2775| warning: string, ^^^^^^ [4] @@ -1699,11 +1699,11 @@ References: process/emitWarning.js:12:29 12| process.emitWarning("blah", 42); // error ^^ [1] - /node.js:2678:38 - 2678| emitWarning(warning: string, type: string, codeOrCtor: string | (...empty) => mixed): void; + /node.js:2773:38 + 2773| emitWarning(warning: string, type: string, codeOrCtor: string | (...empty) => mixed): void; ^^^^^^ [2] - /node.js:2681:11 - 2681| type: string, + /node.js:2776:11 + 2776| type: string, ^^^^^^ [3] @@ -1719,8 +1719,8 @@ References: process/emitWarning.js:13:37 13| process.emitWarning("blah", "blah", 42); // error ^^ [1] - /node.js:2682:11 - 2682| code: string, + /node.js:2777:11 + 2777| code: string, ^^^^^^ [2] @@ -1734,8 +1734,8 @@ Cannot cast `process.emitWarning(...)` to string because undefined [1] is incomp ^^^^^^^^^^^^^^^^^^^^^^^^^^^ References: - /node.js:2676:41 - 2676| emitWarning(warning: string | Error): void; + /node.js:2771:41 + 2771| emitWarning(warning: string | Error): void; ^^^^ [1] process/emitWarning.js:14:31 14| (process.emitWarning("blah"): string); // error @@ -1800,8 +1800,8 @@ References: process/nextTick.js:27:3 27| (a: string, b: number, c: boolean) => {} // Error: too few arguments ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [1] - /node.js:2705:21 - 2705| nextTick: (cb: (...T) => mixed, ...T) => void; + /node.js:2800:21 + 2800| nextTick: (cb: (...T) => mixed, ...T) => void; ^^^^^^^^^^^^^^^ [2] @@ -1815,8 +1815,8 @@ Cannot cast `process.allowedNodeEnvironmentFlags` to string because `Set` [1] is ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ References: - /node.js:2665:32 - 2665| allowedNodeEnvironmentFlags: Set; + /node.js:2760:32 + 2760| allowedNodeEnvironmentFlags: Set; ^^^^^^^^^^^ [1] process/process.js:5:39 5| (process.allowedNodeEnvironmentFlags: string); // error