@inst/vscode-bin-darwin
Version:
BINARY ONLY - VSCode binary deployment for macOS
64 lines (63 loc) • 2.25 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
class Delayer {
constructor(defaultDelay) {
this.defaultDelay = defaultDelay;
this.timeout = null;
this.completionPromise = null;
this.onSuccess = null;
this.task = null;
}
trigger(task, delay = this.defaultDelay) {
this.task = task;
if (delay >= 0) {
this.cancelTimeout();
}
if (!this.completionPromise) {
this.completionPromise = new Promise((resolve) => {
this.onSuccess = resolve;
}).then(() => {
this.completionPromise = null;
this.onSuccess = null;
var result = this.task();
this.task = null;
return result;
});
}
if (delay >= 0 || this.timeout === null) {
this.timeout = setTimeout(() => {
this.timeout = null;
this.onSuccess(null);
}, delay >= 0 ? delay : this.defaultDelay);
}
return this.completionPromise;
}
forceDelivery() {
if (!this.completionPromise) {
return null;
}
this.cancelTimeout();
let result = this.completionPromise;
this.onSuccess(null);
return result;
}
isTriggered() {
return this.timeout !== null;
}
cancel() {
this.cancelTimeout();
this.completionPromise = null;
}
cancelTimeout() {
if (this.timeout !== null) {
clearTimeout(this.timeout);
this.timeout = null;
}
}
}
exports.Delayer = Delayer;
//# sourceMappingURL=https://ticino.blob.core.windows.net/sourcemaps/b813d12980308015bcd2b3a2f6efa5c810c33ba5/extensions/merge-conflict/out/delayer.js.map