refactor(cli): introduce the migration-runner helper for less code duplication and fewer return paths
Thanks to the migration-runner the "up" and "list" commands are now very similar code wise
This commit is contained in:
parent
5307e87242
commit
8cc43a8f83
9 changed files with 332 additions and 294 deletions
14
packages/cli/src/array-from-async.ts
Normal file
14
packages/cli/src/array-from-async.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* This is a simple polyfill for [Array.fromAsync()](https://github.com/tc39/proposal-array-from-async)
|
||||
*
|
||||
* It converts an async iterable to an array.
|
||||
*/
|
||||
export const arrayFromAsync = async <T>(iterable: AsyncIterable<T>): Promise<T[]> => {
|
||||
const array: T[] = [];
|
||||
|
||||
for await (const item of iterable) {
|
||||
array.push(item);
|
||||
}
|
||||
|
||||
return array;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue