-
-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MultiMap.from broken #174
Comments
Hello @andreasdamm,
|
Would the declaration file for MultiMap () multi-map.d.ts) have to be changed to reflect the intended behavior? Right now it is interface MultiMapConstructor {
new <K, V>(container: SetConstructor): MultiMap<K, V, Set<V>>;
new <K, V>(container?: ArrayConstructor): MultiMap<K, V, V[]>;
from<K, V>(
iterable: Iterable<[K, V]> | {[key: string]: V},
Container: SetConstructor
): MultiMap<K, V, Set<V>>;
from<K, V>(
iterable: Iterable<[K, V]> | {[key: string]: V},
Container?: ArrayConstructor
): MultiMap<K, V, V[]>;
} which indicates that the first member of the tuple becomes the key, and the second one the value. |
The type declaration is probably wrong indeed. I have better types suited to this kind of thing in |
There still doesn't appear to be a good way to create a MultiMap from a list of entry tuples, other then creating an empty map and then iterating through the tuples in a loop calling MultiMap.set. How would oblitarator help? |
When using MultiMap.from to create a MultiMap from an iterable of tuples or one-attribute-objects, the index of the item from the iterable is used as the key into the map instead of the first member of the tuple, or the attribute name of the one-attribute-object.
MultiMap.from([['a', 'aa']], Set)
currently results inMap(1) { 0 => Set(1) { [ 'a', 'aa' ] } }
MultiMap.from([{a: 'aa'}], Set)
currently results inMap(1) { 0 => Set(1) { { a: 'aa' } } }
The desired output should be
Map(1) { 'a' => Set(1) { 'aa' } }
The text was updated successfully, but these errors were encountered: