ilp-protocol-stream
Version:
Interledger Transport Protocol for sending multiple streams of money and data over ILP.
27 lines • 759 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StoppableTimeout = void 0;
class StoppableTimeout {
constructor() {
this.stopped = false;
}
wait(delay) {
if (this.stopped) {
return Promise.reject(new Error('timer stopped'));
}
return new Promise((resolve, reject) => {
this.timer = setTimeout(resolve, delay);
this.reject = reject;
});
}
stop() {
if (this.timer)
clearTimeout(this.timer);
this.stopped = true;
if (this.reject) {
this.reject(new Error('timer stopped'));
}
}
}
exports.StoppableTimeout = StoppableTimeout;
//# sourceMappingURL=stoppable-timeout.js.map