MCPcopy Create free account
hub / github.com/contentlayerdev/contentlayer / foldM_

Function foldM_

packages/@contentlayer/utils/src/effect/These.ts:35–49  ·  view source on GitHub ↗
(
  self: These<E, A>,
  onSuccess: (a: A) => These<E1, A1>,
  onBoth: (a: A, e: E) => These<E2, A2>,
  onFail: (e: E) => These<E3, A3>,
)

Source from the content-addressed store, hash-verified

33export const isNonFailure = <E, A>(self: These<E, A>): self is These<never, A> => E.isRight(self.either)
34
35export function foldM_<E, A, E1, A1, E2, A2, E3, A3>(
36 self: These<E, A>,
37 onSuccess: (a: A) => These<E1, A1>,
38 onBoth: (a: A, e: E) => These<E2, A2>,
39 onFail: (e: E) => These<E3, A3>,
40): These<E1 | E2 | E3, A1 | A2 | A3> {
41 return new These(
42 E.fold_(
43 self.either,
44 (x): E.Either<E1 | E2 | E3, Tp.Tuple<[A1 | A2 | A3, O.Option<E1 | E2 | E3>]>> => onFail(x).either,
45 ({ tuple: [result, warnings] }) =>
46 warnings._tag === 'None' ? onSuccess(result).either : onBoth(result, warnings.value).either,
47 ),
48 )
49}
50
51export function foldM<E, A, E1, A1, E2, A2, E3, A3>(
52 onSuccess: (a: A) => These<E1, A1>,

Callers 4

foldMFunction · 0.85
map_Function · 0.85
mapError_Function · 0.85
chain_Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…