MCPcopy Index your code
hub / github.com/angular/angular / matchAll

Method matchAll

packages/service-worker/worker/testing/clients.ts:83–107  ·  view source on GitHub ↗
(
    options?: T,
  )

Source from the content-addressed store, hash-verified

81 }
82
83 async matchAll<T extends ClientQueryOptions>(
84 options?: T,
85 ): Promise<ReadonlyArray<T['type'] extends 'window' ? WindowClient : Client>> {
86 const type = options?.type ?? 'window';
87 const allClients = Array.from(this.clients.values());
88 const matchedClients =
89 type === 'all' ? allClients : allClients.filter((client) => client.type === type);
90
91 // Order clients according to the [spec](https://w3c.github.io/ServiceWorker/#clients-matchall):
92 // In most recently focused then most recently created order, with windows clients before other
93 // clients.
94 return (
95 matchedClients
96 // Sort in most recently created order.
97 .reverse()
98 // Sort in most recently focused order.
99 .sort((a, b) => b.lastFocusedAt - a.lastFocusedAt)
100 // Sort windows clients before other clients (otherwise leave existing order).
101 .sort((a, b) => {
102 const aScore = a.type === 'window' ? 1 : 0;
103 const bScore = b.type === 'window' ? 1 : 0;
104 return bScore - aScore;
105 }) as any
106 );
107 }
108
109 async openWindow(url: string): Promise<WindowClient | null> {
110 return null;

Callers

nothing calls this directly

Calls 3

valuesMethod · 0.80
reverseMethod · 0.80
filterMethod · 0.45

Tested by

no test coverage detected