@mikuroxina/mini-fn
    Preparing search index...

    Function or

    • Returns resB if resA is an Err, otherwise returns the success resA. The order of arguments is reversed because of that it is useful for partial applying.

      Type Parameters

      • E
      • T

      Parameters

      Returns <F>(resA: Result.Result<F, T>) => Result.Result<E, T>

      resA or resB.

      Examples

      const success = ok<number>(2);
      const failure = err<string>("not a 2");
      const lateError = err<string>("late error");
      const earlyError = err<string>("early error");
      const anotherSuccess = ok<number>(100);

      expect(or<string, number>(lateError)(success)).toStrictEqual(success);
      expect(or<string, number>(success)(earlyError)).toStrictEqual(success);
      expect(or(lateError)(failure)).toStrictEqual(lateError);
      expect(or(anotherSuccess)(success)).toStrictEqual(success);