jashkenas / jashkenas/underscore

Supporting ES6 iterables in collection methods

Open
#2,147 3 comments 11 reactions 0 assignees View on GitHub
breaking change enhancement question
Dominant language
JavaScript
Stars
27.3k
Forks
5.4k
Avg merge
2d 5h
Merged PRs (30d)
1

Description

So this sounds like something lodash isn't going to support yet because it will add quite a bit of code https://github.com/lodash/lodash/issues/737 - but I think it'd be cool to have a ticket here to explore the possibility/implications (code, performance, and otherwise) of supporting ES6 iterables in at least the collection functions of underscore.

As ES6 `Map` / `Set` are available in more places (latest browsers, babel polyfill) it'd be great to be able to iterate in the same way as objects, especially since `Map` it avoids the weird edge cases of treating an object as a Map (`__proto__`, ownProperty checks, etc.). Also, the ES6 iterator API provides a standard convention for iterating arbitrary objects and it'd be great if underscore could maybe act as a functional api `for-of` in the same way it does for `for`/`for-in`

I feel like it should be possible to come up with a way that does this in most reasonable cases with out too much overhead, but I admittedly haven't explored it too in-depth - just wanted to see if anyone else would be interested in discussion.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the collection methods and their current iteration behavior, then compare them with the ES6 iterator API and Map/Set semantics described in the issue. The issue is exploratory and does not name files, tests, or a settled definition of done, so the first step is to narrow the supported iterable cases and performance expectations.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.