Skip to content

Commit dc4f475

Browse files
[revert] Move binary detection to the parser
So that we can skip the binary check.
1 parent f115039 commit dc4f475

File tree

3 files changed

+1
-7
lines changed

3 files changed

+1
-7
lines changed

index.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
var debug = require('debug')('socket.io-parser');
77
var Emitter = require('component-emitter');
8-
var hasBin = require('has-binary2');
98
var binary = require('./binary');
109
var isArray = require('isarray');
1110
var isBuf = require('./is-buffer');
@@ -125,10 +124,6 @@ function Encoder() {}
125124
*/
126125

127126
Encoder.prototype.encode = function(obj, callback){
128-
if ((obj.type === exports.EVENT || obj.type === exports.ACK) && hasBin(obj.data)) {
129-
obj.type = obj.type === exports.EVENT ? exports.BINARY_EVENT : exports.BINARY_ACK;
130-
}
131-
132127
debug('encoding packet %j', obj);
133128

134129
if (exports.BINARY_EVENT === obj.type || exports.BINARY_ACK === obj.type) {

is-buffer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var withNativeBuffer = typeof global.Buffer === 'function' && typeof global.Buff
55
var withNativeArrayBuffer = typeof global.ArrayBuffer === 'function';
66

77
var isView = (function () {
8-
if (typeof global.ArrayBuffer.isView === 'function') {
8+
if (withNativeArrayBuffer && typeof global.ArrayBuffer.isView === 'function') {
99
return global.ArrayBuffer.isView;
1010
} else {
1111
return function (obj) { return obj.buffer instanceof global.ArrayBuffer; };

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"dependencies": {
1515
"debug": "~3.1.0",
1616
"component-emitter": "1.2.1",
17-
"has-binary2": "~1.0.2",
1817
"isarray": "2.0.1"
1918
},
2019
"devDependencies": {

0 commit comments

Comments
 (0)