Socket
Socket
Sign inDemoInstall

unordered-array-remove

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    unordered-array-remove

Efficiently remove an element from an unordered array without doing a splice


Version published
Maintainers
1
Install size
3.85 kB
Created

Readme

Source

unordered-array-remove

Efficiently remove an element from an unordered array without doing a splice

npm install unordered-array-remove

build status

Usage

var remove = require('unordered-array-remove')

var list = ['a', 'b', 'c', 'd', 'e']
remove(list, 2) // remove 'c'
console.log(list) // returns ['a', 'b', 'e', 'd'] (no 'c')

This works by popping the last element (which is fast because it doesn't need shift all array elements) and overwriting the removed index with this element.

License

MIT

FAQs

Last updated on 30 Mar 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc