Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Move binary detection to the parser
  • Loading branch information
darrachequesne committed Apr 24, 2017
commit 0a70d363265d55f366d23121ad5c3b623518ed71
8 changes: 2 additions & 6 deletions lib/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ var toArray = require('to-array');
var on = require('./on');
var bind = require('component-bind');
var debug = require('debug')('socket.io-client:socket');
var hasBin = require('has-binary');

/**
* Module exports.
Expand Down Expand Up @@ -138,9 +137,7 @@ Socket.prototype.emit = function (ev) {
}

var args = toArray(arguments);
var parserType = parser.EVENT; // default
if (hasBin(args)) { parserType = parser.BINARY_EVENT; } // binary
var packet = { type: parserType, data: args };
var packet = { type: parser.EVENT, data: args };

packet.options = {};
packet.options.compress = !this.flags || false !== this.flags.compress;
Expand Down Expand Up @@ -289,9 +286,8 @@ Socket.prototype.ack = function (id) {
var args = toArray(arguments);
debug('sending ack %j', args);

var type = hasBin(args) ? parser.BINARY_ACK : parser.ACK;
self.packet({
type: type,
type: parser.ACK,
id: id,
data: args
});
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
"component-emitter": "1.2.1",
"debug": "2.3.3",
"engine.io-client": "2.0.2",
"has-binary": "0.1.7",
"has-cors": "1.1.0",
"indexof": "0.0.1",
"object-component": "0.0.3",
"parseuri": "0.0.5",
"socket.io-parser": "2.3.2",
"socket.io-parser": "~3.1.0",
"to-array": "0.1.4"
},
"devDependencies": {
Expand Down