Return an array of duplicated values in a given array
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.editorconfig
.gitattributes
.gitignore
.travis.yml
LICENSE
README.md
index.js
index.mjs
package-lock.json
package.json
test.js

README.md

array-duplicated

npm version Build Status Coverage Status

Return duplicated values in a given Array

arrayDuplicated(['a', 2, 'b', true, 'b', 12, 'b', true, ['a']]) //=> ['b', true];

Installation

Use npm.

npm install array-duplicated

API

import arrayDuplicated from 'array-duplicated';

arrayDuplicated(array)

array: Array<any>
Return: Array

It finds duplicated values in the Array and returns an Array of them.

arrayDuplicated([0, 1, 1, 1, 1, 1, 1, 1, 1, 1]); //=> [1]

"Duplicated" means a value is identical to another value in the ECMAScript same-value equality level.

arrayDuplicated([-1, 1]); //=> []

License

ISC License © 2017 - 2018 Shinnosuke Watanabe