[refactor] Moved 'clearObject' to its own TS file

This commit is contained in:
Steven Evans
2018-07-05 17:03:28 -04:00
parent bcc6d39b10
commit 7edf5b5f1a
4 changed files with 35 additions and 29 deletions
+14
View File
@@ -0,0 +1,14 @@
/**
* Clears defined properties from an object.
* Does not delete up the prototype chain.
* @deprecated Look into using `Map` or `Set` rather than manipulating properties on an Object.
* @param obj the object to clear all properties
*/
export function clearObject(obj: any) {
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
// tslint:disable-next-line:no-dynamic-delete
delete obj[key];
}
}
}