MCPcopy Index your code
hub / github.com/Effect-TS/effect / fromFlatLoop

Function fromFlatLoop

packages/effect/src/internal/configProvider.ts:239–437  ·  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

237}
238
239const fromFlatLoop = <A>(
240 flat: ConfigProvider.ConfigProvider.Flat,
241 prefix: ReadonlyArray<string>,
242 config: Config.Config<A>,
243 split: boolean
244): Effect.Effect<Array<A>, ConfigError.ConfigError> => {
245 const op = config as _config.ConfigPrimitive
246 switch (op._tag) {
247 case OpCodes.OP_CONSTANT: {
248 return core.succeed(Arr.of(op.value)) as Effect.Effect<Array<A>, ConfigError.ConfigError>
249 }
250 case OpCodes.OP_DESCRIBED: {
251 return core.suspend(
252 () => fromFlatLoop(flat, prefix, op.config, split)
253 ) as unknown as Effect.Effect<Array<A>, ConfigError.ConfigError>
254 }
255 case OpCodes.OP_FAIL: {
256 return core.fail(configError.MissingData(prefix, op.message)) as Effect.Effect<
257 Array<A>,
258 ConfigError.ConfigError
259 >
260 }
261 case OpCodes.OP_FALLBACK: {
262 return pipe(
263 core.suspend(() => fromFlatLoop(flat, prefix, op.first, split)),
264 core.catchAll((error1) => {
265 if (op.condition(error1)) {
266 return pipe(
267 fromFlatLoop(flat, prefix, op.second, split),
268 core.catchAll((error2) => core.fail(configError.Or(error1, error2)))
269 )
270 }
271 return core.fail(error1)
272 })
273 ) as unknown as Effect.Effect<Array<A>, ConfigError.ConfigError>
274 }
275 case OpCodes.OP_LAZY: {
276 return core.suspend(() => fromFlatLoop(flat, prefix, op.config(), split)) as Effect.Effect<
277 Array<A>,
278 ConfigError.ConfigError
279 >
280 }
281 case OpCodes.OP_MAP_OR_FAIL: {
282 return core.suspend(() =>
283 pipe(
284 fromFlatLoop(flat, prefix, op.original, split),
285 core.flatMap(
286 core.forEachSequential((a) =>
287 pipe(
288 op.mapOrFail(a),
289 core.mapError(configError.prefixed(appendConfigPath(prefix, op.original)))
290 )
291 )
292 )
293 )
294 ) as unknown as Effect.Effect<Array<A>, ConfigError.ConfigError>
295 }
296 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