Files
common/packages/util/src/object/clear.ts
T
Jaco 733d7c1948 Add objectClear & objectSpread (#1157)
* Add objectClear & objectSpread

* Allow null/undefined as a source
2021-11-04 08:16:55 +02:00

13 lines
309 B
TypeScript

// Copyright 2017-2021 @polkadot/util authors & contributors
// SPDX-License-Identifier: Apache-2.0
export function objectClear <T> (value: Record<string, T>): Record<string, T> {
const keys = Object.keys(value);
for (let i = 0; i < keys.length; i++) {
delete value[keys[i]];
}
return value;
}