Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
notion-desktop / usr / lib / notion-desktop / resources / app / shared / asyncThrottle.js
Size: Mime:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function asyncThrottle(fn) {
    let runningPromise;
    let queuedPromise;
    let nextArgs;
    return async (...args) => {
        if (runningPromise) {
            nextArgs = args;
            if (queuedPromise) {
                return queuedPromise;
            }
            else {
                queuedPromise = runningPromise.then(() => {
                    queuedPromise = undefined;
                    runningPromise = fn(...nextArgs);
                    return runningPromise;
                });
                return queuedPromise;
            }
        }
        else {
            runningPromise = fn(...args);
            return runningPromise;
        }
    };
}
exports.default = asyncThrottle;
//# sourceMappingURL=asyncThrottle.js.map