@allynet/ishod
    Preparing search index...

    Function tap

    • Tap into a result.

      If the result is an Ok, the function will be called with the data the result contains.

      Otherwise nothing will happen.

      It will not modify the result, and just return the original result.

      Type Parameters

      • T
      • E

      Parameters

      Returns Promise<Result<T, E>>

      const result: Result<number, string> = ok(1);
      const value = tap(result, (data) => {
      console.log(data);
      });
      // `1` gets logged by the callback;
      result === value; // true
      const result: Result<number, string> = err("error");
      const value = tap(result, (data) => {
      console.log(data);
      });
      // Nothing gets logged by the callback;
      result === value; // true
    • Tap into a result.

      If the result is an Ok, the function will be called with the data the result contains.

      Otherwise nothing will happen.

      It will not modify the result, and just return the original result.

      Type Parameters

      • T
      • E

      Parameters

      Returns Result<T, E>

      const result: Result<number, string> = ok(1);
      const value = tap(result, (data) => {
      console.log(data);
      });
      // `1` gets logged by the callback;
      result === value; // true
      const result: Result<number, string> = err("error");
      const value = tap(result, (data) => {
      console.log(data);
      });
      // Nothing gets logged by the callback;
      result === value; // true