MCPcopy Create free account
hub / github.com/Effect-TS/effect / flattenCauseLoop

Function flattenCauseLoop

packages/effect/src/internal/cause.ts:481–510  ·  view source on GitHub ↗
(
  causes: Chunk.Chunk<Cause.Cause<unknown>>,
  flattened: Chunk.Chunk<HashSet.HashSet<unknown>>
)

Source from the content-addressed store, hash-verified

479
480/** @internal */
481const flattenCauseLoop = (
482 causes: Chunk.Chunk<Cause.Cause<unknown>>,
483 flattened: Chunk.Chunk<HashSet.HashSet<unknown>>
484): Chunk.Chunk<HashSet.HashSet<unknown>> => {
485 // eslint-disable-next-line no-constant-condition
486 while (1) {
487 const [parallel, sequential] = pipe(
488 causes,
489 Arr.reduce(
490 [HashSet.empty<unknown>(), Chunk.empty<Cause.Cause<unknown>>()] as const,
491 ([parallel, sequential], cause) => {
492 const [par, seq] = evaluateCause(cause)
493 return [
494 pipe(parallel, HashSet.union(par)),
495 pipe(sequential, Chunk.appendAll(seq))
496 ]
497 }
498 )
499 )
500 const updated = HashSet.size(parallel) > 0 ?
501 pipe(flattened, Chunk.prepend(parallel)) :
502 flattened
503 if (Chunk.isEmpty(sequential)) {
504 return Chunk.reverse(updated)
505 }
506 causes = sequential
507 flattened = updated
508 }
509 throw new Error(getBugErrorMessage("Cause.flattenCauseLoop"))
510}
511
512// -----------------------------------------------------------------------------
513// Finding

Callers 1

flattenCauseFunction · 0.85

Calls 5

evaluateCauseFunction · 0.85
getBugErrorMessageFunction · 0.85
pipeFunction · 0.70
sizeMethod · 0.65
isEmptyMethod · 0.65

Tested by

no test coverage detected