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');

      assert.throws(() => expectResult(TernaryResult.err('oops')), /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');

      assert.throws(() => expectResult(TernaryResult.err('oops')), /needs value/u);