Skip to content

Commit

Permalink
chore: bump @socket.io/component-emitter to version 3.0.0
Browse files Browse the repository at this point in the history
The typed events have been moved from [1] to [2], in order to remove
the intermediary class and reduce the bundle size.

Diff: socketio/emitter@2.0.0...3.0.0

[1]: https://github.com/socketio/socket.io-client/
[2]: https://github.com/socketio/emitter/
  • Loading branch information
darrachequesne committed Oct 14, 2021
1 parent 5ad3e5c commit eb708d1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
14 changes: 9 additions & 5 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Emitter from "@socket.io/component-emitter";
import { Emitter } from "@socket.io/component-emitter";
import { deconstructPacket, reconstructPacket } from "./binary.js";
import { isBinary, hasBinary } from "./is-binary.js";
import debugModule from "debug"; // debug()
Expand Down Expand Up @@ -109,12 +109,16 @@ export class Encoder {
}
}

interface DecoderReservedEvents {
decoded: (packet: Packet) => void;
}

/**
* A socket.io Decoder instance
*
* @return {Object} decoder
*/
export class Decoder extends Emitter {
export class Decoder extends Emitter<{}, {}, DecoderReservedEvents> {
private reconstructor: BinaryReconstructor;

constructor() {
Expand All @@ -140,11 +144,11 @@ export class Decoder extends Emitter {

// no attachments, labeled binary but no binary data to follow
if (packet.attachments === 0) {
super.emit("decoded", packet);
super.emitReserved("decoded", packet);
}
} else {
// non-binary full packet
super.emit("decoded", packet);
super.emitReserved("decoded", packet);
}
} else if (isBinary(obj) || obj.base64) {
// raw binary data
Expand All @@ -155,7 +159,7 @@ export class Decoder extends Emitter {
if (packet) {
// received final buffer
this.reconstructor = null;
super.emit("decoded", packet);
super.emitReserved("decoded", packet);
}
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"require": "./build/cjs/index.js"
},
"dependencies": {
"@socket.io/component-emitter": "~2.0.0",
"@socket.io/component-emitter": "~3.0.0",
"debug": "~4.3.1"
},
"devDependencies": {
Expand Down

0 comments on commit eb708d1

Please sign in to comment.