doddle
    Preparing search index...

    Function doddle

    • Creates a Doddle lazy primitive around a given function. Supports both sync and async initializers and flattens nested Doddle or Promise types.

      See examples for usage.

      Type Parameters

      • X

      Parameters

      • initializer: () => PromiseLike<DoddleAsync<X>>

        An initializer that will be called once to produce the value.

      Returns DoddleAsync<X>

      // Simple initializer:
      const regular = doddle(() => 1) satisfies Doddle<number>

      // Initializer returning another lazily primitive is flattened:
      const lazyNested = doddle(() => doddle(() => 1)) satisfies Doddle<number>

      // Async initializer gives a `DoddleAsync` instance:
      const lazyAsync = doddle(async () => 1) satisfies DoddleAsync<number>

      // Async initializer returning another lazily primitive is flattened:
      const asyncDoddle = doddle(async () => doddle(() => 1)) satisfies DoddleAsync<number>

      // Async initializer returning another lazily async primitive is flattened:
      const asyncDoddleAsync = doddle(async () =>
      doddle(async () => 1)
      ) satisfies DoddleAsync<number>
    • Creates a Doddle lazy primitive around a given function. Supports both sync and async initializers and flattens nested Doddle or Promise types.

      See examples for usage.

      Type Parameters

      • X

      Parameters

      • initializer: () => PromiseLike<Doddle<X>>

        An initializer that will be called once to produce the value.

      Returns DoddleAsync<X>

      // Simple initializer:
      const regular = doddle(() => 1) satisfies Doddle<number>

      // Initializer returning another lazily primitive is flattened:
      const lazyNested = doddle(() => doddle(() => 1)) satisfies Doddle<number>

      // Async initializer gives a `DoddleAsync` instance:
      const lazyAsync = doddle(async () => 1) satisfies DoddleAsync<number>

      // Async initializer returning another lazily primitive is flattened:
      const asyncDoddle = doddle(async () => doddle(() => 1)) satisfies DoddleAsync<number>

      // Async initializer returning another lazily async primitive is flattened:
      const asyncDoddleAsync = doddle(async () =>
      doddle(async () => 1)
      ) satisfies DoddleAsync<number>
    • Creates a Doddle lazy primitive around a given function. Supports both sync and async initializers and flattens nested Doddle or Promise types.

      See examples for usage.

      Type Parameters

      • X

      Parameters

      • initializer: () => PromiseLike<X>

        An initializer that will be called once to produce the value.

      Returns DoddleAsync<X>

      // Simple initializer:
      const regular = doddle(() => 1) satisfies Doddle<number>

      // Initializer returning another lazily primitive is flattened:
      const lazyNested = doddle(() => doddle(() => 1)) satisfies Doddle<number>

      // Async initializer gives a `DoddleAsync` instance:
      const lazyAsync = doddle(async () => 1) satisfies DoddleAsync<number>

      // Async initializer returning another lazily primitive is flattened:
      const asyncDoddle = doddle(async () => doddle(() => 1)) satisfies DoddleAsync<number>

      // Async initializer returning another lazily async primitive is flattened:
      const asyncDoddleAsync = doddle(async () =>
      doddle(async () => 1)
      ) satisfies DoddleAsync<number>
    • Creates a Doddle lazy primitive around a given function. Supports both sync and async initializers and flattens nested Doddle or Promise types.

      See examples for usage.

      Type Parameters

      • T

      Parameters

      • initializer: () => Doddle<T>

        An initializer that will be called once to produce the value.

      Returns Doddle<T>

      // Simple initializer:
      const regular = doddle(() => 1) satisfies Doddle<number>

      // Initializer returning another lazily primitive is flattened:
      const lazyNested = doddle(() => doddle(() => 1)) satisfies Doddle<number>

      // Async initializer gives a `DoddleAsync` instance:
      const lazyAsync = doddle(async () => 1) satisfies DoddleAsync<number>

      // Async initializer returning another lazily primitive is flattened:
      const asyncDoddle = doddle(async () => doddle(() => 1)) satisfies DoddleAsync<number>

      // Async initializer returning another lazily async primitive is flattened:
      const asyncDoddleAsync = doddle(async () =>
      doddle(async () => 1)
      ) satisfies DoddleAsync<number>
    • Creates a Doddle lazy primitive around a given function. Supports both sync and async initializers and flattens nested Doddle or Promise types.

      See examples for usage.

      Type Parameters

      • T

      Parameters

      • initializer: () => T | Doddle<T>

        An initializer that will be called once to produce the value.

      Returns Doddle<T>

      // Simple initializer:
      const regular = doddle(() => 1) satisfies Doddle<number>

      // Initializer returning another lazily primitive is flattened:
      const lazyNested = doddle(() => doddle(() => 1)) satisfies Doddle<number>

      // Async initializer gives a `DoddleAsync` instance:
      const lazyAsync = doddle(async () => 1) satisfies DoddleAsync<number>

      // Async initializer returning another lazily primitive is flattened:
      const asyncDoddle = doddle(async () => doddle(() => 1)) satisfies DoddleAsync<number>

      // Async initializer returning another lazily async primitive is flattened:
      const asyncDoddleAsync = doddle(async () =>
      doddle(async () => 1)
      ) satisfies DoddleAsync<number>