-
Notifications
You must be signed in to change notification settings - Fork 71
Description
Hi @anvaka!
Thank you for your huge work on the ngraph packages family. It is cool, except there is a vital thing not implemented yet - so is a convenient and universal way to iterate through nodes/links. The existing way of iteration via callback provided to internal foreach cycle is not enough, as:
-
The
ngraph.graphpackage controls the iteration and one cannot suspend execution somewhere in the middle of the cycle. -
It requires an intermediate array to write graph elements to if one wants to pass them anywhere else.
#1 is a pretty similar issue, @ZigGreen probably wanted the same thing - a convenient way to iterate through elements.
I suppose adding methods that will return ECMAScript 6 iterators a cool way to deal with this problem. An iterator is a simple object so it is completely compatible with vanilla JavaScript.
Everyone who is happy to afford using ECMAScript 6 features can then use for..of and *yield syntax with the returned iterator. For everybody else we could create a simple ngraph.iteration package with common functional methods, such as map/filter/forEach, written on vanilla JS.
Another benefit of this approach is that the internal nodes object won't be able to be changed by user.
The only possible problem may be a concurrency issue... or not?
What do you think about it?