MCPcopy
hub / github.com/Effect-TS/effect / filterMap

Function filterMap

packages/effect/src/Micro.ts:4002–4023  ·  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

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…