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

Function filterMap

packages/effect/src/Micro.ts:4003–4024  ·  view source on GitHub ↗
(
  iterable: Iterable<A>,
  f: (a: NoInfer<A>) => Micro<Option.Option<B>, E, R>,
  options?: {
    readonly concurrency?: Concurrency | undefined
  }
)

Source from the content-addressed store, hash-verified

4001 * @category collecting & elements
4002 */
4003export const filterMap = <A, B, E, R>(
4004 iterable: Iterable<A>,
4005 f: (a: NoInfer<A>) => Micro<Option.Option<B>, E, R>,
4006 options?: {
4007 readonly concurrency?: Concurrency | undefined
4008 }
4009): Micro<Array<B>, E, R> =>
4010 suspend(() => {
4011 const out: Array<B> = []
4012 return as(
4013 forEach(iterable, (a) =>
4014 map(f(a), (o) => {
4015 if (o._tag === "Some") {
4016 out.push(o.value)
4017 }
4018 }), {
4019 discard: true,
4020 concurrency: options?.concurrency
4021 }),
4022 out
4023 )
4024 })
4025
4026// ----------------------------------------------------------------------------
4027// do notation

Callers 14

Filterable.test.tsFile · 0.85
partitionMapCompositionFunction · 0.85
filterFunction · 0.85
compactFunction · 0.85
Array.tsFile · 0.85
Iterable.tsFile · 0.85
getLeftsFunction · 0.85
getRightsFunction · 0.85
Option.tsFile · 0.85
compactFunction · 0.85
Record.tsFile · 0.85
compactFunction · 0.85

Calls 5

asFunction · 0.85
suspendFunction · 0.70
forEachFunction · 0.70
mapFunction · 0.70
fFunction · 0.70

Tested by

no test coverage detected