Skip to content

Commit

Permalink
Fix: Add missing "typeof"
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
feross committed Aug 8, 2016
1 parent 60dd67a commit d5cd2f2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d5cd2f2

Please sign in to comment.