export function debouncePromise(factory, delayMs) {
    let currentArgs;
    let timeout = 0;
    let resolvers = [];
    return ((...args) => {
        clearTimeout(timeout);
        currentArgs = args;
        const promise = new Promise(resolve => {
            resolvers.push(resolve);
        });
        timeout = window.setTimeout(async () => {
            const res = resolvers;
            resolvers = [];
            const result = await factory(...currentArgs);
            res.forEach(r => r(result));
        }, delayMs);
        return promise;
    });
}
//# sourceMappingURL=promise.js.map