Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #29018
| From | Asen Bozhilov <asen.bozhilov@gmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | ES6 itertools |
| Date | 2015-12-16 22:30 +0200 |
| Organization | solani.org |
| Message-ID | <n4shlq$huj$1@solani.org> (permalink) |
I am working on project called ES-Iter <URL:
https://github.com/abozhilov/ES-Iter>. Since, ES6 provides iterator
protocol and `for-of` loop the intention of lib is to provide set of
utility functions for lazy iteration in similar way of Python's itertools.
The lib is inspired by Python, but it is not 1 to 1 port.
Some design considerations:
- Error detection is as early as it can, e.g. `let z = Iter.zip([1, 2,
3], null); for (let i of z) {}` it will throw an error in time of
calling `zip` not when the iteration starts.
- Every iterator is closed properly on abrupt exits e.g. break, return,
throw. This is really important, especially for some host objects which
could implement iterator protocol. E.g. File object can implement
iterator protocol and in their `return` method must close the file
properly.
- The most common used method are implemented as static.
- Every method returns new Iter instance in order to allow chaining
calls e.g. `Iter.range(10).filter((x) => x % 2).accumulate()`
I am open for discussion, and contributions. Any improvements are welcome.
Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread
ES6 itertools Asen Bozhilov <asen.bozhilov@gmail.com> - 2015-12-16 22:30 +0200 Re: ES6 itertools Scott Sauyet <scott.sauyet@gmail.com> - 2015-12-22 08:37 -0800
csiph-web