{
  "name": "engine.io-parser",
  "description": "Parser for the client for the realtime Engine",
  "version": "1.2.4",
  "homepage": "https://github.com/Automattic/engine.io-parser",
  "devDependencies": {
    "expect.js": "0.3.1",
    "mocha": "2.2.5",
    "zuul": "3.7.3",
    "zuul-ngrok": "3.2.0"
  },
  "dependencies": {
    "after": "0.8.1",
    "arraybuffer.slice": "0.0.6",
    "base64-arraybuffer": "0.1.2",
    "blob": "0.0.4",
    "has-binary": "0.1.6",
    "utf8": "2.1.0"
  },
  "scripts": {
    "test": "make test"
  },
  "repository": {
    "type": "git",
    "url": "git@github.com:Automattic/engine.io-parser.git"
  },
  "browser": "./lib/browser.js",
  "readme": "\n# engine.io-parser\n\n[![Build Status](https://secure.travis-ci.org/socketio/engine.io-parser.svg)](http://travis-ci.org/socketio/engine.io-parser)\n[![NPM version](https://badge.fury.io/js/engine.io-parser.svg)](http://badge.fury.io/js/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`, `encodePayloadAsBinary`, `decodePayloadAsBinary`.\n\nThe browser-side parser also includes `encodePayloadAsArrayBuffer` and `encodePayloadAsBlob`.\n\nExample:\n\n```js\nvar parser = require('engine.io-parser');\n\nvar data = new Buffer(5);\nfor (var i = 0; i < data.length; i++) { data[i] = i; }\n\nparser.encodePacket({ type: 'message', data: data }, function(encoded) {\n  var decodedData = parser.decodePacket(encoded); // { type: 'message', data: 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    var parser = require('engine.io-parser');\n\n    var testBuffer = new Int8Array(10);\n    for (var i = 0; i < testBuffer.length; i++) testBuffer[i] = i;\n\n    var packets = [{ type: 'message', data: testBuffer.buffer }, { type: 'message', data: 'hello' }];\n\n    parser.encodePayload(packets, function(encoded) {\n      parser.decodePayload(encoded,\n        function(packet, index, total) {\n          var isLast = index + 1 == total;\n          if (!isLast) {\n            var buffer = new Int8Array(packet.data); // testBuffer\n          } else {\n            var 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`: optional, 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- `encodeBase64Packet`\n    - Encodes a packet with binary data in a base64 string (`String`)\n    - **Parameters**\n      - `Object`: the packet to encode, has `type` and `data`\n      - `Function`: callback, returns the base64 encoded message (`cb(String)`)\n- `decodeBase64Packet`\n    - Decodes a packet encoded in a base64 string.\n    - **Parameters**\n      - `String`: the base64 encoded message\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      - `Boolean`: optional, binary support\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      - `String`: optional, the binary type\n      - `Function`: callback, returns (cb(`Object`: packet, `Number`:packet index, `Number`:packet total))\n\n- `encodePayloadAsBinary`\n    - Encodes multiple messages (payload) as binary.\n    - **Parameters**\n      - `Array`: an array of packets\n      - `Function`: callback, returns the encoded payload (`cb(Buffer)`)\n- `decodePayloadAsBinary`\n    - Decodes data when a payload is maybe expected. Strings are decoded by\n      interpreting each byte as a key code for entries marked to start with 0. See\n      description of encodePayloadAsBinary.\n    - **Parameters**\n      - `Buffer`: the buffer\n      - `String`: optional, the binary type\n      - `Function`: callback, returns the decoded packet (`cb(Object)`)\n\n### Browser\n\n- `encodePayloadAsArrayBuffer`\n    - Encodes multiple messages (payload) as binary.\n    - **Parameters**\n      - `Array`: an array of packets\n      - `Function`: callback, returns the encoded payload (`cb(ArrayBuffer)`)\n- `encodePayloadAsBlob`\n    - Encodes multiple messages (payload) as blob.\n    - **Parameters**\n      - `Array`: an array of packets\n      - `Function`: callback, returns the encoded payload (`cb(Blob)`)\n\n## Tests\n\nStandalone tests can be run with `make test` which will run both node.js and browser 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```\n./node_modules/.bin/zuul --local 8080 -- test/index.js\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  - [Google Groups](http://groups.google.com/group/socket_io)\n  - [Website](http://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/LearnBoost/engine.io-parser.git\n```\n\nThen:\n\n```bash\ncd engine.io-parser\nnpm install\n```\n\nSee the `Tests` section above for how to run tests before submitting any patches.\n\n## License\n\nMIT\n",
  "readmeFilename": "Readme.md",
  "bugs": {
    "url": "https://github.com/Automattic/engine.io-parser/issues"
  },
  "_id": "engine.io-parser@1.2.4",
  "_from": "engine.io-parser@1.2.4"
}
