mirror of
https://github.com/vatesfr/xen-orchestra.git
synced 2026-09-10 22:14:48 -05:00
fix(async-map): allow return type to be different than input type (#10227)
This commit is contained in:
@@ -13,11 +13,11 @@ const wrapCall = (fn, arg, thisArg) => {
|
||||
*
|
||||
* WARNING: Does not handle plain objects
|
||||
*
|
||||
* @template Item,This
|
||||
* @template Item, Result, [This=Iterable<Item>]
|
||||
* @param {Iterable<Item>} iterable
|
||||
* @param {(this: This, item: Item) => (Item | PromiseLike<Item>)} mapFn
|
||||
* @param {This} [thisArg]
|
||||
* @returns {Promise<Item[]>}
|
||||
* @param {(this: This, item: Item) => (Result | PromiseLike<Result>)} mapFn
|
||||
* @param {This} [thisArg] defaults to `iterable`
|
||||
* @returns {Promise<Result[]>}
|
||||
*/
|
||||
exports.asyncMap = function asyncMap(iterable, mapFn, thisArg = iterable) {
|
||||
return Promise.all(Array.from(iterable, mapFn, thisArg))
|
||||
@@ -26,11 +26,11 @@ exports.asyncMap = function asyncMap(iterable, mapFn, thisArg = iterable) {
|
||||
/**
|
||||
* Like `asyncMap` but wait for all promises to settle before rejecting
|
||||
*
|
||||
* @template Item,This
|
||||
* @template Item, Result, [This=Iterable<Item>]
|
||||
* @param {Iterable<Item>} iterable
|
||||
* @param {(this: This, item: Item) => (Item | PromiseLike<Item>)} mapFn
|
||||
* @param {This} [thisArg]
|
||||
* @returns {Promise<Item[]>}
|
||||
* @param {(this: This, item: Item) => (Result | PromiseLike<Result>)} mapFn
|
||||
* @param {This} [thisArg] defaults to `iterable`
|
||||
* @returns {Promise<Result[]>}
|
||||
*/
|
||||
exports.asyncMapSettled = function asyncMapSettled(iterable, mapFn, thisArg = iterable) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
<!--packages-start-->
|
||||
|
||||
- @xen-orchestra/acl minor
|
||||
- @xen-orchestra/async-map patch
|
||||
- @xen-orchestra/proxy-cli patch
|
||||
- @xen-orchestra/rest-api minor
|
||||
- @xen-orchestra/upload-ova patch
|
||||
|
||||
Reference in New Issue
Block a user