-
Notifications
You must be signed in to change notification settings - Fork 640
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
Add support for ES iterators #1058
Add support for ES iterators #1058
Conversation
3a188e0
to
a35cc75
Compare
Just wanted to give you a heads-up that there is a fairly big refactor / cleanup in progress and under discussion at PR #1053. I intend to merge that into master sometime next week probably. Your best bet would be to try to open this as a patch onto the I'm not sure about this approach when it comes to generators. Someone using nunjucks that wanted to convert their generators to arrays could use |
fb66b82
to
421c8cc
Compare
Ok, I've updated this PR to point to develop and your totally right about the generators, so I've removed that from the docs. Talking about generators, you really want to use |
Codecov Report
@@ Coverage Diff @@
## develop #1058 +/- ##
===========================================
+ Coverage 89.41% 89.44% +0.02%
===========================================
Files 22 22
Lines 2966 2974 +8
===========================================
+ Hits 2652 2660 +8
Misses 314 314
Continue to review full report at Codecov.
|
tests/compiler.js
Outdated
@@ -475,6 +475,38 @@ | |||
}, | |||
'showing test\nshowing 1\nshowing 2\nshowing 3\n'); | |||
}); | |||
/* global Set */ | |||
if (typeof Set === 'function') { | |||
it('should work with Set bultin', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you have a typo here (and below) for 'builtin'.
Would it also be possible to rewrite this to use this.skip
? e.g.:
it('should work with the Set builtin', function() {
/* global Set */
if (typeof Set === 'undefined') {
this.skip();
} else {
equal(/* ... */);
}
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
421c8cc
to
23f590c
Compare
This requires the Symbol.iterator well known symbol and Array.from to coerce them into vanilla arrays.
23f590c
to
7086e2d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. Thanks for your contribution!
Always happy to help 😄 |
@@ -10,6 +10,8 @@ master (unreleased) | |||
|
|||
* Support objects created with Object.create(null). fixes [#468](https://github.com/mozilla/nunjucks/issues/468) | |||
|
|||
* Support ESNext iterators, using Array.from. Merge of | |||
[#760](https://github.com/mozilla/nunjucks/pull/760) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean #1058? 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, but I also want to mention that PR and I didn't understand what the format was. Would you mind making a PR that corrects this, please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
Summary
Proposed change:
This requires the Symbol.iterator well known symbol and Array.from to coerce them into vanilla arrays.
This basically supersedes #760, see there for more info.
Checklist
I've completed the checklist below to ensure I didn't forget anything. This makes reviewing this PR as easy as possible for the maintainers. And it gets this change released as soon as possible.