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

Function make

packages/effect/src/ExecutionPlan.ts:169–199  ·  view source on GitHub ↗
(
  ...steps: Steps & { [K in keyof Steps]: make.Step }
)

Source from the content-addressed store, hash-verified

167 * @since 3.16.0
168 */
169export const make = <const Steps extends NonEmptyReadonlyArray<make.Step>>(
170 ...steps: Steps & { [K in keyof Steps]: make.Step }
171): ExecutionPlan<{
172 provides: make.StepProvides<Steps>
173 input: make.StepInput<Steps>
174 error:
175 | (Steps[number]["provide"] extends Context.Context<infer _P> | Layer.Layer<infer _P, infer E, infer _R> ? E
176 : never)
177 | (Steps[number]["while"] extends (input: infer _I) => Effect.Effect<infer _A, infer _E, infer _R> ? _E : never)
178 requirements:
179 | (Steps[number]["provide"] extends Layer.Layer<infer _A, infer _E, infer R> ? R : never)
180 | (Steps[number]["while"] extends (input: infer _I) => Effect.Effect<infer _A, infer _E, infer R> ? R : never)
181 | (Steps[number]["schedule"] extends Schedule.Schedule<infer _O, infer _I, infer R> ? R : never)
182}> =>
183 makeProto(steps.map((options, i) => {
184 if (options.attempts !== undefined && options.attempts < 1) {
185 throw new Error(`ExecutionPlan.make: step[${i}].attempts must be greater than 0`)
186 }
187 return {
188 schedule: options.schedule,
189 attempts: options.attempts,
190 while: options.while
191 ? (input: any) =>
192 effect.suspend(() => {
193 const result = options.while!(input)
194 return typeof result === "boolean" ? effect.succeed(result) : result
195 })
196 : undefined,
197 provide: options.provide
198 }
199 }) as any)
200
201/**
202 * Namespace containing type helpers used by `ExecutionPlan.make`.

Callers

nothing calls this directly

Calls 3

makeProtoFunction · 0.70
mapMethod · 0.45
succeedMethod · 0.45

Tested by

no test coverage detected