You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
287 B
18 lines
287 B
4 months ago
|
export function toObjMap(obj) {
|
||
|
if (obj == null) {
|
||
|
return Object.create(null);
|
||
|
}
|
||
|
|
||
|
if (Object.getPrototypeOf(obj) === null) {
|
||
|
return obj;
|
||
|
}
|
||
|
|
||
|
const map = Object.create(null);
|
||
|
|
||
|
for (const [key, value] of Object.entries(obj)) {
|
||
|
map[key] = value;
|
||
|
}
|
||
|
|
||
|
return map;
|
||
|
}
|