export async function asyncWhile( checker: (index: number) => boolean | Promise, callback: (index: number) => void | Promise ) { let index = 0; const newCallback = async () => { const checkRes = await checker(index); if (checkRes) { await callback(index); index++; await newCallback(); } }; return await newCallback(); } export async function asyncForEach( array: T[], callback: (item: T, index: number) => boolean | Promise ) { let index = 0; const newCallback = async () => { const item = array[index]; const res = await callback(item, index); if (index < array.length - 1 && res !== false) { index++; await newCallback(); } }; return await newCallback(); } export function nextTick(time = 0) { return new Promise((resolve) => { setTimeout(() => { resolve(true); }, time); }); }