我正在通过以下键值对进行映射:
a => a1
a => a2
a => a3
b => b1
b => b2
b => b3
c => c1
c => c2
c => c3
现在我有一张地图:
const myobject = new Map()
我需要在我的地图中设置以上数据,以使每个键都具有一个类似于以下列表的值:
a => list[a1, a2, a3]
b => list[b1, b2, b3]
c => list[c1, c2, c3]
这是实际代码:
const serviceResponses = new Map();
await Promise.all(allPromise.map(promises => {
promises.then(promise => promise.map(([stateName, item]) => {
// below is the part I am trying to set stateName (string) and
// result (it should be an array) into serviceResponses which is a
// map. note: result always has the same number of items. in this
// example the number of items is 3, but it can be any number.
item[0].then(result => {
serviceResponses.set(stateName, result);
});
return serviceResponses;
}));
我浏览了Immutablr.js api文档,并且已经尝试了setIn,set,MergeIn和MergeDeep。 感谢您的帮助