On 28 August 2013 17:02, Forbes Lindesay for...@lindesay.co.uk wrote:
It would be nice from a readability point of view if `iteratable.toArray()`
could always be used as a substitute for `Array.from(iteratable)`. Is there
a way that could be neatly achieved? It would also be nice if methods
To: Forbes Lindesay
Cc: es-discuss@mozilla.org
Subject: Re: `.toArray()` for all generators
On 28 August 2013 17:02, Forbes Lindesay for...@lindesay.co.uk wrote:
It would be nice from a readability point of view if
`iteratable.toArray()` could always be used as a substitute for
`Array.from(iteratable
: Andreas Rossberg [mailto:rossb...@google.com]
Sent: 29 August 2013 09:56
To: Forbes Lindesay
Cc: es-discuss@mozilla.org
Subject: Re: `.toArray()` for all generators
On 28 August 2013 17:02, Forbes Lindesay for...@lindesay.co.uk wrote:
It would be nice from a readability point of view
It would be nice from a readability point of view if `iteratable.toArray()`
could always be used as a substitute for `Array.from(iteratable)`. Is there a
way that could be neatly achieved? It would also be nice if methods like
`.map` and `.filter` existed on iteratables. C# does this via the
On Aug 28, 2013, at 17:02 , Forbes Lindesay for...@lindesay.co.uk wrote:
It would be nice from a readability point of view if `iteratable.toArray()`
could always be used as a substitute for `Array.from(iteratable)`. Is there
a way that could be neatly achieved?
For me, [ ... iterable ]
The thing about `.map` and `.filter` is that it would be easy enough to create
functional versions:
```js
function* map(array, fn) {
for (var x of array) {
yield fn(x)
}
}
```
But harder to create methods:
```js
Iteratable.prototype.map = function(fn) {
for (var x of this) {
Note that an equivalent of both `.map` and `.filter` already exists in ES6: its
name is generator expression. For instance:
```
array.filter(pred).map(transf)
```
becomes:
```
(for (let x of iter) if (pred(x)) transf(x))
```
—Claude
Le 28 août 2013 à 17:27, Forbes Lindesay
On Wed, Aug 28, 2013 at 11:02 AM, Forbes Lindesay for...@lindesay.co.ukwrote:
It would be nice from a readability point of view if
`iteratable.toArray()` could always be used as a substitute for
`Array.from(iteratable)`.
Since both Array.from and [..spread] already covers every single
I completely agree with Rick plus this is what I meant in the other thread
when I've said I don't see the urge/need to deal with Iterators = Arrays
if not ending up with waste of resources as the one proposed here.
Somebody will need to write specs, tests, and implementations while we have
all
9 matches
Mail list logo