Skip to content

Commit badff82

Browse files
author
ygj6
authored
fix: Memory leak caused by global variables. (#686)
1 parent 12b544e commit badff82

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/utils/utils.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,17 @@ export const hasSymbol =
1414

1515
export const noopFn: any = (_: any) => _
1616

17-
const sharedPropertyDefinition = {
18-
enumerable: true,
19-
configurable: true,
20-
get: noopFn,
21-
set: noopFn,
22-
}
23-
2417
export function proxy(
2518
target: any,
2619
key: string,
2720
{ get, set }: { get?: Function; set?: Function }
2821
) {
29-
sharedPropertyDefinition.get = get || noopFn
30-
sharedPropertyDefinition.set = set || noopFn
31-
Object.defineProperty(target, key, sharedPropertyDefinition)
22+
Object.defineProperty(target, key, {
23+
enumerable: true,
24+
configurable: true,
25+
get: get || noopFn,
26+
set: set || noopFn,
27+
})
3228
}
3329

3430
export function def(obj: Object, key: string, val: any, enumerable?: boolean) {

0 commit comments

Comments
 (0)