| 1329 | ) => mergeAll(self, ...(Array.isArray(that) ? that : [that]))) |
| 1330 | |
| 1331 | const provideWith = ( |
| 1332 | self: Layer<any, any, any>, |
| 1333 | that: Layer<any, any, any> | ReadonlyArray<Layer<any, any, any>>, |
| 1334 | f: ( |
| 1335 | selfContext: Context.Context<any>, |
| 1336 | thatContext: Context.Context<any> |
| 1337 | ) => Context.Context<any> |
| 1338 | ) => |
| 1339 | fromBuild((memoMap, scope) => |
| 1340 | internalEffect.flatMap( |
| 1341 | Array.isArray(that) |
| 1342 | ? mergeAllEffect(that as NonEmptyArray<Layer<any, any, any>>, memoMap, scope) |
| 1343 | : (that as Layer<any, any, any>).build(memoMap, scope), |
| 1344 | (context) => |
| 1345 | self.build(memoMap, scope).pipe( |
| 1346 | internalEffect.provideContext(context), |
| 1347 | internalEffect.map((merged) => f(merged, context)) |
| 1348 | ) |
| 1349 | ) |
| 1350 | ) |
| 1351 | |
| 1352 | /** |
| 1353 | * Feeds the output services of the dependency layer into the requirements of |