{"id":18137761,"url":"https://github.com/tc39/proposal-array-unique","last_synced_at":"2025-08-19T13:32:25.749Z","repository":{"id":54394065,"uuid":"158808585","full_name":"tc39/proposal-array-unique","owner":"tc39","description":"ECMAScript proposal for Deduplicating method of Array","archived":false,"fork":false,"pushed_at":"2022-03-16T13:50:41.000Z","size":64,"stargazers_count":138,"open_issues_count":13,"forks_count":7,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-12-11T10:24:28.844Z","etag":null,"topics":["array","deduplicate","ecmascript","javascript","polyfill","proposal","unique"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tc39.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-23T09:15:52.000Z","updated_at":"2024-08-16T15:37:34.000Z","dependencies_parsed_at":"2022-08-13T14:20:34.639Z","dependency_job_id":null,"html_url":"https://github.com/tc39/proposal-array-unique","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tc39%2Fproposal-array-unique","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tc39%2Fproposal-array-unique/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tc39%2Fproposal-array-unique/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tc39%2Fproposal-array-unique/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tc39","download_url":"https://codeload.github.com/tc39/proposal-array-unique/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229982697,"owners_count":18154595,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["array","deduplicate","ecmascript","javascript","polyfill","proposal","unique"],"created_at":"2024-11-01T15:06:33.692Z","updated_at":"2024-12-19T00:08:40.542Z","avatar_url":"https://github.com/tc39.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Array deduplication proposal\n\nECMAScript proposal for Deduplicating method of Array.\n\n![Proposal Stage-1](https://img.shields.io/badge/Proposal-Stage--1-red)\n[![CI \u0026 CD](https://github.com/tc39/proposal-array-unique/actions/workflows/main.yml/badge.svg)][1]\n\n[![NPM](https://nodei.co/npm/array-unique-proposal.png?downloads=true\u0026downloadRank=true\u0026stars=true)][2]\n\n## Motivation\n\n**Deduplication** is one of the most common requirements in Data processing, especially in large Web Apps nowadays.\n\nIn Lodash, `*uniq*` methods are also [very popular][3]:\n\n| #   | Name     | Downloads |\n| --- | -------- | --------- |\n| 1   | uniq     | 5,546,070 |\n| 7   | uniqby   | 447,858   |\n| 28  | uniqwith | 15,077    |\n\nBut `[...new Set(array)]` in ECMAScript 6 isn't enough for **Non-primitive values**, and now, we may need a `Array.prototype.uniqueBy()`.\n\n## Core features\n\nWhile `Array.prototype.uniqueBy()` invoked with:\n\n1.  no parameter, it'll work as `[...new Set(array)]`;\n\n2.  one **index-key** parameter (`Number`, `String` or `Symbol`), it'll get values from each array element with the key, and then deduplicates the origin array based on these _values_;\n\n3.  one **function** parameter, it'll call this function for each array element, and then deduplicates the origin array based on these _returned values_.\n\nNotice:\n\n-   the **Returned value** is a new array, no mutation happens in the original array\n-   **Empty/nullish items** are treated as nullish values\n-   `0` \u0026 `-0` are treated as the same\n-   All `NaN`s are treated as the same\n\n## Typical cases\n\n```JavaScript\n[1, 2, 3, 3, 2, 1].uniqueBy();  // [1, 2, 3]\n\nconst data = [\n    { id: 1, uid: 10000 },\n    { id: 2, uid: 10000 },\n    { id: 3, uid: 10001 }\n];\n\ndata.uniqueBy('uid');\n// [\n//     { id: 1, uid: 10000 },\n//     { id: 3, uid: 10001 }\n// ]\n\ndata.uniqueBy(({ id, uid }) =\u003e `${id}-${uid}`);\n// [\n//     { id: 1, uid: 10000 },\n//     { id: 2, uid: 10000 },\n//     { id: 3, uid: 10001 }\n// ]\n```\n\n## Polyfill\n\nA polyfill is available in the [core-js][4] library. You can find it in the [ECMAScript proposals section][5].\n\n[A simple polyfill from the proposal repo write in TypeScript.](polyfill/index.ts)\n\n## Proposer\n\n-   Author: [@TechQuery](https://github.com/TechQuery)\n-   Champion: [@Jack-Works](https://github.com/Jack-Works)\n\n[1]: https://github.com/tc39/proposal-array-unique/actions/workflows/main.yml\n[2]: https://nodei.co/npm/array-unique-proposal/\n[3]: https://github.com/AndrewRot/lodash-function-usage/blob/9ec92a7980e321f8a32dd62e13addd6562ba4612/README.md\n[4]: https://github.com/zloirock/core-js\n[5]: https://github.com/zloirock/core-js#array-deduplication\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftc39%2Fproposal-array-unique","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftc39%2Fproposal-array-unique","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftc39%2Fproposal-array-unique/lists"}