engine.io-parser is a foundational JavaScript parser library responsible for encoding and decoding packets and payloads for the Engine.IO protocol, which underpins Socket.IO. It enables seamless communication by handling various data types including strings, numbers, buffers, and ArrayBuffers across both Node.js and browser environments. The current stable version is 5.2.3, and it is actively maintained as part of the broader Socket.IO ecosystem, receiving updates alongside major Socket.IO releases. Its key differentiators include robust cross-environment compatibility (Node.js, browser, WebWorkers) and flexible binary data handling (encoding to/from ArrayBuffer, Blob, or Buffer), making it a critical component for real-time, low-level data transmission.
npm install engine.io-parserVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates encoding and decoding single Engine.IO packets and multi-packet payloads, including binary data, showcasing the library's core functionality.
Consider wrapping callback-based functions with `util.promisify` in Node.js or creating custom Promise wrappers for a more modern async experience.
Optimize binary handling by understanding when base64 encoding occurs. For direct binary transport, ensure your transport layer (e.g., WebSocket) is configured to handle ArrayBuffers or Buffers natively and that `engine.io-parser`'s specific binary flags are correctly utilized.
Always check the specific type of binary data returned (e.g., `instanceof Buffer` in Node, `instanceof ArrayBuffer` or `instanceof Blob` in browser) and write platform-agnostic code or branch logic as needed.
For ESM, try `import * as parser from 'engine.io-parser';` then use `parser.encodePacket(...)`. If individual functions are exported, use `import { encodePacket } from 'engine.io-parser';`.When running in a browser, ensure you are providing `ArrayBuffer` or `Blob` objects for binary data instead of Node.js `Buffer` objects. If using a bundler like Webpack or Browserify, ensure `buffer` is polyfilled or correctly configured for browser usage.
No dependency data recorded yet.