MCPcopy
hub / github.com/angular/angular / provideFirstSupported

Function provideFirstSupported

packages/benchpress/src/web_driver_extension.ts:37–62  ·  view source on GitHub ↗
(childTokens: any[])

Source from the content-addressed store, hash-verified

35 */
36export abstract class WebDriverExtension {
37 static provideFirstSupported(childTokens: any[]): any[] {
38 const res = [
39 {
40 provide: _CHILDREN,
41 useFactory: (injector: Injector) => childTokens.map((token) => injector.get(token)),
42 deps: [Injector],
43 },
44 {
45 provide: WebDriverExtension,
46 useFactory: (children: WebDriverExtension[], capabilities: {[key: string]: any}) => {
47 let delegate: WebDriverExtension = undefined!;
48 children.forEach((extension) => {
49 if (extension.supports(capabilities)) {
50 delegate = extension;
51 }
52 });
53 if (!delegate) {
54 throw new Error('Could not find a delegate for given capabilities!');
55 }
56 return delegate;
57 },
58 deps: [_CHILDREN, Options.CAPABILITIES],
59 },
60 ];
61 return res;
62 }
63
64 gc(): Promise<any> {
65 throw new Error('NYI');

Callers

nothing calls this directly

Calls 4

mapMethod · 0.80
getMethod · 0.65
supportsMethod · 0.65
forEachMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…