{"id":17472572,"url":"https://github.com/shinnn/array-has-duplicates","last_synced_at":"2025-04-09T23:00:25.273Z","repository":{"id":57183981,"uuid":"53038618","full_name":"shinnn/array-has-duplicates","owner":"shinnn","description":"Check if an array includes duplicated values or not","archived":false,"fork":false,"pushed_at":"2018-11-29T00:54:14.000Z","size":74,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-18T19:58:02.173Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://npm.runkit.com/array-has-duplicates","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shinnn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-03T09:37:32.000Z","updated_at":"2019-07-15T21:00:19.000Z","dependencies_parsed_at":"2022-08-23T01:20:51.182Z","dependency_job_id":null,"html_url":"https://github.com/shinnn/array-has-duplicates","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Farray-has-duplicates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Farray-has-duplicates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Farray-has-duplicates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Farray-has-duplicates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shinnn","download_url":"https://codeload.github.com/shinnn/array-has-duplicates/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247721956,"owners_count":20985083,"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-10-18T17:27:26.671Z","updated_at":"2025-04-09T23:00:25.132Z","avatar_url":"https://github.com/shinnn.png","language":"JavaScript","readme":"# array-has-duplicates\n\n[![npm version](https://img.shields.io/npm/v/array-has-duplicates.svg)](https://www.npmjs.com/package/array-has-duplicates)\n[![Build Status](https://travis-ci.com/shinnn/array-has-duplicates.svg?branch=master)](https://travis-ci.com/shinnn/array-has-duplicates)\n[![Coverage Status](https://img.shields.io/coveralls/shinnn/array-has-duplicates.svg)](https://coveralls.io/github/shinnn/array-has-duplicates)\n\nCheck if an `Array` includes duplicated values or not\n\n```javascript\narrayHasDuplicates([1, 2, 3, 4, 5]); //=\u003e false\narrayHasDuplicates([1, 2, 3, 4, 5, 1]); //=\u003e true\n```\n\n## Installation\n\n[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/).\n\n```\nnpm install array-has-duplicates\n```\n\n## API\n\n### arrayHasDuplicates(*array*)\n\n*array*: `Array\u003cany\u003e`  \nReturn: `boolean`\n\nIt returns `true` if the array includes at least one pair of duplicated values, otherwise returns `false`.\n\n```javascript\narrayHasDuplicates([3, 3, 3]); //=\u003e true\narrayHasDuplicates([3, '3', [3]]); //=\u003e false\n```\n\n*\"Duplicated\"* means a value is identical to another value in the ECMAScript [same-value equality](https://developer.mozilla.org/docs/Web/JavaScript/Equality_comparisons_and_sameness#Same-value_equality) level.\n\n```javascript\narrayHasDuplicates([0, -0]); //=\u003e false\n```\n\nNote that it ignores all empty indexes.\n\n```javascript\narrayHasDuplicates([, undefined]);\n//=\u003e false, though array[0] and array[1] are both `undefined`\n```\n\n## Tips\n\nWhen the difference between `-0` and `+0` is not important, there is no need to use this module and the [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) constructor serves the purpose.\n\n```javascript\nfunction arrayHasDuplicatesLoose(arr) {\n  return arr.length !== new Set(arr).size;\n}\n```\n\n## License\n\n[ISC License](./LICENSE) © 2018 Shinnosuke Watanabe\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Farray-has-duplicates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshinnn%2Farray-has-duplicates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Farray-has-duplicates/lists"}