tc39 / tc39/test262

Add test case for `Object.groupBy` / `Map.groupBy` with strings?

Open
#4,036 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
2.8k
Forks
564
Avg merge
3d 7h
Merged PRs (30d)
10

Description

Object.groupBy and Map.groupBy take an iterable, such as an array, as their first argument. This can be any iterable, so they can also accept a string.

const str = "abcd";
const grouped = Object.groupBy(str, (char) => char < 'c' ? "x" : "y");

However, it was discovered that in some implementations, a TypeError was thrown when the first argument was not of object type, so this was not working^1.

What do you think about adding test cases to test262 to cover this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing test262 coverage for Object.groupBy and Map.groupBy and follow its test conventions; the issue does not name specific files. Review the linked WebKit bug for the failure context. Done means test cases cover both methods when the iterable is a string and verify the expected grouping results.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.