commonmark / commonmark/commonmark.js
Would be nice if there was an iterable interface to the NodeWalker
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.6k
- Forks
- 231
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 3
Description
Right now the NodeWalker instance returned by .walker() is not an actual javascript iterable.
Would be great to be able to do:
const walker = ast.walker()
for(event of walker) {
// stuff here
}
But right now that doesn't work.
It should be pretty simple to add, the following works when I already have a walker instance so just adding that before it is returned will work...
walker[Symbol.iterator] = function() {
return {
next() {
const data = walker.next();
if (data) {
return {
value: data
};
}
return {done: true};
}
};
};
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the NodeWalker implementation returned by .walker() and inspect its existing next() behavior. Add iterable support so for...of yields the same walker events and ends when traversal is complete; verify the behavior with the project’s existing tests, though no test file is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100