ts-data-forge
    Preparing search index...
    • Combines two Result values into a single Result containing a tuple. If either Result is Err, returns the first Err encountered.

      Type Parameters

      • S1

        The success type of the first Result.

      • E1

        The error type of the first Result.

      • S2

        The success type of the second Result.

      • E2

        The error type of the second Result.

      Parameters

      • resultA: Result<S1, E1>

        The first Result.

      • resultB: Result<S2, E2>

        The second Result.

      Returns Result<readonly [S1, S2], E1 | E2>

      A Result containing a tuple of both values, or the first Err.

      const first = Result.ok('left');

      const second = Result.ok(1);

      const expected = ['left', 1] as const;

      assert.deepStrictEqual(Result.zip(first, second), Result.ok(expected));

      assert.deepStrictEqual(
      Result.zip(first, Result.err('error')),
      Result.err('error'),
      );