Vincit / Vincit/objection.js

union() keeps duplicates for small arrays

Open
#2,811 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
7.3k
Forks
637
PR merge metrics
No merged PRs in 30d

Description

union() in lib/utils/objectUtils.js uses a Set for large inputs (deduping both arrays) but a plain copy of the first array for small ones (deduping only the second). So duplicates in the first array survive only on the small-array path: union([1, 1, 2], [2, 3]) returns [1, 1, 2, 3] instead of [1, 2, 3].

PR: #2809

Contributor guide

No contributing guide indexed for this repository

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

Read lib/utils/objectUtils.js and trace the small-array and large-array paths in union(). Check the reported example and compare both paths; done means duplicates are removed from the first array as well as the second, including for small inputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.