Add Event web API (#1059)

This commit is contained in:
Adam Conrad 2019-01-05 15:02:44 +00:00 committed by Ryan Dahl
parent ad01085406
commit f44322128b
9 changed files with 504 additions and 35 deletions

View file

@ -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");
}