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

remove-item-array

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remove-item-array

remove array duplicates or customized with JS

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

remove-item-array

πŸŒͺremove array duplicates or customized with JS.

⭐️ Usage

install:

yarn add remove-item-array
npm install remove-item-array --save

use:

const {
    removeItems,
    removeDuplicates
} = require('remove-item-array')

let arr = ['🐏', '🐈', '🐏','🐫','🐈','🐏','🐏','🐈','🐏','🐈','🐫']

// remove all
removeDuplicates(arr)

// or remove '🐏'
removeDuplicates(arr, '🐏')

// remove nums
removeItems(arr, 1, 4)

πŸ“¦ API

removeDuplicates(arr, item(?))

Removes item duplicates from an array.

Parameters
  • arr: {Array<*>} The target array.
  • item: {<*>} Removes item specified duplicate.

removeItems(arr, start, count)

Performs better to splice, use Proxy can compare splice with removeItems.

Parameters
  • arr: {Array<*>} The target array.
  • start: {Number} start The index to begin removing.
  • count: The count of items need to remove.

πŸ’Ž Compare

The function that removes all repeating elements, I code four methods, and made a comparison.

The array:

arr = [1, 1, 2, 5, 3, 1, 1, 2, 5, 3, 1, 1, 2, 5, 3, 1, 1, 2, 5, 3, 1, 1, 2, 5, 3, 1, 1, 2, 5, 3, 1, 1, 2, 5, 3]

You can view the results via the https://jsperf.com/removeduplicatesarray

The results:

By comparison, it can be seen that the performance of filter() is better, so the function adopts the filter().

βœ… Test

just run

yarn test

πŸ“œ MIT

MIT.

Keywords

FAQs

Package last updated on 22 Oct 2019

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