Skip to content

Support for spread operator on iterables#569

Merged
Perryvw merged 2 commits intomasterfrom
spread-iterable
May 5, 2019
Merged

Support for spread operator on iterables#569
Perryvw merged 2 commits intomasterfrom
spread-iterable

Conversation

@tomblind
Copy link
Copy Markdown
Collaborator

@tomblind tomblind commented May 5, 2019

fixes #534

};
const arr = [...it];
return JSONStringify(arr)`;
expect(util.transpileAndExecute(code)).toBe(JSON.stringify([9, 8, 7, 6, 5, 4, 3, 2, 1, 0]));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the other way around would be a bit nicer:

const result = util.transpileAndExecute(code);
expect(JSON.parse(result)).toEqual([9, 8, 7, 6, 5, 4, 3, 2, 1, 0]);

return this;
},
next() {
--this.i;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think making this just count up is a bit clearer, first time I looked at this test I thought it was bugged and reversed the order.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually do this on purpose to ensure we're not somehow getting array indicies instead of values.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get that, but I'd sooner opt for adding a constant to each value, or multiplying them by 3 or something like that.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll do something different here

@Perryvw Perryvw merged commit 1fc5f26 into master May 5, 2019
@Perryvw Perryvw deleted the spread-iterable branch May 5, 2019 14:22
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 this pull request may close these issues.

Arrays initialized with a spread operator on an iterator are empty

2 participants