Skip to content

Commit

Permalink
[revert] Move binary detection to the parser
Browse files Browse the repository at this point in the history
So that we can skip the binary check.
  • Loading branch information
darrachequesne committed Feb 28, 2018
1 parent f115039 commit dc4f475
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 7 deletions.
5 changes: 0 additions & 5 deletions index.js
Expand Up @@ -5,7 +5,6 @@

var debug = require('debug')('socket.io-parser');
var Emitter = require('component-emitter');
var hasBin = require('has-binary2');
var binary = require('./binary');
var isArray = require('isarray');
var isBuf = require('./is-buffer');
Expand Down Expand Up @@ -125,10 +124,6 @@ function Encoder() {}
*/

Encoder.prototype.encode = function(obj, callback){
if ((obj.type === exports.EVENT || obj.type === exports.ACK) && hasBin(obj.data)) {
obj.type = obj.type === exports.EVENT ? exports.BINARY_EVENT : exports.BINARY_ACK;
}

debug('encoding packet %j', obj);

if (exports.BINARY_EVENT === obj.type || exports.BINARY_ACK === obj.type) {
Expand Down
2 changes: 1 addition & 1 deletion is-buffer.js
Expand Up @@ -5,7 +5,7 @@ var withNativeBuffer = typeof global.Buffer === 'function' && typeof global.Buff
var withNativeArrayBuffer = typeof global.ArrayBuffer === 'function';

var isView = (function () {
if (typeof global.ArrayBuffer.isView === 'function') {
if (withNativeArrayBuffer && typeof global.ArrayBuffer.isView === 'function') {
return global.ArrayBuffer.isView;
} else {
return function (obj) { return obj.buffer instanceof global.ArrayBuffer; };
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -14,7 +14,6 @@
"dependencies": {
"debug": "~3.1.0",
"component-emitter": "1.2.1",
"has-binary2": "~1.0.2",
"isarray": "2.0.1"
},
"devDependencies": {
Expand Down

0 comments on commit dc4f475

Please sign in to comment.