Skip to content

Move binary detection to the parser #1103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
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.1",
"to-array": "0.1.4"
},
"devDependencies": {
Expand Down