@uppy/utils: remove ponyfill for Array#findIndex (#3080)

The built-in method is supported everywhere.
This commit is contained in:
Antoine du Hamel 2021-08-06 12:05:05 +02:00
parent 2c1287fc52
commit 9866fc1f5c
3 changed files with 3 additions and 12 deletions

View file

@ -112,7 +112,7 @@ module.exports = class ProviderView {
let updatedDirectories
const state = this.plugin.getPluginState()
const index = findIndex(state.directories, (dir) => id === dir.id)
const index = state.directories.findIndex((dir) => id === dir.id)
if (index !== -1) {
updatedDirectories = state.directories.slice(0, index + 1)

View file

@ -1,5 +1,3 @@
const findIndex = require('./findIndex')
function createCancelError () {
return new Error('Cancelled')
}
@ -84,7 +82,7 @@ class RateLimitedQueue {
},
}
const index = findIndex(this.#queuedHandlers, (other) => {
const index = this.#queuedHandlers.findIndex((other) => {
return handler.priority > other.priority
})
if (index === -1) {

View file

@ -1,13 +1,6 @@
/**
* Array.prototype.findIndex ponyfill for old browsers.
*
* @param {Array} array
* @param {Function} predicate
* @returns {number}
*/
module.exports = function findIndex (array, predicate) {
for (let i = 0; i < array.length; i++) {
if (predicate(array[i])) return i
}
return -1
}
module.exports = Function.prototype.call.bind(Array.prototype.findIndex)