Make Deno/Deno.core not deletable/writable (#2153)

This commit is contained in:
Kevin (Kun) "Kassimo" Qian 2019-04-19 17:39:54 -07:00 committed by Ryan Dahl
parent 0796a8f2f7
commit c8db224efe
4 changed files with 67 additions and 2 deletions

View file

@ -131,6 +131,21 @@ export function requiredArguments(
}
}
// @internal
export function immutableDefine(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
o: any,
p: string | number | symbol,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
value: any
): void {
Object.defineProperty(o, p, {
value,
configurable: false,
writable: false
});
}
// Returns values from a WeakMap to emulate private properties in JavaScript
export function getPrivateValue<
K extends object,