MCPcopy Create free account
hub / github.com/effect-app/libs / CauseImpl

Class CauseImpl

repos/effect/packages/effect/src/internal/core.ts:137–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135export const isCauseReason = (self: unknown): self is Cause.Reason<unknown> => hasProperty(self, CauseReasonTypeId)
136
137/** @internal */
138export class CauseImpl<E> implements Cause.Cause<E> {
139 readonly [CauseTypeId]: typeof CauseTypeId
140 readonly reasons: ReadonlyArray<
141 Cause.Fail<E> | Cause.Die | Cause.Interrupt
142 >
143 constructor(
144 failures: ReadonlyArray<
145 Cause.Fail<E> | Cause.Die | Cause.Interrupt
146 >
147 ) {
148 this[CauseTypeId] = CauseTypeId
149 this.reasons = failures
150 }
151 pipe() {
152 return pipeArguments(this, arguments)
153 }
154 toJSON(): unknown {
155 return {
156 _id: "Cause",
157 failures: this.reasons.map((f) => f.toJSON())
158 }
159 }
160 toString() {
161 return `Cause(${format(this.reasons)})`
162 }
163 [NodeInspectSymbol]() {
164 return this.toJSON()
165 }
166 [Equal.symbol](that: any): boolean {
167 return (
168 isCause(that) &&
169 this.reasons.length === that.reasons.length &&
170 this.reasons.every((e, i) => Equal.equals(e, that.reasons[i]))
171 )
172 }
173 [Hash.symbol](): number {
174 return Hash.array(this.reasons)
175 }
176}
177
178const annotationsMap = new WeakMap<object, ReadonlyMap<string, unknown>>()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…