10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-27 06:43:47 +01:00
QUESTDB_website/static/js/ArrayExtensions.js

18 lines
434 B
JavaScript
Raw Normal View History

if (!Array.prototype.findAsync) {
Array.prototype.findAsync = async function (asyncCallback) {
for (const item of this) {
if (await asyncCallback(item)) {
return item
}
}
}
2020-09-24 16:56:51 +02:00
if (!Array.prototype.findAllIndexes) {
Array.prototype.findAllIndexes = function (Callback) {
2020-09-24 18:38:45 +02:00
return this.reduce(function(a, e, i) {
2020-09-24 16:56:51 +02:00
if (Callback(e))
a.push(i)
return a
}, [])
}
}
}