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

Function pick

packages/effect/src/Context.ts:1226–1235  ·  view source on GitHub ↗
(
  ...services: S
)

Source from the content-addressed store, hash-verified

1224 * @since 2.0.0
1225 */
1226export const pick = <S extends ReadonlyArray<Key<any, any>>>(
1227 ...services: S
1228) =>
1229<Services>(self: Context<Services>): Context<Services & Service.Identifier<S[number]>> => {
1230 const keep = new Set(services.map((key) => key.key))
1231 return withFlat(self, (map) =>
1232 map.forEach((_, key) => {
1233 if (!keep.has(key)) map.delete(key)
1234 }))
1235}
1236
1237/**
1238 * Returns a new `Context` with the specified service keys removed.

Callers

nothing calls this directly

Calls 4

withFlatFunction · 0.85
forEachMethod · 0.65
mapMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected