A WebSocket permessage-deflate compression extension plugin for websocket-extensions, with a threshold option to skip compressing small messages. Version 0.1.8 requires Node >=20.0.0. It implements the IETF draft for permessage-deflate compression, allowing configuration of compression level, memory level, strategy, window bits, and context takeover. The key differentiator from the original permessage-deflate is the addition of a threshold option (default 0) to avoid wasting CPU on tiny payloads.
npm install permessage-deflate2No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to import the extension, configure it with options including threshold, and add it to websocket-extensions.
Upgrade Node.js to 20 or later, or use the original permessage-deflate package (CJS compatible).
Use deflate.configure({...}) after import deflate from 'permessage-deflate2'.Monitor the original spec or consider using WebSocket libraries with built-in compression.
Ensure the threshold value is chosen carefully based on message size distribution.
Use ESM import: import deflate from 'permessage-deflate2'
Switch to ESM (e.g., type: 'module' in package.json) or use dynamic import().
Check server capabilities and try with default options.