MCPcopy Index your code
hub / github.com/nodejs/node / constructor

Method constructor

lib/zlib.js:887–925  ·  view source on GitHub ↗
(opts, mode, initParamsArray, maxParam)

Source from the content-addressed store, hash-verified

885};
886class Zstd extends ZlibBase {
887 constructor(opts, mode, initParamsArray, maxParam) {
888 assert(mode === ZSTD_COMPRESS || mode === ZSTD_DECOMPRESS);
889
890 initParamsArray.fill(-1);
891 if (opts?.params) {
892 ObjectKeys(opts.params).forEach((origKey) => {
893 const key = +origKey;
894 if (NumberIsNaN(key) || key < 0 || key > maxParam ||
895 (initParamsArray[key] | 0) !== -1) {
896 throw new ERR_ZSTD_INVALID_PARAM(origKey);
897 }
898
899 const value = opts.params[origKey];
900 if (typeof value !== 'number' && typeof value !== 'boolean') {
901 throw new ERR_INVALID_ARG_TYPE('options.params[key]',
902 'number', opts.params[origKey]);
903 }
904 initParamsArray[key] = value;
905 });
906 }
907
908 const handle = mode === ZSTD_COMPRESS ?
909 new binding.ZstdCompress() : new binding.ZstdDecompress();
910
911 const pledgedSrcSize = opts?.pledgedSrcSize ?? undefined;
912
913 const writeState = new Uint32Array(2);
914
915 handle.init(
916 initParamsArray,
917 pledgedSrcSize,
918 writeState,
919 processCallback,
920 opts?.dictionary && isArrayBufferView(opts.dictionary) ? opts.dictionary : undefined,
921 );
922
923 super(opts, mode, handle, zstdDefaultOpts);
924 this._writeState = writeState;
925 }
926}
927
928const kMaxZstdCParam = MathMax(...ObjectKeys(constants).map(

Callers

nothing calls this directly

Calls 4

fillMethod · 0.80
assertFunction · 0.70
forEachMethod · 0.65
initMethod · 0.45

Tested by

no test coverage detected