Immutable.js 将Map的值转换为数组

7 浏览
0 Comments

Immutable.js 将Map的值转换为数组

我正在使用来自http://facebook.github.io/immutable-js/docs/#/Map的不可变Map。

我需要获取值的数组以传递给后端服务,但我觉得我漏掉了一些基本的东西,我应该怎么做?

我尝试过:

mymap.valueSeq().toArray()

但我仍然得到一个不可变的数据结构?

例如:

var d = '[{"address":"10.0.35.118","cpus":4}]';
var sr = JSON.parse(d);
var is = Immutable.fromJS(sr);
console.log(sr);
console.log(is.toArray());
console.log(is.valueSeq().toArray());

请参阅http://jsfiddle.net/3sjq148f/2/

我们从不可变数据结构中获取的数组似乎仍然带有每个包含对象的不可变字段。这是预期的吗?

0