mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 00:55:25 -05:00
a4a5a08c31
[web] Add Remove from group action in dropdown for unmanaged/pending users GitOrigin-RevId: daa66598e42befa2f8430bdf118e907a8758d60e
16 lines
570 B
JavaScript
16 lines
570 B
JavaScript
/**
|
|
* run `fn` in serie for all values, and resolve with an array of the results
|
|
* inspired by https://stackoverflow.com/a/50506360/1314820
|
|
* @template T the input array's item type
|
|
* @template V the `fn` function's return type
|
|
* @param {T[]} values
|
|
* @param {(item: T) => Promise<V>} fn
|
|
* @returns {V[]}
|
|
*/
|
|
export function mapSeries(values, fn) {
|
|
return values.reduce(async (promiseChain, value) => {
|
|
const chainResults = await promiseChain
|
|
const currentResult = await fn(value)
|
|
return [...chainResults, currentResult]
|
|
}, Promise.resolve([]))
|
|
}
|