Skip to content
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

values() is not a function or its return value is not iterable #12

Open
piranna opened this issue May 27, 2021 · 4 comments · May be fixed by #13
Open

values() is not a function or its return value is not iterable #12

piranna opened this issue May 27, 2021 · 4 comments · May be fixed by #13

Comments

@piranna
Copy link

piranna commented May 27, 2021

With the next code

[...mediasoupWorkers.values()]

being mediasoupWorkers an instance of multimap I get the error TypeError: mediasoupWorkers.values is not a function or its return value is not iterable. Seems like multimap doesn't fully implement the iterable and/or iterator protocol, just only return an object with a next method, and the coversion to an array doesn't works.

@piranna
Copy link
Author

piranna commented May 27, 2021

This equivalent code doesn't works too:

const result = []

for(const value of mediasoupWorkers.values()) result.push(value)

return result

@piranna
Copy link
Author

piranna commented May 27, 2021

Ok, according to https://medium.com/@insomniocode/javascript-iterator-and-iterable-protocols-583b700305ce, multimap implements the iterator protocol (the next() method), but it doesn't implements the iterable protocol (the one used by for..of and spread).

piranna added a commit to Mafalda-SFU/multi-map that referenced this issue May 27, 2021
This fixes villadora#12 and allow to use `for..of` and array spread.
@piranna piranna linked a pull request May 27, 2021 that will close this issue
@maximilianMairinger
Copy link

maximilianMairinger commented May 16, 2022

Iterating over the whole map is also not supported, but is in the native Map implementation

for (const [key, val] of map) 

@piranna
Copy link
Author

piranna commented May 16, 2022

We would need to use an Array to keep record of the insertion order of the entries. We could iterate though it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants