Created
March 3, 2021 16:47
-
-
Save wayneseymour/d31f108495a7226344d08f1c324fffee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ToolingLog } from '@kbn/dev-utils'; | |
import { SuperTest } from 'supertest'; | |
// @ts-ignore | |
import * as Either from '../../../../src/dev/code_coverage/ingest_coverage/either'; | |
const id = (x: any = null) => x; | |
const recurseEither = (max: number) => (x: number) => | |
max > x ? Either.right(x) : Either.left(x); | |
export const recurseList = (f: any) => (log: ToolingLog) => (supertest: SuperTest<any>) => async ( | |
names: any, | |
i: number = 1 | |
) => { | |
const appName = names[i - 1]; | |
await f()(log)(supertest)(appName); | |
recurseEither(names.length)(i) // Recurses only when names.length is less than i | |
.fold(id, async () => { | |
i++; | |
await recurseList(f)(log)(supertest)(names, i); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment