Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

array-duplicates

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-duplicates

Returns the duplicated items found in an array

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
459
decreased by-9.47%
Maintainers
1
Weekly downloads
 
Created
Source

Array duplicates

Returns the duplicated items in an array.

Install

npm install array-duplicates

Usage

Given an array with duplicates, obtain the duplicated items:

const duplicates = require('array-duplicates')

console.log(duplicates([1, 2, 3, 2, 3, 4])) // [2, 3]
console.log(duplicates([{ id: 1 }, { id: 2 }, { id: 2 }], i => i.id)) // [{ id: 2 }]

API

duplicates(array[, identity])

  • array is an array containing numbers, string and/or objects.
  • identity is an optional function that will recieve each item in the array and shall return a value that represents that item. Is needed when comparing objects, otherwhise, the objects will be compared by reference instead of content.

License

WTFPL

Keywords

FAQs

Package last updated on 18 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc