0.2.1 • Published 4 years ago

has-duplicate v0.2.1

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

has-duplicate

Build Status

Returns true if an array has duplicate elements.

Based on find-indices-of-duplicates.

Install

npm install has-duplicate --save

API

has-duplicate

Parameters

  • array Array The array to check
  • comparator Function The compare function (optional, default lodash.isequal)

Examples

import hasDuplicates from 'has-duplicate';

hasDuplicates([1, 2, 3]); // false
hasDuplicates([1, 2, 3, 1]); // true
hasDuplicates([{ v: 1 }, { v: 1 }]); // true
hasDuplicates([{ v: 1 }, { v: 2 }]); // false
hasDuplicates([{ v: 1 }, { v: 1 }], (a, b) => a === b); // false

Returns boolean True if has duplicates and false otherwise