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

Function fromFlatLoop

packages/effect/src/internal/configProvider.ts:251–458  ·  view source on GitHub ↗
(
  flat: ConfigProvider.ConfigProvider.Flat,
  prefix: ReadonlyArray<string>,
  config: Config.Config<A>,
  split: boolean
)

Source from the content-addressed store, hash-verified

249 configError.reduceWithContext(error, void 0, RedactedConfigErrorReducer)
250
251const fromFlatLoop = <A>(
252 flat: ConfigProvider.ConfigProvider.Flat,
253 prefix: ReadonlyArray<string>,
254 config: Config.Config<A>,
255 split: boolean
256): Effect.Effect<Array<A>, ConfigError.ConfigError> => {
257 const op = config as _config.ConfigPrimitive
258 switch (op._tag) {
259 case OpCodes.OP_CONSTANT: {
260 return core.succeed(Arr.of(op.value)) as Effect.Effect<Array<A>, ConfigError.ConfigError>
261 }
262 case OpCodes.OP_DESCRIBED: {
263 return core.suspend(
264 () => fromFlatLoop(flat, prefix, op.config, split)
265 ) as unknown as Effect.Effect<Array<A>, ConfigError.ConfigError>
266 }
267 case OpCodes.OP_FAIL: {
268 return core.fail(configError.MissingData(prefix, op.message)) as Effect.Effect<
269 Array<A>,
270 ConfigError.ConfigError
271 >
272 }
273 case OpCodes.OP_FALLBACK: {
274 return pipe(
275 core.suspend(() => fromFlatLoop(flat, prefix, op.first, split)),
276 core.catchAll((error1) => {
277 if (op.condition(error1)) {
278 return pipe(
279 fromFlatLoop(flat, prefix, op.second, split),
280 core.catchAll((error2) => core.fail(configError.Or(error1, error2)))
281 )
282 }
283 return core.fail(error1)
284 })
285 ) as unknown as Effect.Effect<Array<A>, ConfigError.ConfigError>
286 }
287 case OpCodes.OP_LAZY: {
288 return core.suspend(() => fromFlatLoop(flat, prefix, op.config(), split)) as Effect.Effect<
289 Array<A>,
290 ConfigError.ConfigError
291 >
292 }
293 case OpCodes.OP_MAP_OR_FAIL: {
294 return core.suspend(() =>
295 pipe(
296 fromFlatLoop(flat, prefix, op.original, split),
297 core.flatMap(
298 core.forEachSequential((a) =>
299 pipe(
300 op.mapOrFail(a),
301 core.mapError(configError.prefixed(appendConfigPath(prefix, op.original)))
302 )
303 )
304 )
305 )
306 ) as unknown as Effect.Effect<Array<A>, ConfigError.ConfigError>
307 }
308 case OpCodes.OP_NESTED: {

Callers 1

fromFlatFunction · 0.85

Calls 15

appendConfigPathFunction · 0.85
transposeFunction · 0.85
fromFlatLoopFailFunction · 0.85
lastMethod · 0.80
enumerateChildrenMethod · 0.80
pipeFunction · 0.70
concatFunction · 0.70
extendFunction · 0.70
ofMethod · 0.65
failMethod · 0.65
patchMethod · 0.65
loadMethod · 0.65

Tested by

no test coverage detected