mirror of
https://github.com/denoland/deno.git
synced 2025-08-02 18:12:39 +00:00
Add Event web API (#1059)
This commit is contained in:
parent
ad01085406
commit
f44322128b
9 changed files with 504 additions and 35 deletions
12
js/util.ts
12
js/util.ts
|
@ -151,3 +151,15 @@ export function requiredArguments(
|
|||
throw new TypeError(errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
// Returns values from a WeakMap to emulate private properties in JavaScript
|
||||
export function getPrivateValue<
|
||||
K extends object,
|
||||
V extends object,
|
||||
W extends keyof V
|
||||
>(instance: K, weakMap: WeakMap<K, V>, key: W): V[W] {
|
||||
if (weakMap.has(instance)) {
|
||||
return weakMap.get(instance)![key];
|
||||
}
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue