live-list.js
Fast linked list with live iterator. The list can be modified while iterating over the items.
Install with npm
npm install live-list
Browser compatibility
To use this module in a browser, download the npm package and then use Browserify to create a standalone version.
Usage
var List = List; var l = ;l;l;l; var v i = l;while v = inext !== undefined console;
List API
length
: Reflects the number of items in the listpush(value)
: Appends a value to the listunshift(value)
: Prepends a value to the listinsert(value, before)
: Inserts a value before another valueremove(value)
: Removes the given value from the listremoveAll()
: Removes all values from the listtoArray()
: Returns a new array with all values in the listiterator()
: Returns a newIterator
Iterator API
The iterator is derived from min-iterator and extends the API with these functions:
insert(value)
: Inserts a value into the list before the value returned by the last call tonext()
remove()
: Removes the value from the list that was returned by the last call tonext()
License
MIT