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

    Function and

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

      Type Parameters

      • U
      • E

      Parameters

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

      resB if resA is a Ok.

      Examples

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

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