Skip to content

mafintosh/unordered-array-remove

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published