From: Feross Aboukhadijeh Date: Mon, 8 Aug 2016 08:53:07 +0000 (-0700) Subject: Fix: Add missing "typeof" X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=d5cd2f2922d4c379c04121a5b16b051239dac9bf;p=buffer.git Fix: Add missing "typeof" Without this, we never go down the faster native indexOf code-path. So this wasn't causing bugs in user code, it was just probably slower than necessary. --- diff --git a/index.js b/index.js index dfac15a..b870886 100644 --- a/index.js +++ b/index.js @@ -698,7 +698,8 @@ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { return arrayIndexOf(buffer, val, byteOffset, encoding, dir) } else if (typeof val === 'number') { val = val & 0xFF // Search for a byte value [0-255] - if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') { + if (Buffer.TYPED_ARRAY_SUPPORT && + typeof Uint8Array.prototype.indexOf === 'function') { if (dir) { return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) } else {