{"name":"engine.io-parser","description":"Parser for the client for the realtime Engine","license":"MIT","version":"5.0.6","main":"./build/cjs/index.js","module":"./build/esm/index.js","exports":{"import":"./build/esm/index.js","require":"./build/cjs/index.js"},"types":"build/esm/index.d.ts","homepage":"https://github.com/socketio/engine.io-parser","devDependencies":{"@babel/core":"~7.9.6","@babel/preset-env":"~7.9.6","@types/mocha":"^9.0.0","@types/node":"^16.9.6","babelify":"^10.0.0","benchmark":"^2.1.4","expect.js":"0.3.1","mocha":"^5.2.0","nyc":"~15.0.1","prettier":"^1.19.1","rimraf":"^3.0.2","socket.io-browsers":"^1.0.4","ts-node":"^10.2.1","tsify":"^5.0.4","typescript":"^4.4.3","zuul":"3.11.1","zuul-ngrok":"4.0.0"},"scripts":{"compile":"rimraf ./build && tsc && tsc -p tsconfig.esm.json && ./postcompile.sh","test":"npm run format:check && npm run compile && if test \"$BROWSERS\" = \"1\" ; then npm run test:browser; else npm run test:node; fi","test:node":"nyc mocha -r ts-node/register test/index.ts","test:browser":"zuul test/index.ts --no-coverage","format:check":"prettier --check 'lib/**/*.ts' 'test/**/*.ts'","format:fix":"prettier --write 'lib/**/*.ts' 'test/**/*.ts'","prepack":"npm run compile"},"repository":{"type":"git","url":"git+ssh://git@github.com/socketio/engine.io-parser.git"},"browser":{"./test/node":"./test/browser","./build/esm/encodePacket.js":"./build/esm/encodePacket.browser.js","./build/esm/decodePacket.js":"./build/esm/decodePacket.browser.js","./build/cjs/encodePacket.js":"./build/cjs/encodePacket.browser.js","./build/cjs/decodePacket.js":"./build/cjs/decodePacket.browser.js"},"engines":{"node":">=10.0.0"},"gitHead":"214182b4f0616a44c18251d9f418a7ca5595dbe4","bugs":{"url":"https://github.com/socketio/engine.io-parser/issues"},"_id":"engine.io-parser@5.0.6","_nodeVersion":"16.15.1","_npmVersion":"8.11.0","dist":{"integrity":"sha512-tjuoZDMAdEhVnSFleYPCtdL2GXwVTGtNjoeJd9IhIG3C1xs9uwxqRNEu5WpnDZCaozwVlK/nuQhpodhXSIMaxw==","shasum":"7811244af173e157295dec9b2718dfe42a64ef45","tarball":"http://registry-npm.ywwl.com/engine.io-parser/download/engine.io-parser-5.0.6.tgz","fileCount":26,"unpackedSize":28754,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGief+ZGTznI9iw/AkACbrQ2Sy5yKQMQwQoKAzz5/qFeAiAI06NYg9f6Z6nPeIjnBko236zOiebx4BOVDUo1naPoHQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjxP5/ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpCTA/8D5t/DYyWXoxSyfr6oBu8YAMH/tu5mWXvpngMBnJweYoGKLrT\r\n4DXOaeq7DcKpA9l5A2NMnO4LsWawHFY/quT/MIrICRWLRWoySmm0bX1d/5MK\r\ng1REvw+YuTo/dwspSV2PU+koA/AUShV0mrrEE7YtaCCwJYwzUH+l8vXrJgik\r\nSv1WrxpSefo+5wHok/FHFjioEvrIX6q4V+8Kn/7z0cYtzL2jDebJq5PbxZMl\r\nASptMiIRgytejhn0h28JieZ54d5+4VrRjGsIEBFFsKGOzBEicsDbEISNRwCJ\r\nW6jPcq4pvRN0PTDhfHpuhwAgtxJ/F1VCsVxwmu6uOp/NYiVPKULr56LGziZb\r\n8fEk1gAzlh/NJ4RLYWvlzpAIsfxIbsswxxvY0ladI8Iyn9qYy2uOJ3WcPzkv\r\noBOl5tZYYKEozmm7M1JkfajbRHpJSJuo3Z1poxMp5vqBr2cjtETSKpBxb0qC\r\nb/7uSfXT5cikf0MjklMdd0EWryLKQFWe+1QQaMmEKiUUVOe340VWjpAWZoC3\r\nbcPC5hP+nn5pEgdU3jv2Im9DrH4YQDf3UsXdMgw87dUj8IKqCq99ot9t3ksF\r\n2JnDPYgchweAb2pecXtGG4RvCDofiBKbFfkxDjOPr+mdNAAW5QbupIJkMbA5\r\na2KDuydFBosl34W3vI8uppoIpsHQYju55pE=\r\n=80VK\r\n-----END PGP SIGNATURE-----\r\n","size":6764,"noattachment":false,"key":"/engine.io-parser/-/engine.io-parser-5.0.6.tgz"},"_npmUser":{"name":"darrachequesne","email":"damien.arrachequesne@gmail.com"},"directories":{},"maintainers":[{"name":"rauchg","email":"rauchg@gmail.com"},{"name":"darrachequesne","email":"damien.arrachequesne@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/engine.io-parser_5.0.6_1673854591025_0.3686450556086678"},"_hasShrinkwrap":false,"readme":"\n# engine.io-parser\n\n[![Build Status](https://github.com/socketio/engine.io-parser/workflows/CI/badge.svg?branch=main)](https://github.com/socketio/engine.io-parser/actions)\n[![NPM version](https://badge.fury.io/js/engine.io-parser.svg)](https://npmjs.com/package/engine.io-parser)\n\nThis is the JavaScript parser for the engine.io protocol encoding,\nshared by both\n[engine.io-client](https://github.com/socketio/engine.io-client) and\n[engine.io](https://github.com/socketio/engine.io).\n\n## How to use\n\n### Standalone\n\nThe parser can encode/decode packets, payloads, and payloads as binary\nwith the following methods: `encodePacket`, `decodePacket`, `encodePayload`,\n`decodePayload`.\n\nExample:\n\n```js\nconst parser = require(\"engine.io-parser\");\nconst data = Buffer.from([ 1, 2, 3, 4 ]);\n\nparser.encodePacket({ type: \"message\", data }, encoded => {\n  const decodedData = parser.decodePacket(encoded); // decodedData === data\n});\n```\n\n### With browserify\n\nEngine.IO Parser is a commonjs module, which means you can include it by using\n`require` on the browser and package using [browserify](http://browserify.org/):\n\n1. install the parser package\n\n    ```shell\n    npm install engine.io-parser\n    ```\n\n1. write your app code\n\n    ```js\n    const parser = require(\"engine.io-parser\");\n\n    const testBuffer = new Int8Array(10);\n    for (let i = 0; i < testBuffer.length; i++) testBuffer[i] = i;\n\n    const packets = [{ type: \"message\", data: testBuffer.buffer }, { type: \"message\", data: \"hello\" }];\n\n    parser.encodePayload(packets, encoded => {\n      parser.decodePayload(encoded,\n        (packet, index, total) => {\n          const isLast = index + 1 == total;\n          if (!isLast) {\n            const buffer = new Int8Array(packet.data); // testBuffer\n          } else {\n            const message = packet.data; // \"hello\"\n          }\n        });\n    });\n    ```\n\n1. build your app bundle\n\n    ```bash\n    $ browserify app.js > bundle.js\n    ```\n\n1. include on your page\n\n    ```html\n    <script src=\"/path/to/bundle.js\"></script>\n    ```\n\n## Features\n\n- Runs on browser and node.js seamlessly\n- Runs inside HTML5 WebWorker\n- Can encode and decode packets\n  - Encodes from/to ArrayBuffer or Blob when in browser, and Buffer or ArrayBuffer in Node\n\n## API\n\nNote: `cb(type)` means the type is a callback function that contains a parameter of type `type` when called.\n\n### Node\n\n- `encodePacket`\n    - Encodes a packet.\n    - **Parameters**\n      - `Object`: the packet to encode, has `type` and `data`.\n        - `data`: can be a `String`, `Number`, `Buffer`, `ArrayBuffer`\n      - `Boolean`: binary support\n      - `Function`: callback, returns the encoded packet (`cb(String)`)\n- `decodePacket`\n    - Decodes a packet. Data also available as an ArrayBuffer if requested.\n    - Returns data as `String` or (`Blob` on browser, `ArrayBuffer` on Node)\n    - **Parameters**\n      - `String` | `ArrayBuffer`: the packet to decode, has `type` and `data`\n      - `String`: optional, the binary type\n\n- `encodePayload`\n    - Encodes multiple messages (payload).\n    - If any contents are binary, they will be encoded as base64 strings. Base64\n      encoded strings are marked with a b before the length specifier\n    - **Parameters**\n      - `Array`: an array of packets\n      - `Function`: callback, returns the encoded payload (`cb(String)`)\n- `decodePayload`\n    - Decodes data when a payload is maybe expected. Possible binary contents are\n      decoded from their base64 representation.\n    - **Parameters**\n      - `String`: the payload\n      - `Function`: callback, returns (cb(`Object`: packet, `Number`:packet index, `Number`:packet total))\n\n## Tests\n\nStandalone tests can be run with `npm test` which will run the node.js tests.\n\nBrowser tests are run using [zuul](https://github.com/defunctzombie/zuul).\n(You must have zuul setup with a saucelabs account.)\n\nYou can run the tests locally using the following command:\n\n```\nnpm run test:browser\n```\n\n## Support\n\nThe support channels for `engine.io-parser` are the same as `socket.io`:\n  - irc.freenode.net **#socket.io**\n  - [Github Discussions](https://github.com/socketio/socket.io/discussions)\n  - [Website](https://socket.io)\n\n## Development\n\nTo contribute patches, run tests or benchmarks, make sure to clone the\nrepository:\n\n```bash\ngit clone git://github.com/socketio/engine.io-parser.git\n```\n\nThen:\n\n```bash\ncd engine.io-parser\nnpm ci\n```\n\nSee the `Tests` section above for how to run tests before submitting any patches.\n\n## License\n\nMIT\n","publish_time":1673854591235,"_cnpm_publish_time":1673854591235,"dist-tags":{"alpha":"4.0.0-alpha.1","latest":"5.2.3"}}