From c8db224efed08d7722c9951cde048d731db050d3 Mon Sep 17 00:00:00 2001 From: "Kevin (Kun) \"Kassimo\" Qian" Date: Fri, 19 Apr 2019 17:39:54 -0700 Subject: Make Deno/Deno.core not deletable/writable (#2153) --- js/util.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'js/util.ts') diff --git a/js/util.ts b/js/util.ts index b81b96aca..348e36a1f 100644 --- a/js/util.ts +++ b/js/util.ts @@ -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, -- cgit v1.2.3