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

Function fromFunction

packages/effect/src/RequestResolver.ts:348–359  ·  view source on GitHub ↗
(
  f: (entry: Request.Entry<A>) => Request.Success<A>
)

Source from the content-addressed store, hash-verified

346 * @since 2.0.0
347 */
348export const fromFunction = <A extends Request.Any>(
349 f: (entry: Request.Entry<A>) => Request.Success<A>
350): RequestResolver<A> =>
351 make(
352 (entries) =>
353 Effect.sync(() => {
354 for (let i = 0; i < entries.length; i++) {
355 const entry = entries[i]
356 entry.completeUnsafe(exitSucceed(f(entry)))
357 }
358 })
359 )
360
361/**
362 * Constructs a request resolver from a pure function that takes a list of requests

Callers

nothing calls this directly

Calls 4

completeUnsafeMethod · 0.80
makeFunction · 0.70
fFunction · 0.50
syncMethod · 0.45

Tested by

no test coverage detected