* Produces a new array of values by mapping each value in list through a transformation function `iteratee()`. * Each invocation of `iteratee()` is called with two arguments: `(element, index)`. * * If `iteratee` returns a `Promise` then it's awaited before a next call. * *
(iteratee: DatasetMapper<Data, R>, options: DatasetIteratorOptions = {})
| 512 | * @param [options] All `map()` parameters. |
| 513 | */ |
| 514 | async map<R>(iteratee: DatasetMapper<Data, R>, options: DatasetIteratorOptions = {}): Promise<R[]> { |
| 515 | checkStorageAccess(); |
| 516 | |
| 517 | const result: R[] = []; |
| 518 | |
| 519 | await this.forEach(async (item, index) => { |
| 520 | const res = await iteratee(item, index); |
| 521 | result.push(res); |
| 522 | }, options); |
| 523 | |
| 524 | return result; |
| 525 | } |
| 526 | |
| 527 | /** |
| 528 | * Reduces a list of values down to a single value. |