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

Function fromRecord

packages/effect/src/LayerMap.ts:210–236  ·  view source on GitHub ↗
(
  layers: Layers,
  options?: {
    readonly idleTimeToLive?: Duration.DurationInput | undefined
    /**
     * Preloaded entries become idle immediately and follow the idle TTL.
     * The default idle TTL is zero, so preloading only occurs when a nonzero
     * `idleTimeToLive` is configured.
     */
    readonly preload?: Preload | undefined
  } | undefined
)

Source from the content-addressed store, hash-verified

208 * @experimental
209 */
210export const fromRecord = <
211 const Layers extends Record<string, Layer.Layer<any, any, any>>,
212 const Preload extends boolean = false
213>(
214 layers: Layers,
215 options?: {
216 readonly idleTimeToLive?: Duration.DurationInput | undefined
217 /**
218 * Preloaded entries become idle immediately and follow the idle TTL.
219 * The default idle TTL is zero, so preloading only occurs when a nonzero
220 * `idleTimeToLive` is configured.
221 */
222 readonly preload?: Preload | undefined
223 } | undefined
224): Effect.Effect<
225 LayerMap<
226 keyof Layers,
227 Layers[keyof Layers] extends Layer.Layer<infer _A, infer _E, infer _R> ? _A : never,
228 Preload extends true ? never : Layers[keyof Layers] extends Layer.Layer<infer _A, infer _E, infer _R> ? _E : never
229 >,
230 Preload extends true ? never : Layers[keyof Layers] extends Layer.Layer<infer _A, infer _E, infer _R> ? _E : never,
231 Scope.Scope | (Layers[keyof Layers] extends Layer.Layer<infer _A, infer _E, infer _R> ? _R : never)
232> =>
233 make((key: keyof Layers) => layers[key], {
234 ...options,
235 preloadKeys: options?.preload ? Object.keys(layers) : undefined
236 }) as any
237
238/**
239 * @since 3.14.0

Callers 1

ServiceFunction · 0.70

Calls 2

keysMethod · 0.80
makeFunction · 0.70

Tested by

no test coverage detected