mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-21 13:45:44 +01:00
15 lines
454 B
TypeScript
15 lines
454 B
TypeScript
|
/**
|
||
|
* 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];
|
||
|
}
|
||
|
}
|
||
|
}
|