-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json
36 lines (36 loc) · 2.98 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{
"name": "socket.io-parser",
"version": "2.2.1",
"description": "socket.io protocol parser",
"repository": {
"type": "git",
"url": "https://github.com/Automattic/socket.io-parser.git"
},
"dependencies": {
"debug": "0.7.4",
"json3": "3.2.6",
"component-emitter": "1.1.2",
"isarray": "0.0.1",
"benchmark": "1.0.0"
},
"devDependencies": {
"mocha": "1.16.2",
"expect.js": "0.2.0",
"zuul": "1.6.3"
},
"scripts": {
"test": "make test"
},
"license": "MIT",
"readme": "\n# socket.io-parser\n\n[![Build Status](https://secure.travis-ci.org/Automattic/socket.io-parser.png)](http://travis-ci.org/Automattic/socket.io-parser)\n[![NPM version](https://badge.fury.io/js/socket.io-parser.png)](http://badge.fury.io/js/socket.io-parser)\n\nA socket.io encoder and decoder written in JavaScript complying with version `3`\nof [socket.io-protocol](https://github.com/learnboost/socket.io-protocol).\nUsed by [socket.io](https://github.com/learnboost/socket.io) and\n[socket.io-client](https://github.com/learnboost/socket.io-client).\n\n## Parser API\n\n socket.io-parser is the reference implementation of socket.io-protocol. Read\n the full API here:\n [socket.io-protocol](https://github.com/learnboost/socket.io-protocol).\n\n## Example Usage\n\n### Encoding and decoding a packet\n\n```js\nvar parser = require('socket.io-parser');\nvar encoder = new parser.Encoder();\nvar packet = {\n type: parser.EVENT,\n data: 'test-packet',\n id: 13\n};\nencoder.encode(packet, function(encodedPackets) {\n var decoder = new parser.Decoder();\n decoder.on('decoded', function(decodedPacket) {\n // decodedPacket.type == parser.EVENT\n // decodedPacket.data == 'test-packet'\n // decodedPacket.id == 13\n });\n\n for (var i = 0; i < encodedPackets.length; i++) {\n decoder.add(encodedPackets[i]);\n }\n});\n```\n\n### Encoding and decoding a packet with binary data\n\n```js\nvar parser = require('socket.io-parser');\nvar encoder = new parser.Encoder();\nvar packet = {\n type: parser.BINARY_EVENT,\n data: {i: new Buffer(1234), j: new Blob([new ArrayBuffer(2)])}\n id: 15\n};\nencoder.encode(packet, function(encodedPackets) {\n var decoder = new parser.Decoder();\n decoder.on('decoded', function(decodedPacket) {\n // decodedPacket.type == parser.BINARY_EVENTEVENT\n // Buffer.isBuffer(decodedPacket.data.i) == true\n // Buffer.isBuffer(decodedPacket.data.j) == true\n // decodedPacket.id == 15\n });\n\n for (var i = 0; i < encodedPackets.length; i++) {\n decoder.add(encodedPackets[i]);\n }\n});\n```\nSee the test suite for more examples of how socket.io-parser is used.\n\n\n## License\n\nMIT\n",
"readmeFilename": "Readme.md",
"bugs": {
"url": "https://github.com/Automattic/socket.io-parser/issues"
},
"_id": "socket.io-parser@2.2.1",
"dist": {
"shasum": "df4af0a429b51d90ec829e5686f07e0c39a3e0c2"
},
"_from": "socket.io-parser@2.2.1",
"_resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-2.2.1.tgz"
}