I have this configurations
type Option = {
value: any,
label: any
}
And
export interface Role {
id: number
name: string
}
Then I have Roles
const roles:Role[]:[
{id:1,name:'name1'},
{id:2,name:'name2'},
{id:3,name:'name3'}
]
I want to extract Option[] from that roles dataset. How do i do it in javascript?
In java I could do
roles.stream().map(role->new Option(role.id,role.name)).collect(collectors.toList());