Skip to content

Commit be3bf1c

Browse files
committed
add clearObject() function to lib module which completely empties the object of properties (including symbol properties)
1 parent 6b6d22f commit be3bf1c

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/lib.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,17 @@ export class DynamicMap<K, V> extends Map<K, V> {
6262
return value
6363
}
6464
}
65+
66+
export function clearObject(object: {}) {
67+
for (const propertyName of Object.getOwnPropertyNames(object) as any) {
68+
// @ts-ignore
69+
delete object[propertyName]
70+
}
71+
72+
for (const propertySymbol of Object.getOwnPropertySymbols(object) as any) {
73+
// @ts-ignore
74+
delete object[propertyName]
75+
}
76+
77+
return object
78+
}

0 commit comments

Comments
 (0)