From d5cd2f2922d4c379c04121a5b16b051239dac9bf Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Mon, 8 Aug 2016 01:53:07 -0700 Subject: [PATCH] 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. --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 { -- 2.34.1