Update index.html
This commit is contained in:
parent
4d0df33005
commit
7dfb1135fc
14
index.html
14
index.html
@ -1217,17 +1217,11 @@ function Library (client) {
|
|||||||
fn(arg, i)
|
fn(arg, i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.map = (arr, fn) => { // Run a function on each element in a list.
|
this.map = (arr, fn) => { // Returns a new list with fn applied to each value.
|
||||||
return Promise.all(arr.map(fn)).then(result => { return result })
|
return arr.map(fn);
|
||||||
}
|
}
|
||||||
this.filter = (arr, fn) => { // Remove from list, when function returns false.
|
this.filter = (arr, fn) => { // Returns a new list, without values evaluated to false by fn.
|
||||||
const list = Array.from(arr)
|
return arr.filter(fn);
|
||||||
return Promise.all(list.map((element, index) => fn(element, index, list)))
|
|
||||||
.then(result => {
|
|
||||||
return list.filter((_, index) => {
|
|
||||||
return result[index]
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
this.reduce = (arr, fn, acc) => {
|
this.reduce = (arr, fn, acc) => {
|
||||||
const length = arr.length
|
const length = arr.length
|
||||||
|
Loading…
x
Reference in New Issue
Block a user