-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: replace indexOf with typedArrayIndexOf for IE11 support #417
Conversation
// IE11 doesn't support indexOf for TypedArrays. | ||
// Once IE11 support is dropped, this function should be removed. | ||
var typedArrayIndexOf = (typedArray, element, fromIndex) => { | ||
if (!typedArray) { | ||
return -1; | ||
} | ||
|
||
var currentIndex = fromIndex; | ||
|
||
for (; currentIndex < typedArray.length; currentIndex++) { | ||
if (typedArray[currentIndex] === element) { | ||
return currentIndex; | ||
} | ||
} | ||
|
||
return -1; | ||
}; | ||
|
||
module.exports = { typedArrayIndexOf }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function does not support negative fromIndex
whereas indexOf
does. Let's hope nobody uses it that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gesinger You could also replace for loop with typedArrayIndexOf
for PRIV
frames.
I didn't change PRIV for now because the behavior is slightly different, in that it takes a subarray of the typed array from a non-existent area in the event that 0 is not found. Although the behavior is not great, I didn't want to potentially break anything and the logic becomes a bit more complex with |
No description provided.