mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 23:53:13 +09:00
Fixed scenario_loader
This commit is contained in:
1 parent
b7ce4a18a4
commit
82141ac9d7
3 files changed
+4
-173
No files matched your search
@@ -103,19 +103,14 @@ class AsyncArray extends Array {
|
||||
super(arr)
|
||||
this.data = arr; // In place of Array subclassing
|
||||
}
|
||||
}
|
||||
|
||||
filterAsync(predicate) {
|
||||
async filterAsync(predicate) {
|
||||
// Take a copy of the array, it might mutate by the time we've finished
|
||||
const data = Array.from(this.data);
|
||||
// Transform all the elements into an array of promises using the predicate
|
||||
// as the promise
|
||||
return Promise.all(data.map((element, index) => predicate(element, index, data)))
|
||||
// Use the result of the promises to call the underlying sync filter function
|
||||
.then(result => {
|
||||
return data.filter((element, index) => {
|
||||
return result[index];
|
||||
});
|
||||
const result = await Promise.all(data.map((element, index) => predicate(element, index, data)));
|
||||
return data.filter((element, index) => {
|
||||
return result[index];
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user