{"id":22021480,"url":"https://github.com/lamansky/unique-array-by","last_synced_at":"2026-04-28T21:32:02.915Z","repository":{"id":57386304,"uuid":"114898055","full_name":"lamansky/unique-array-by","owner":"lamansky","description":"[Node.js] Filters an array by testing uniqueness with a callback, an index, or a key.","archived":false,"fork":false,"pushed_at":"2017-12-20T15:26:43.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T02:06:34.153Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lamansky.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-20T14:44:38.000Z","updated_at":"2017-12-20T15:26:43.000Z","dependencies_parsed_at":"2022-09-02T01:11:39.196Z","dependency_job_id":null,"html_url":"https://github.com/lamansky/unique-array-by","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Funique-array-by","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Funique-array-by/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Funique-array-by/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lamansky%2Funique-array-by/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lamansky","download_url":"https://codeload.github.com/lamansky/unique-array-by/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245084931,"owners_count":20558307,"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":[],"created_at":"2024-11-30T06:12:15.221Z","updated_at":"2026-04-28T21:31:57.881Z","avatar_url":"https://github.com/lamansky.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# unique-array-by\n\nFilters an array by testing uniqueness with a callback, an index, or a key.\n\nOptionally lets you set a numeric limit on total unique values returned.\n\nIf you merely need to remove duplicate values from an array, use the simpler [deduplicate](https://github.com/lamansky/deduplicate) module instead.\n\n## Installation\n\n```bash\nnpm install unique-array-by --save\n```\n\nThe module exports a single function.\n\n## Usage Example\n\nLet’s say you have an array of person objects and you only want one person with any given name.\n\n```javascript\nconst uniqueArrayBy = require('unique-array-by')\n\nconst people = [\n  {name: 'John'},\n  {name: 'John'},\n  {name: 'Stephen'},\n]\n\nuniqueArrayBy(people, 'name') // [{name: 'John'}, {name: 'Stephen'}]\n```\n\nOr you can use a callback that retrieves the significant value:\n\n```javascript\nuniqueArrayBy(people, person =\u003e person.name) // [{name: 'John'}, {name: 'Stephen'}]\n```\n\nYou can also use the `limit` argument to cap the number of total unique values returned:\n\n```javascript\nuniqueArrayBy(people, 'name', {limit: 1}) // [{name: 'John'}]\n```\n\n## Related Projects\n\n* [deduplicate](https://github.com/lamansky/deduplicate)\n* [unique-iterable](https://github.com/lamansky/unique-iterable)\n* [unique-iterable-by](https://github.com/lamansky/unique-iterable-by)\n* [unique-map](https://github.com/lamansky/unique-map)\n* [unique-map-by](https://github.com/lamansky/unique-map-by)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamansky%2Funique-array-by","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flamansky%2Funique-array-by","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flamansky%2Funique-array-by/lists"}