Reputation: 508
I'm having a utility function that converts a map into a list. It is supposed to still have the key values attached to it, but for some reason it doesn't. Rather I need to read of by index, of which is not really useful for my use case. Do someone know how to preserve keys when I transfer from a map? Here's my source
function getMetaStateArray(metaStateArrayOrObject) {
let metaStateArray;
if (metaStateArrayOrObject && Immutable.Map.isMap(metaStateArrayOrObject)) {
metaStateArray = metaStateArrayOrObject.toList();
}
else {
metaStateArray = metaStateArrayOrObject;
}
return metaStateArray;
}
Upvotes: 1
Views: 159
Reputation: 508
Solved it by making a list Wrapper around my map, while doing List.of()
inside the wrapper, so the map inside won't turn into a regular array:
metaStateArray = List(List.of(metaStateArrayOrObject));
Upvotes: 1