| 1 | import { InvalidParametersError, serviceCapabilities } from '@libp2p/interface' |
| 2 | |
| 3 | export function getComponent <T> (component: string, components: any, capability: string): T { |
| 4 | const output = components[component] |
| 5 | |
| 6 | if (output[serviceCapabilities]?.includes(capability) === true) { |
| 7 | return output |
| 8 | } |
| 9 | |
| 10 | throw new InvalidParametersError(`Component ${component} did not have capabilitiy ${capability}`) |
| 11 | } |