UNPKG

has-duplicates

Version:

Returns true if an array has duplicate elements or a string has duplicate characters.

12 lines (10 loc) 265 B
'use strict' /** * Returns true if the array has duplicate elements or the string has * duplicate characters. * @param {array|string} thing * @return {bool} */ module.exports = function hasDuplicates (thing) { return (new Set(thing)).size < thing.length }