-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptEffort: CasualGood issue if you're already used to contributing to the codebase. Harder than "good first issue".Good issue if you're already used to contributing to the codebase. Harder than "good first issue".Help WantedYou can do thisYou can do this
Milestone
Description
The proposal for Array.prototype.groupBy
and Array.prototype.groupByToMap
reached stage 3 recently.
Search terms: proposal-array-grouping array groupBy ernest
lib Update Request
With advancement into stage 3, it's time for JS engines, transpilers and toolings to start implementing support for new features and provide feedback for the proposal's advancement into stage 4.
Configuration Check
This is so new that it needs to go into ESNext
target.
Missing / Incorrect Definition
Missing Array.prototype.groupBy
and Array.prototype.groupByToMap
.
Sample Code
const array = [1, 2, 3, 4, 5];
// groupBy groups items by arbitrary key.
// In this case, we're grouping by even/odd keys
array.groupBy((num, index, array) => {
return num % 2 === 0 ? 'even': 'odd';
});
// => { odd: [1, 3, 5], even: [2, 4] }
// groupByToMap returns items in a Map, and is useful for grouping using
// an object key.
const odd = { odd: true };
const even = { even: true };
array.groupByToMap((num, index, array) => {
return num % 2 === 0 ? even: odd;
});
// => Map { {odd: true}: [1, 3, 5], {even: true}: [2, 4] }
Sample code from https://github.com/es-shims/Array.prototype.groupBy
Documentation Link
Proposal: proposal-array-grouping
Shim implementation that can the code can be tested against: es-shims/Array.prototype.groupBy
justinanastos, I-Want-ToBelieve, brunolm, Narretz, karlhorky and 13 moretimbuckley, MartinJohns, sh1okoh, johnfn, I-Want-ToBelieve and 3 more
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptEffort: CasualGood issue if you're already used to contributing to the codebase. Harder than "good first issue".Good issue if you're already used to contributing to the codebase. Harder than "good first issue".Help WantedYou can do thisYou can do this