Closed Bug 1468159 Opened 6 years ago Closed 6 years ago

Convert lodash .union() to native ES6 JS

Categories

(Tree Management :: Treeherder: Frontend, enhancement, P3)

enhancement

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: evct, Assigned: evct, Mentored)

References

Details

Attachments

(1 file)

Converting all _.union() (lodash) functions to ES6 JS
Assignee: nobody → oss
Blocks: 1466494
Status: NEW → ASSIGNED
Priority: -- → P3
Here's what I have in mind to replace _.union() with native ES6:

const c = [2, 3, 3, 4];
const d = [1, 2, 3];
const uniondBis = Array.from(new Set([...c, ...d]));
console.log(uniondBis);
// [ 2, 3, 4, 1 ]

Spreading syntax to merge the arrays.
new Set() to remove duplicates.
Array.from() to convert back to an Array.
Finally went with this syntax:

const union = [...new Set([...c, ...d])];
Attachment #8985073 - Flags: review?(cdawson)
Comment on attachment 8985073 [details] [review]
Link to GitHub pull-request: https://github.com/mozilla/treeherder/pull/3655

Awaiting new updates.
Flags: needinfo?(cdawson)
Attachment #8985073 - Flags: review?(cdawson)
Attachment #8985073 - Flags: review?(cdawson)
Comment on attachment 8985073 [details] [review]
Link to GitHub pull-request: https://github.com/mozilla/treeherder/pull/3655

Requested updates in the PR.  Clearing review for now.
Flags: needinfo?(cdawson)
Attachment #8985073 - Flags: review?(cdawson)
Flags: needinfo?(cdawson)
Flags: needinfo?(cdawson)
Comment on attachment 8985073 [details] [review]
Link to GitHub pull-request: https://github.com/mozilla/treeherder/pull/3655

Request changes done.
Attachment #8985073 - Flags: review?(cdawson)
Comment on attachment 8985073 [details] [review]
Link to GitHub pull-request: https://github.com/mozilla/treeherder/pull/3655

Comments in PR.  Hit an error while testing.
Attachment #8985073 - Flags: review?(cdawson) → review-
Actually, this is likely because this branch is based on a commit that had this error.  Would you rebase and try again please?
I've rebased on last master and force pushed. As far as I have tested, no error when visiting the Alerts tab.
Attachment #8985073 - Flags: review- → review?(cdawson)
Attachment #8985073 - Flags: review?(cdawson) → review+
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: