expiring-value.js
1 "use strict"; 2 Object.defineProperty(exports, "__esModule", { value: true }); 3 exports.ExpiringValue = void 0; 4 /** 5 * A class that wraps some value that expires in some future time. 6 */ 7 class ExpiringValue { 8 constructor(value, maxAge) { 9 this._value = value; 10 this._maxAge = maxAge; 11 } 12 /// Whether or not value is valid (not expired). 13 isValid() { 14 return Date.now() < this._maxAge; 15 } 16 /** Access the expiring value, returning null if it is expired. */ 17 get value() { 18 return this.isValid() ? this._value : null; 19 } 20 } 21 exports.ExpiringValue = ExpiringValue; 22 //# sourceMappingURL=expiring-value.js.map