( ...services: S )
| 1224 | * @since 2.0.0 |
| 1225 | */ |
| 1226 | export 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. |