socketio/socket.io-parser

Allow hints to disable binary check

calzoneman opened this issue · 2 comments

encode uses has-binary2 to check if the given data is binary or not:

if ((obj.type === exports.EVENT || obj.type === exports.ACK) && hasBin(obj.data)) {

has-binary2 has a bunch of early exits if it does find binary data, but in the case where the input is not binary, it ends up recursively walking the entire object.

It would be nice if I could pass a flag through from socket.io to say "I already know this isn't binary, so don't even bother checking" to avoid this additional expense.

Let's do this!