Add objectClear & objectSpread (#1157)

* Add objectClear & objectSpread

* Allow null/undefined as a source
This commit is contained in:
Jaco
2021-11-04 08:16:55 +02:00
committed by GitHub
parent 08ac55d7cd
commit 733d7c1948
13 changed files with 105 additions and 35 deletions
+12
View File
@@ -0,0 +1,12 @@
// 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;
}