'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = SettableDisposable; /** @license MIT License (c) copyright 2010-2016 original author or authors */ /** @author Brian Cavalier */ /** @author John Hann */ function SettableDisposable() { this.disposable = void 0; this.disposed = false; this._resolve = void 0; var self = this; this.result = new Promise(function (resolve) { self._resolve = resolve; }); } SettableDisposable.prototype.setDisposable = function (disposable) { if (this.disposable !== void 0) { throw new Error('setDisposable called more than once'); } this.disposable = disposable; if (this.disposed) { this._resolve(disposable.dispose()); } }; SettableDisposable.prototype.dispose = function () { if (this.disposed) { return this.result; } this.disposed = true; if (this.disposable !== void 0) { this.result = this.disposable.dispose(); } return this.result; };