jashkenas / jashkenas/underscore
_.union doesn't work with arrays of objects
- Dominant language
- JavaScript
- Stars
- 27.3k
- Forks
- 5.4k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 1
Description
_.union will always produce duplicates when passed arrays of objects.
e.g. `_.union( [ { a:1 } ], [ { a:1 } ])` will return `[ { a:1 }, { a:1 } ]`
Perversely, underscore's own isEqual function will tell you that the objects in question are equal. Maybe we could have a flag/option which dictates the equality comparison to use, or the option to pass in a comparator?
Contributor guide
Research direction
Reproduce the example with _.union and compare its behavior with _.isEqual; no source file or test is named in the issue. Before changing anything, resolve whether object equality or a caller-supplied comparator is intended, then add regression coverage for the agreed behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100