ts-data-forge
    Preparing search index...
    • Unwraps the Ok value or throws with the provided message.

      Type Parameters

      • R extends UnknownTernaryResult

      Parameters

      • result: R
      • message: string

      Returns UnwrapOk<R>

      const okValue = TernaryResult.ok('ready');

      assert.strictEqual(TernaryResult.expectToBe(okValue, 'missing'), 'ready');

      const expectResult = TernaryResult.expectToBe<string>('needs value');

      const throwTest = (): void => {
      expectResult(TernaryResult.err('oops'));
      };

      assert.throws(throwTest, /needs value/u);
    • Unwraps the Ok value or throws with the provided message.

      Type Parameters

      • S

      Parameters

      • message: string

      Returns <W, E>(result: TernaryResult<S, E, W>) => S

      const okValue = TernaryResult.ok('ready');

      assert.strictEqual(TernaryResult.expectToBe(okValue, 'missing'), 'ready');

      const expectResult = TernaryResult.expectToBe<string>('needs value');

      const throwTest = (): void => {
      expectResult(TernaryResult.err('oops'));
      };

      assert.throws(throwTest, /needs value/u);