From badff82a10624c70a2475f315d6a13dbfcb4253a Mon Sep 17 00:00:00 2001 From: ygj6 <82787816@qq.com> Date: Thu, 29 Apr 2021 12:08:20 +0800 Subject: [PATCH] fix: Memory leak caused by global variables. (#686) --- src/utils/utils.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 32d0961b..dff6823c 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -14,21 +14,17 @@ export const hasSymbol = export const noopFn: any = (_: any) => _ -const sharedPropertyDefinition = { - enumerable: true, - configurable: true, - get: noopFn, - set: noopFn, -} - export function proxy( target: any, key: string, { get, set }: { get?: Function; set?: Function } ) { - sharedPropertyDefinition.get = get || noopFn - sharedPropertyDefinition.set = set || noopFn - Object.defineProperty(target, key, sharedPropertyDefinition) + Object.defineProperty(target, key, { + enumerable: true, + configurable: true, + get: get || noopFn, + set: set || noopFn, + }) } export function def(obj: Object, key: string, val: any, enumerable?: boolean) {