jashkenas / jashkenas/underscore
Make the underscore wrapper iterable
- Dominant language
- JavaScript
- Stars
- 27.3k
- Forks
- 5.4k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 1
Description
Thoughts on making the Underscore wrapper an iterator and iterable?
It would require detecting `Symbol.iterator` and doing something like
``` js
_.prototype[Symbol.iterator] = function() {
return this;
};
_.prototype.next = function() {
if (this.__values__ === undefined) {
this.__values__ = _.toArray(this.value());
}
var done = this.__index__ >= this.__values__.length,
value = done ? undefined : this.__values__[this.__index__++];
return { 'done': done, 'value': value };
};
```
Related to https://github.com/jashkenas/backbone/issues/3954#issuecomment-189552205.
Contributor guide
Research direction
Locate the Underscore wrapper prototype and inspect its existing value and toArray behavior. Use the Symbol.iterator and next entry points described in the issue as the starting point, then verify that wrapped values can be consumed through JavaScript iteration and that iteration reaches completion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100