INNER CODE UNIT · TypeScript

executeAndHandle

VincentJouanne/nest-clean-architecture · common/utils/executeTask.ts:25

export const executeAndHandle = async <E, A, B>(task: TaskEither<E, A>, onLeft: (error: E) => B, onRight: (data: A) => B): Promise<B> => {
  const result = await task();
  return pipe(result, Either.fold<E, A, B>(onLeft, onRight));
};

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…