[feat] Move binary detection to the parser (#1103)

This commit is contained in:
Damien Arrachequesne
2017-04-25 00:28:50 +02:00
committed by GitHub
parent b4c7e49607
commit ff4cb3eed0
2 changed files with 3 additions and 8 deletions

View File

@@ -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.
@@ -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;
@@ -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
});