Since Y.Map is an Iterable you could also do new Map(ymap)
reducing some overhead.
I see several use-cases for toArray
. It transforms the list representation to an Array representation. In contrast to toJSON
, toArray
retains type information. It only transforms the outer representation to an Array. This means that yarray.toArray()[0]
will return a Y.Map if yarray.get(0)
is a Y.Map. With toJSON
the Y.Map will be transformed to an Objetct.
Arrays have better performance when iterating in random order than the Y.Array. Meanwhile, Y.Map and Map have similar performance. This is why there is no Y.Map yet. But if you have a real use-case for transforming to a Y.Map, then lets add toMap
to the API.