@ts-rust/std - v0.0.5
    Preparing search index...

    Function pendingOption

    • Creates a PendingOption<T> from an option, promise, or factory function.

      Accepts an Option, a Promise resolving to an Option, or a function returning either, and converts it into a pending option, handling asynchronous resolution as needed.

      Type Parameters

      • T

        The type of the value in the option.

      Parameters

      Returns PendingOption<T>

      A PendingOption resolving to the provided or produced option.

      const x = pendingOption(some(42));
      const y = pendingOption(() => Promise.resolve(none<string>()));
      const z = pendingOption(async () => some("thing"));

      expect(await x).toStrictEqual(some(42));
      expect(await y).toStrictEqual(none());
      expect(await z).toStrictEqual(some("thing"));