Skip to content

Commit f0a7ecd

Browse files
robhoganfacebook-github-bot
authored andcommitted
Add Flow lib defs for Node's zlib zstd support (#54616)
Summary: Since 22.15, Node.js now natively supports zstd (de)compression in `zlib`. This adds the Flow typings. - Node docs: https://nodejs.org/api/zlib.html#zlibcreatezstdcompressoptions - Reference for new constants: https://github.com/nodejs/node/blob/main/deps/zstd/lib/zstd.h Changelog: [General][Internal] Monorepo Flow typings Reviewed By: javache Differential Revision: D87449911
1 parent 00eba55 commit f0a7ecd

1 file changed

Lines changed: 93 additions & 0 deletions

File tree

flow-typed/environment/node.js

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3484,6 +3484,20 @@ type zlib$brotliOptions = {
34843484
...
34853485
};
34863486

3487+
type zlib$zstdOptions = {
3488+
flush?: number,
3489+
finishFlush?: number,
3490+
chunkSize?: number,
3491+
params?: {
3492+
[number]: boolean | number,
3493+
...
3494+
},
3495+
maxOutputLength?: number,
3496+
info?: boolean,
3497+
dictionary?: Buffer,
3498+
...
3499+
};
3500+
34873501
type zlib$syncFn = (
34883502
buffer: Buffer | $TypedArray | DataView | ArrayBuffer | string,
34893503
options?: zlib$options,
@@ -3661,6 +3675,79 @@ declare module 'zlib' {
36613675
BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: number,
36623676
BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: number,
36633677
BROTLI_DECODER_ERROR_UNREACHABL: number,
3678+
3679+
ZSTD_COMPRESS: number,
3680+
ZSTD_DECOMPRESS: number,
3681+
3682+
// Default compression level for zstd streams
3683+
ZSTD_CLEVEL_DEFAULT: number,
3684+
3685+
// Keys for zlib$zstdOptions['params']
3686+
ZSTD_c_compressionLevel: number,
3687+
ZSTD_c_windowLog: number,
3688+
ZSTD_c_hashLog: number,
3689+
ZSTD_c_chainLog: number,
3690+
ZSTD_c_searchLog: number,
3691+
ZSTD_c_minMatch: number,
3692+
ZSTD_c_targetLength: number,
3693+
ZSTD_c_strategy: number,
3694+
ZSTD_c_enableLongDistanceMatching: number,
3695+
ZSTD_c_ldmHashLog: number,
3696+
ZSTD_c_ldmMinMatch: number,
3697+
ZSTD_c_ldmBucketSizeLog: number,
3698+
ZSTD_c_ldmHashRateLog: number,
3699+
ZSTD_c_contentSizeFlag: number,
3700+
ZSTD_c_checksumFlag: number,
3701+
ZSTD_c_dictIDFlag: number,
3702+
ZSTD_c_nbWorkers: number,
3703+
ZSTD_c_jobSize: number,
3704+
ZSTD_c_overlapLog: number,
3705+
3706+
// Flush opereations
3707+
ZSTD_e_continue: number,
3708+
ZSTD_e_flush: number,
3709+
ZSTD_e_end: number,
3710+
3711+
// Values for the ZSTD_c_strategy paramater
3712+
ZSTD_fast: number,
3713+
ZSTD_dfast: number,
3714+
ZSTD_greedy: number,
3715+
ZSTD_lazy: number,
3716+
ZSTD_lazy2: number,
3717+
ZSTD_btlazy2: number,
3718+
ZSTD_btopt: number,
3719+
ZSTD_btultra: number,
3720+
ZSTD_btultra2: number,
3721+
3722+
// Error codes
3723+
ZSTD_error_no_error: number,
3724+
ZSTD_error_GENERIC: number,
3725+
ZSTD_error_prefix_unknown: number,
3726+
ZSTD_error_version_unsupported: number,
3727+
ZSTD_error_frameParameter_unsupported: number,
3728+
ZSTD_error_frameParameter_windowTooLarge: number,
3729+
ZSTD_error_corruption_detected: number,
3730+
ZSTD_error_checksum_wrong: number,
3731+
ZSTD_error_literals_headerWrong: number,
3732+
ZSTD_error_dictionary_corrupted: number,
3733+
ZSTD_error_dictionary_wrong: number,
3734+
ZSTD_error_dictionaryCreation_failed: number,
3735+
ZSTD_error_parameter_unsupported: number,
3736+
ZSTD_error_parameter_combination_unsupported: number,
3737+
ZSTD_error_parameter_outOfBound: number,
3738+
ZSTD_error_tableLog_tooLarge: number,
3739+
ZSTD_error_maxSymbolValue_tooLarge: number,
3740+
ZSTD_error_maxSymbolValue_tooSmall: number,
3741+
ZSTD_error_stabilityCondition_notRespected: number,
3742+
ZSTD_error_stage_wrong: number,
3743+
ZSTD_error_init_missing: number,
3744+
ZSTD_error_memory_allocation: number,
3745+
ZSTD_error_workSpace_tooSmall: number,
3746+
ZSTD_error_dstSize_tooSmall: number,
3747+
ZSTD_error_srcSize_wrong: number,
3748+
ZSTD_error_dstBuffer_null: number,
3749+
ZSTD_error_noForwardProgress_destFull: number,
3750+
ZSTD_error_noForwardProgress_inputEmpty: number,
36643751
...
36653752
};
36663753
declare var codes: {
@@ -3680,6 +3767,8 @@ declare module 'zlib' {
36803767
}
36813768
declare class BrotliCompress extends Zlib {}
36823769
declare class BrotliDecompress extends Zlib {}
3770+
declare class ZstdCompress extends Zlib {}
3771+
declare class ZstdDecompress extends Zlib {}
36833772
declare class Deflate extends Zlib {}
36843773
declare class Inflate extends Zlib {}
36853774
declare class Gzip extends Zlib {}
@@ -3700,6 +3789,10 @@ declare module 'zlib' {
37003789
declare function createGzip(options?: zlib$options): Gzip;
37013790
declare function createGunzip(options?: zlib$options): Gunzip;
37023791
declare function createUnzip(options?: zlib$options): Unzip;
3792+
declare function createZstdCompress(options?: zlib$zstdOptions): ZstdCompress;
3793+
declare function createZstdDecompress(
3794+
options?: zlib$zstdOptions,
3795+
): ZstdDecompress;
37033796
declare var brotliCompress: zlib$brotliAsyncFn;
37043797
declare var brotliCompressSync: zlib$brotliSyncFn;
37053798
declare var brotliDeompress: zlib$brotliAsyncFn;

0 commit comments

Comments
 (0)