UNPKG

@nozbe/watermelondb

Version:

Build powerful React Native and React web apps that scale from hundreds to tens of thousands of records and remain fast

10 lines (8 loc) 318 B
// @flow // Executes async action sequentially for each element in list (same as async for-of) export default function forEachAsync<T>(list: T[], action: (T) => Promise<void>): Promise<void> { return list.reduce( (promiseChain, element) => promiseChain.then(() => action(element)), Promise.resolve(), ) }