Add objectClear & objectSpread (#1157)
* Add objectClear & objectSpread * Allow null/undefined as a source
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user