// (C) 2007-2022 GoodData Corporation
function partial(fn, ...others) {
    return (...args) => {
        return fn.apply(null, [...others, ...args]);
    };
}

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

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);
    });
}

module.exports = {
    partial,
    retryOperation
};
