main.js 605 B

1234567891011121314151617181920212223242526
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.Lazy = void 0;
  4. class Lazy {
  5. constructor(creator) {
  6. this._value = null;
  7. this.creator = creator;
  8. }
  9. get hasValue() {
  10. return this.creator == null;
  11. }
  12. get value() {
  13. if (this.creator == null) {
  14. return this._value;
  15. }
  16. const result = this.creator();
  17. this.value = result;
  18. return result;
  19. }
  20. set value(value) {
  21. this._value = value;
  22. this.creator = null;
  23. }
  24. }
  25. exports.Lazy = Lazy;
  26. //# sourceMappingURL=main.js.map