【发布时间】:2020-10-02 18:14:29
【问题描述】:
这是我可以在数组中访问的一些示例数据。
[
{ filesList: List {size: 2, _origin: 0, _capacity: 2, _level: 5, _root: null, …},
id: "089b5559-171f-46b0-9aa4-1c9fc5013b0b",
name: "Arabidopsis TAIR10",
value: "Arabidopsis",
},
{ filesList: List {size: 2, _origin: 0, _capacity: 2, _level: 5, _root: null, …},
id: "da8f7da3-04e3-4aba-98e3-615e86982a60",
name: "Arabidopsis TAIR10",
value: "Arabidopsis",
},
{ filesList: List {size: 2, _origin: 0, _capacity: 2, _level: 5, _root: null, …},
id: "6b166a90-f73b-4000-b18c-8f7b80513e6d",
name: "Bean GCF_000499845.1",
value: "Bean_reference_genome",
}
]
这是filesList 对象的示例。它是一个数组。
List {size: 2, _origin: 0, _capacity: 2, _level: 5, _root: null, …}
size: 2
__altered: false
__hash: undefined
__ownerID: undefined
_capacity: 2
_level: 5
_origin: 0
_root: null
_tail: VNode
array: Array(2)
0: File
id: "92cb45c3-91ec-4e1e-8ead-99762465f9e2"
isLocal: true
lastModified: 1591716051955
lastModifiedDate: Tue Jun 09 2020 10:20:51 GMT-0500 (Central Daylight Time) {}
name: "Gene_List_edgr_chickpea.txt"
size: 162890
type: "text/plain"
webkitRelativePath: ""
__proto__: File
1: File
id: "edccae34-71dd-46f7-a4e1-d821e1315f1a"
isLocal: true
lastModified: 1591716038452
lastModifiedDate: Tue Jun 09 2020 10:20:38 GMT-0500 (Central Daylight Time) {}
name: "callset_name_hc.g.vcf.gz"
size: 3891432
type: "application/x-gzip"
webkitRelativePath: ""
__proto__: File
length: 2
__proto__: Array(0)
ownerID: OwnerID {}
__proto__: Object
__proto__: IndexedCollection
我需要将此信息转换为以下结构的对象。
每个键都是对象的值。如果键值重复,我想将 filesList 数据附加到同一个键。
{
Arabidopsis: [file1, file2, file3, file4],
Bean_reference_genome: [file1, file2]
}
我怎样才能实现这种数据结构?
【问题讨论】:
-
能否请您展示
filesList对象的完整示例? -
@Paul 我已经更新了对象
-
试试我的解决方案 - 只是表达,而不是我的对象。我认为它已经开始工作了。
标签: javascript arrays sorting object immutable.js