2018-07-05 23:03:28 +02:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2021-09-05 01:09:30 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
2021-05-01 09:17:31 +02:00
|
|
|
export function clearObject(obj: any): void {
|
2021-09-05 01:09:30 +02:00
|
|
|
for (const key in obj) {
|
|
|
|
if (obj.hasOwnProperty(key)) {
|
|
|
|
// tslint:disable-next-line:no-dynamic-delete
|
|
|
|
delete obj[key];
|
2018-07-05 23:03:28 +02:00
|
|
|
}
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2018-07-05 23:03:28 +02:00
|
|
|
}
|