{"name":"engine.io-parser","description":"Parser for the client for the realtime Engine","license":"MIT","version":"4.0.3","main":"lib/index.js","homepage":"https://github.com/socketio/engine.io-parser","devDependencies":{"@babel/core":"~7.9.6","@babel/preset-env":"~7.9.6","babel-eslint":"^10.0.3","babelify":"^10.0.0","benchmark":"^2.1.4","eslint":"^6.8.0","eslint-config-prettier":"^6.9.0","expect.js":"0.3.1","mocha":"^5.2.0","nyc":"~15.0.1","prettier":"^1.19.1","socket.io-browsers":"^1.0.4","zuul":"3.11.1","zuul-ngrok":"4.0.0"},"dependencies":{"base64-arraybuffer":"0.1.4"},"scripts":{"test":"npm run lint && npm run format:check && if test \"$BROWSERS\" = \"1\" ; then npm run test:browser; else npm run test:node; fi","test:node":"nyc mocha test/index.js","test:browser":"zuul test/index.js --no-coverage","format:check":"prettier --check 'lib/**/*.js' 'test/**/*.js'","format:fix":"prettier --write 'lib/**/*.js' 'test/**/*.js'","lint":"eslint 'lib/**/*.js' 'test/**/*.js'"},"repository":{"type":"git","url":"git+ssh://git@github.com/socketio/engine.io-parser.git"},"browser":{"./lib/encodePacket.js":"./lib/encodePacket.browser.js","./lib/decodePacket.js":"./lib/decodePacket.browser.js"},"engines":{"node":">=8.0.0"},"gitHead":"412bcc429877affc12a7491f86818c71e320a6c0","bugs":{"url":"https://github.com/socketio/engine.io-parser/issues"},"_id":"engine.io-parser@4.0.3","_nodeVersion":"12.19.0","_npmVersion":"6.14.8","dist":{"integrity":"sha512-xEAAY0msNnESNPc00e19y5heTPX4y/TJ36gr8t1voOaNmTojP9b3oK3BbJLFufW2XFPQaaijpFewm2g2Um3uqA==","shasum":"83d3a17acfd4226f19e721bb22a1ee8f7662d2f6","tarball":"http://registry-npm.ywwl.com/engine.io-parser/download/engine.io-parser-4.0.3.tgz","fileCount":10,"unpackedSize":17697,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhKyF4CRA9TVsSAnZWagAAYUcP/iMq7HaFrDfSlN93N0nL\nQqgE2KO1Wi3lAMsK4ym8HPnBYd9URL6Y/BsDQcj/ErT7HelXO8lJY/xtYakV\nW/9FFQ9UYEwfJOJvRuaTSDHuBDlUYufKcngKyjHRttx8RsCzyfT0giazo5cb\nhJ2vJUi60esBJRRBAkH3bYXf7fcjqATWiJnpAqGI0+Gb4Ovzzp2ms8fHdrUH\n3IUeoueBBLXWKQ5v9wQ0C4ed6EB24v3bVgdBlDczBNlSxMTnyEshxbuQEcSf\n7qzqXOPUjQM4zJFnmSm25u6L3QWLhNVpQb6mEI3eSWqJSEUm7iz9tm5pcvi/\neEq7J2qn2ocof7mZWgBqw7WggXxrjHKgDSGGwCpaNxzTBFu3C06MgLvsZr4S\nKDQlTkUaOnzBsqX2f127BwwKt2DBrNJz7b1Nwxx5rTvTDU0BR/U6oYuzC6UB\ncam9qm+8TjMLGO66v44+00pR8kRBuLstjyd8RCgzisozh+uRCOWFuUidLodr\nqGRb7xbO8ZTxO9Tt3z/dIVhb4N/6usOEQqoVDtuaseL1cI7C7m7++usr/tIx\n/n301BMOL+hFOOIUksbKhDESHi0lawiUbF9Yfj+dO1tbfaX3yLpJNaR1hDww\nbL4s5BGcuNc94IIVN6CgAKsE+pnUffOPGFNyW6sxTj/1nBxtLZdWTu2GoxIH\nO9CY\r\n=OEUO\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDMy44BODamADny2/dZ0QukDCgQqxtPqdzDfdyFu+hhrAiAF54hEqedfH1DYFNqfwcpcq3QhIY8wY3bliBVzU1NPBQ=="}],"size":6280,"noattachment":false,"key":"/engine.io-parser/-/engine.io-parser-4.0.3.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_4.0.3_1630216568667_0.48666544141584644"},"_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":1630216568788,"_cnpm_publish_time":1630216568788,"dist-tags":{"alpha":"4.0.0-alpha.1","latest":"5.2.3"}}