Basically I'm trying to implement the equivalent of the C# LINQ ToDictionary() method in Typescript.
As an example, if I have a list of Person (with properties say int Id
and string[] FirstNames
), I would like to have as an output, a dictionary with Id
as the key, and the FirstNames
as the value.
What I currently did in Typescript:
interface IDictionary<T> {
[index: string]: T;
}
Then I tried with map:
let result: IDictionary<string[]> = {};
let test = myObservable.map(b => b.map(item => result[item.moduleName] = item.jsFiles));
and with foreach
let test = myObservable.map(r => r.forEach(item => result[item.moduleName] = item.jsFiles));
Note that myObservable is of type Observable<Abc[]>
But it doesnt work...
The goal would be to have in the test
variable an Observable<IDictionary<string[]>>