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

    Function isPendingOption

    • Checks if a value is a PendingOption, narrowing its type to PendingOption<unknown>.

      This type guard verifies whether the input is a PendingOption, indicating it wraps a Promise resolving to an Option (either Some or None).

      Parameters

      • x: unknown

        The value to check.

      Returns x is PendingOption<unknown>

      true if the value is a PendingOption, narrowing to PendingOption<unknown>.

      const x = pendingOption(some(42));
      const y = pendingOption(none<number>());
      const z = some(42); // Not a PendingOption

      expect(isPendingOption(x)).toBe(true);
      expect(isPendingOption(y)).toBe(true);
      expect(isPendingOption(z)).toBe(false);

      if (isPendingOption(x)) {
      expect(await x).toStrictEqual(some(42)); // Type narrowed to PendingOption<unknown>
      }