UNPKG

wdio-wait-for

Version:

a library of conditions that are useful for end-to-end tests

16 lines (15 loc) 410 B
export function logicalChain(defaultRet, fns) { return async () => { if (fns.length === 0) { return defaultRet; } const [fn] = fns; return fn().then((bool) => { if (bool === defaultRet) { // @ts-ignore return logicalChain(defaultRet, fns.slice(1))(); } return !defaultRet; }); }; }