ts-data-forge
    Preparing search index...
    • Checks if an Optional is Some. Acts as a type guard.

      Type Parameters

      • O extends UnknownOptional

        The UnknownOptional type to check.

      Parameters

      • optional: O

        The Optional to check.

      Returns optional is NarrowToSome<O>

      true if the Optional is Some, false otherwise.

      const optionalNumber = Optional.some(42);

      if (Optional.isSome(optionalNumber)) {
      const value: number = optionalNumber.value;

      assert.isTrue(value === 42);
      }