// (C) 2026 GoodData Corporation

function delay(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

export async function retryOperation(operation, retries = 10, delayms = 1000, err = null) {
    if (retries === 0) {
        return Promise.reject(err);
    }
    await delay(delayms);
    return operation().catch((error) => {
        return retryOperation(operation, (retries - 1), delayms, error);
    });
}
