import * as O from 'fp-ts/Option';
export class Lazy {
  constructor(factory) {
    this.factory = factory;
    this._value = O.none;
  }
  get value() {
    if (O.isSome(this._value)) {
      return this._value.value;
    }
    const lazyValue = this.factory();
    this._value = O.some(lazyValue);
    return lazyValue;
  }
}
export class AsyncLazy {
  constructor(factory) {
    this.factory = factory;
    this._value = O.none;
  }
  async getValueAsync() {
    if (O.isSome(this._value)) {
      return this._value.value;
    }
    const lazyValue = await this.factory();
    this._value = O.some(lazyValue);
    return lazyValue;
  }
}
