MCPcopy
hub / github.com/microsoft/playwright / Zone

Class Zone

packages/utils/zones.ts:23–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21const asyncLocalStorage = new AsyncLocalStorage<Zone | undefined>();
22
23export class Zone {
24 private readonly _asyncLocalStorage: AsyncLocalStorage<Zone | undefined>;
25 private readonly _data: ReadonlyMap<ZoneType, unknown>;
26
27 constructor(asyncLocalStorage: AsyncLocalStorage<Zone | undefined>, store: Map<ZoneType, unknown>) {
28 this._asyncLocalStorage = asyncLocalStorage;
29 this._data = store;
30 }
31
32 with(type: ZoneType, data: unknown): Zone {
33 return new Zone(this._asyncLocalStorage, new Map(this._data).set(type, data));
34 }
35
36 without(type?: ZoneType): Zone {
37 const data = type ? new Map(this._data) : new Map();
38 data.delete(type);
39 return new Zone(this._asyncLocalStorage, data);
40 }
41
42 run<R>(func: () => R): R {
43 return this._asyncLocalStorage.run(this, func);
44 }
45
46 data<T>(type: ZoneType): T | undefined {
47 return this._data.get(type) as T | undefined;
48 }
49}
50
51export const emptyZone = new Zone(asyncLocalStorage, new Map());
52

Callers

nothing calls this directly

Implementers 1

NodeZonepackages/utils/nodePlatform.ts

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…