Skip to content

Commit

Permalink
fix: Memory leak caused by global variables. (#686)
Browse files Browse the repository at this point in the history
  • Loading branch information
ygj6 committed Apr 29, 2021
1 parent 12b544e commit badff82
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/utils/utils.ts
Expand Up @@ -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) {
Expand Down

0 comments on commit badff82

Please sign in to comment.