Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

find-array-duplicate

hdkhoa16225MIT1.0.2

Find and return duplicated elements in an array.

npm, find, array, element, ele, find array element, find-array-duplicate, duplicate, duplicated elements, duplicate elements, duplicated array elements, array-find

readme

find-array-duplicate NPM total downloads

This plugin is to find and return duplicated array elements.

const findDuplicates = require('find-array-duplicate');
const testArr = [ 
    { a: 'a', b: ['a', 'b', { c: 'c' }] },
    { a: 'a', b: ['a', 'b', { c: 'c' }] }, 
    { name: 'Khoa',
        a: {
            b: {
                c: 'c'
            }
        }
    },
    'dev',
    'Khoa',
    1,
    2,
    3,
    'dev',
    {a: 'a', b: ['a', 'b', 'c'] },
    3,
    'Khoa',
    {a: 'a', b: ['a', 'b', 'c'] }
]

findDuplicates(testArr);
// [ { value: { a: 'a', b: ['a', 'b', { c: 'c' } ] }, position: [ 0, 1 ] },
//   { value: 'dev', position: [ 3, 8 ] },
//   { value: 'Khoa', position: [ 4, 11 ] },
//   { value: 3, position: [ 7, 10 ] },
//   { value: { a: 'a', b: ['a', 'b', 'c'] }, position: [ 9, 12 ] } ]

Install

$ npm install find-array-duplicate