Socket
Socket
Sign inDemoInstall

engine.io-parser

Package Overview
Dependencies
Maintainers
2
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

engine.io-parser - npm Package Compare versions

Comparing version 4.0.0 to 4.0.1

10

CHANGELOG.md

@@ -1,3 +0,11 @@

# [4.0.0](https://github.com/socketio/engine.io-parser/compare/v4.0.0-alpha.1...v4.0.0) (2020-09-08)
## [4.0.1](https://github.com/socketio/engine.io-parser/compare/4.0.0...4.0.1) (2020-09-10)
### Bug Fixes
* use a terser-compatible representation of the separator ([886f9ea](https://github.com/socketio/engine.io-parser/commit/886f9ea7c4e717573152c31320f6fb6c6664061b))
# [4.0.0](https://github.com/socketio/engine.io-parser/compare/v4.0.0-alpha.1...4.0.0) (2020-09-08)
This major release contains the necessary changes for the version 4 of the Engine.IO protocol. More information about the new version can be found [there](https://github.com/socketio/engine.io-protocol#difference-between-v3-and-v4).

@@ -4,0 +12,0 @@

2

lib/index.js
const encodePacket = require("./encodePacket");
const decodePacket = require("./decodePacket");
const SEPARATOR = "\x1e"; // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text
const SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text

@@ -6,0 +6,0 @@ const encodePayload = (packets, callback) => {

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "4.0.0",
"version": "4.0.1",
"main": "lib/index.js",

@@ -8,0 +8,0 @@ "homepage": "https://github.com/socketio/engine.io-parser",

@@ -18,16 +18,12 @@

with the following methods: `encodePacket`, `decodePacket`, `encodePayload`,
`decodePayload`, `encodePayloadAsBinary`, `decodePayloadAsBinary`.
`decodePayload`.
The browser-side parser also includes `encodePayloadAsArrayBuffer` and `encodePayloadAsBlob`.
Example:
```js
var parser = require('engine.io-parser');
const parser = require("engine.io-parser");
const data = Buffer.from([ 1, 2, 3, 4 ]);
var data = new Buffer(5);
for (var i = 0; i < data.length; i++) { data[i] = i; }
parser.encodePacket({ type: 'message', data: data }, function(encoded) {
var decodedData = parser.decodePacket(encoded); // { type: 'message', data: data }
parser.encodePacket({ type: "message", data }, encoded => {
const decodedData = parser.decodePacket(encoded); // decodedData === data
});

@@ -50,17 +46,17 @@ ```

```js
var parser = require('engine.io-parser');
const parser = require("engine.io-parser");
var testBuffer = new Int8Array(10);
for (var i = 0; i < testBuffer.length; i++) testBuffer[i] = i;
const testBuffer = new Int8Array(10);
for (let i = 0; i < testBuffer.length; i++) testBuffer[i] = i;
var packets = [{ type: 'message', data: testBuffer.buffer }, { type: 'message', data: 'hello' }];
const packets = [{ type: "message", data: testBuffer.buffer }, { type: "message", data: "hello" }];
parser.encodePayload(packets, function(encoded) {
parser.encodePayload(packets, encoded => {
parser.decodePayload(encoded,
function(packet, index, total) {
var isLast = index + 1 == total;
(packet, index, total) => {
const isLast = index + 1 == total;
if (!isLast) {
var buffer = new Int8Array(packet.data); // testBuffer
const buffer = new Int8Array(packet.data); // testBuffer
} else {
var message = packet.data; // 'hello'
const message = packet.data; // "hello"
}

@@ -101,3 +97,3 @@ });

- `data`: can be a `String`, `Number`, `Buffer`, `ArrayBuffer`
- `Boolean`: optional, binary support
- `Boolean`: binary support
- `Function`: callback, returns the encoded packet (`cb(String)`)

@@ -111,13 +107,2 @@ - `decodePacket`

- `encodeBase64Packet`
- Encodes a packet with binary data in a base64 string (`String`)
- **Parameters**
- `Object`: the packet to encode, has `type` and `data`
- `Function`: callback, returns the base64 encoded message (`cb(String)`)
- `decodeBase64Packet`
- Decodes a packet encoded in a base64 string.
- **Parameters**
- `String`: the base64 encoded message
- `String`: optional, the binary type
- `encodePayload`

@@ -129,3 +114,2 @@ - Encodes multiple messages (payload).

- `Array`: an array of packets
- `Boolean`: optional, binary support
- `Function`: callback, returns the encoded payload (`cb(String)`)

@@ -137,35 +121,7 @@ - `decodePayload`

- `String`: the payload
- `String`: optional, the binary type
- `Function`: callback, returns (cb(`Object`: packet, `Number`:packet index, `Number`:packet total))
- `encodePayloadAsBinary`
- Encodes multiple messages (payload) as binary.
- **Parameters**
- `Array`: an array of packets
- `Function`: callback, returns the encoded payload (`cb(Buffer)`)
- `decodePayloadAsBinary`
- Decodes data when a payload is maybe expected. Strings are decoded by
interpreting each byte as a key code for entries marked to start with 0. See
description of encodePayloadAsBinary.
- **Parameters**
- `Buffer`: the buffer
- `String`: optional, the binary type
- `Function`: callback, returns the decoded packet (`cb(Object)`)
### Browser
- `encodePayloadAsArrayBuffer`
- Encodes multiple messages (payload) as binary.
- **Parameters**
- `Array`: an array of packets
- `Function`: callback, returns the encoded payload (`cb(ArrayBuffer)`)
- `encodePayloadAsBlob`
- Encodes multiple messages (payload) as blob.
- **Parameters**
- `Array`: an array of packets
- `Function`: callback, returns the encoded payload (`cb(Blob)`)
## Tests
Standalone tests can be run with `make test` which will run both node.js and browser tests.
Standalone tests can be run with `npm test` which will run the node.js tests.

@@ -178,3 +134,3 @@ Browser tests are run using [zuul](https://github.com/defunctzombie/zuul).

```
./node_modules/.bin/zuul --local 8080 -- test/index.js
npm run test:browser
```

@@ -186,4 +142,4 @@

- irc.freenode.net **#socket.io**
- [Google Groups](http://groups.google.com/group/socket_io)
- [Website](http://socket.io)
- [Github Discussions](https://github.com/socketio/socket.io/discussions)
- [Website](https://socket.io)

@@ -196,3 +152,3 @@ ## Development

```bash
git clone git://github.com/LearnBoost/engine.io-parser.git
git clone git://github.com/socketio/engine.io-parser.git
```

@@ -204,3 +160,3 @@

cd engine.io-parser
npm install
npm ci
```

@@ -207,0 +163,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc