From dc4f475a452f28fd6fd2ecfecf869c133bf0978d Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Wed, 28 Feb 2018 21:51:03 +0100 Subject: [PATCH] [revert] Move binary detection to the parser So that we can skip the binary check. --- index.js | 5 ----- is-buffer.js | 2 +- package.json | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/index.js b/index.js index f71ff27..90f9d3c 100644 --- a/index.js +++ b/index.js @@ -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'); @@ -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) { diff --git a/is-buffer.js b/is-buffer.js index be23951..9f451a4 100644 --- a/is-buffer.js +++ b/is-buffer.js @@ -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; }; diff --git a/package.json b/package.json index bec32d4..5976fca 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "dependencies": { "debug": "~3.1.0", "component-emitter": "1.2.1", - "has-binary2": "~1.0.2", "isarray": "2.0.1" }, "devDependencies": {