-
Notifications
You must be signed in to change notification settings - Fork 1
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
Iterator.concat instead of variadic Iterator.from #1
Comments
Taking consistency into consideration, |
@graphemecluster The second parameter of |
It's an inconsistency that will make JS harder to learn and memorize.
If |
Iterator.from always produced a wrapped iterator, so the return will always have .map on it. |
Thanks, I'll rephrase: Iterator.from always produces an iterator that has |
I have no idea how it's related to this case. In Iterator.from({
next: () => ({ done: Math.random() > .9, value: Math.random() })
}).map(it => it * 10 | 0).toArray();
It's not something I can't live without - it's just an example that consistency is better. |
@ljharb said he would want any method named @michaelficarra said he wasn't interested in that behavior. Combined, that rules out the name So, instead, how about a static variadic |
Seems perfectly reasonable to me! |
Why is that? I believe more people are confused by this behaviour than pleased by it, and would gladly drop it (if it wasn't for backwards compatibility). Having to check for
Hm, I think that would confuse Pythonistas where I'd definitely prefer |
Not because of isConcatSpreadable, but because it’s very very idiomatic to do Nobody ever uses string concat (other than Babel’s template literal transpile). Anything that’s similar to concatenation implies the same behavior as array concat; “concatenation” is this the same as “concat” in this regard, |
(i note the readme still says the chosen solution is called "concat"; my constraint remains that if it's called "concat" it must accept both iterables and non-iterables; alternatively a new name can be chosen) |
I'd vote to avoid concatenate or cat, due to possible confusion ( |
My vote is still for I am somewhat reluctant to give up on the obvious name based only on a single person's dislike of that name. I see the inconsistency you're pointing out but since it's already different by virtue of being static rather than prototype, and since you'll immediately get an error if you try to use it assuming it has the same behavior as |
Variadic
Iterator.from
is weird in a couple of ways:Iterator.from
.Iterator.from(null)
throws immediately.Iterator.from(null, it)
will return an iterator which throws once used.Array.from(x, y)
So I would prefer not to do this. I'd prefer instead having a static (or prototype)
concat
method, which works the same way as the variadic case offrom
currently in this proposal.The text was updated successfully, but these errors were encountered: