Doubly linked list implementation for JavaScript with iterator and array-like interface
npm install doublylinked[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![Build Status][travis-image]][travis-url]
[![Test Coverage][coveralls-image]][coveralls-url]
[![Dependencies][dependencies-image]][dependencies-url]
[![DevDependencies][devdependencies-image]][devdependencies-url]
Doubly linked list implementation for JavaScript with iterator and array-like interface
$ npm install doublylinked [--save]
``js`
const list = new DoublyLinked([element1[, ..[, elementN]]]);
##### Parameters
- elementN : The elements will list contains
* DoublyLinked.prototype.concat()
* DoublyLinked.prototype.entries()
* DoublyLinked.prototype.every()
* DoublyLinked.prototype.everyRight()
* DoublyLinked.prototype.filter()
* DoublyLinked.prototype.find()
* DoublyLinked.prototype.forEach()
* DoublyLinked.prototype.forEachRight()
* DoublyLinked.prototype.includes()
* DoublyLinked.prototype.insert()
* DoublyLinked.prototype.join()
* DoublyLinked.prototype.map()
* DoublyLinked.prototype.next()
* DoublyLinked.prototype.prev()
* DoublyLinked.prototype.pop()
* DoublyLinked.prototype.push()
* DoublyLinked.prototype.reduce()
* DoublyLinked.prototype.reduce()
* DoublyLinked.prototype.reduceRight()
* DoublyLinked.prototype.remove()
* DoublyLinked.prototype.reset()
* DoublyLinked.prototype.reverse()
* DoublyLinked.prototype.shift()
* DoublyLinked.prototype.some()
* DoublyLinked.prototype.someRight()
* DoublyLinked.prototype.toArray()
* DoublyLinked.prototype.toString()
* DoublyLinked.prototype.unshift()
* [DoublyLinked.prototype[@@iterator]](#doublylinkedprototypeiterator)
Merges cursor list with and given lists/values into new list.
list.concat(otherList1[, element1[, ...[otherList2]]])
##### Parameters
- valueN : Lists and/or values to concatenate into a new list
- Return value : A new DoublyLinked instance
Returns the iterator object contains entries
list.entries()
##### Parameters
- Return value : A new iterator object.
Tests whether all elements in the list pass the test implemented by the provided function (from left to right)
list.every(callback[, thisArg])
##### Parameters
- callback : Function to test for each element, taking three arguments:
- currentValue : The current element being processed in the list
- index : The index of the current element being processed in the list
- list : The list every was called upon
- thisArg : Value to use as this when executing callback
- Return value : true if the callback function returns a truthy value for every list element; otherwise, false
Tests whether all elements in the list pass the test implemented by the provided function (from right to left)
list.everyRight(callback[, thisArg])
##### Parameters
- callback : Function to test for each element, taking three arguments:
- currentValue : The current element being processed in the list
- index : The index of the current element being processed in the list
- list : The list every was called upon
- thisArg : Value to use as this when executing callback
- Return value : true if the callback function returns a truthy value for every list element; otherwise, false
Creates a new list with all elements that pass the test implemented by the provided function
list.filter(callback[, thisArg])
##### Parameters
- callback : Function to test for each element, taking three arguments:
- element : The current element being processed in the list
- index : The index of the current element being processed in the list
- list : The list every was called upon
- thisArg : Value to use as this when executing callback
- Return value : A new list with the elements that pass the test
Returns the value of the first element in the list that satisfies the provided testing function. Otherwise undefined is returned
list.find(callback[, thisArg])
##### Parameters
- callback : Function to test for each element, taking three arguments:
- element : The current element being processed in the list
- index : The index of the current element being processed in the list
- list : The list every was called upon
- thisArg : Value to use as this when executing callback
- Return value : A value in the list if an element passes the test; otherwise, undefined
Executes a provided function once for each list element (from left to right)
list.forEach(callback[, thisArg])
##### Parameters
- callback : Function to test for each element, taking three arguments:
- element : The current element being processed in the list
- index : The index of the current element being processed in the list
- list : The list every was called upon
- thisArg : Value to use as this when executing callback
- Return value : Value to use as this when executing callback
Executes a provided function once for each list element (from right to left)
list.forEachRight(callback[, thisArg])
##### Parameters
- callback : Function to test for each element, taking three arguments:
- element : The current element being processed in the list
- index : The index of the current element being processed in the list
- list : The list every was called upon
- thisArg : Value to use as this when executing callback
- Return value : Value to use as this when executing callback
Determines whether an list includes a certain element, returning true or false as appropriate
list.includes(searchElement[, fromIndex])
##### Parameters
- searchElement : The element to search for
- fromIndex : The position in this list at which to begin searching for searchElement. A negative value searches from the index of list.length + fromIndex by asc. Defaults to 0.
- Return value : true if the searchElement found in the list; otherwise, false
Adds one or more elements right after the cursor node of the list and returns the new length of the list
list.insert(element1[, ...[, elementN]])
##### Parameters
- elementN : The elements to add right after the cursor
- Return value : The new length of the list
Adds one or more elements right after the cursor node of the list and returns the new length of the list
list.join([separator])
##### Parameters
- separator : Specifies a string to separate each pair of adjacent elements of the list
- Return value : A string with all list elements joined. If length is 0, the empty string is returned
Creates a new list with the results of calling a provided function on every element in the calling list
list.map(callback[, thisArg])
##### Parameters
- callback : Function to test for each element, taking three arguments:
- currentValue : The current element being processed in the list
- index : The index of the current element being processed in the list
- list : The list every was called upon
- thisArg : Value to use as this when executing callback
- Return value : A new list with each element being the result of the callback function
Moves cursor to the next and returns its value
list.next()
##### Parameters
- Return value : Returns value of next node to the cursor. If cursor reaches to the end it returns undefined
Moves cursor to the previous and returns its value
list.prev()
##### Parameters
- Return value : Returns value of previous node to the cursor. If cursor reaches to the head it returns undefined
Removes the last element from the list and returns that element
list.pop()
##### Parameters
- Return value : The removed element from the list; undefined if the list is empty.
Adds one or more elements to the end of the list and returns the new length of the list
list.push(element1[, ...[, elementN]])
##### Parameters
- elementN : The elements to add to the end of the list
- Return value : The new length of the list
Applies a function against an accumulator and each element in the list (from left-to-right) to reduce it to a single value
list.reduce(callback[, initialValue])
##### Parameters
- callback : Function to test for each element, taking three arguments:
- accumulator : The accumulator accumulates the callback's return values; it is the accumulated value previously returned in the last invocation of the callback, or initialValue, if supplied.
- currentValue : The current element being processed in the list
- currentIndex : The index of the current element being processed in the list
- list : The list every was called upon
- initialValue : Value to use as the first argument to the first call of the callback
- Return value : The value that results from the reduction
Applies a function against an accumulator and each element in the list (from right-to-left) to reduce it to a single value
list.reduceRight(callback[, initialValue])
##### Parameters
- callback : Function to test for each element, taking three arguments:
- accumulator : The accumulator accumulates the callback's return values; it is the accumulated value previously returned in the last invocation of the callback, or initialValue, if supplied.
- currentValue : The current element being processed in the list
- currentIndex : The index of the current element being processed in the list
- list : The list every was called upon
- initialValue : Value to use as the first argument to the first call of the callback
- Return value : The value that results from the reduction
Resets cursor to head
list.reset()
##### Parameters
- Return value : Returns the DoublyLinked instance which this method is called
Reverses a list in place. The first array element becomes the last, and the last list element becomes the first
list.reverse()
##### Parameters
- Return value : Returns the DoublyLinked instance which this method is called
Removes the first element from the list and returns that element
list.shift()
##### Parameters
- Return value : The removed element from the list; undefined if the list is empty
Tests whether all elements in the list pass the test implemented by the provided function (from left to right)
list.some(callback[, thisArg])
##### Parameters
- callback : Function to test for each element, taking three arguments:
- currentValue : The current element being processed in the list
- index : The index of the current element being processed in the list
- list : The list every was called upon
- thisArg : Value to use as this when executing callback
- Return value : Value to use as this when executing callback
Tests whether all elements in the list pass the test implemented by the provided function (from right to left)
list.someRight(callback[, thisArg])
##### Parameters
- callback : Function to test for each element, taking three arguments:
- currentValue : The current element being processed in the list
- index : The index of the current element being processed in the list
- list : The list every was called upon
- thisArg : Value to use as this when executing callback
- Return value : Value to use as this when executing callback
Returns a new array containing elements of the list
list.toArray()
##### Parameters
- Return value : A new Array instance contains elements of the list
Returns a string representing the specified list and its elements
list.toString()
##### Parameters
- Return value : Returns a string representing the specified list and its elements.
Adds one or more elements to the beginning of the list the new length of the list
list.unshift(element1[, ...[, elementN]])
##### Parameters
- elementN : The elements to add to the front of the list
- Return value : The new length of the list
Returns the iterator object contains entries
const iterator = list[Symbol.iterator]()
`js`
for (const val in list) {
...
}
##### Parameters
- Return value : Returns the iterator object contains entries
#### cursor
Returns current located node of the list
#### head
Returns first node of the list
#### length
Returns the element count of the list
#### head
Returns last node of the list
- node >= 6.0`;
[npm-image]: https://img.shields.io/npm/v/doublylinked.svg
[npm-url]: https://npmjs.org/package/doublylinked
[travis-image]: https://img.shields.io/travis/panates/doublylinked/master.svg
[travis-url]: https://travis-ci.org/panates/doublylinked
[coveralls-image]: https://img.shields.io/coveralls/panates/doublylinked/master.svg
[coveralls-url]: https://coveralls.io/r/panates/doublylinked
[downloads-image]: https://img.shields.io/npm/dm/doublylinked.svg
[downloads-url]: https://npmjs.org/package/doublylinked
[gitter-image]: https://badges.gitter.im/panates/doublylinked.svg
[gitter-url]: https://gitter.im/panates/doublylinked?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
[dependencies-image]: https://david-dm.org/panates/doublylinked/status.svg
[dependencies-url]:https://david-dm.org/panates/doublylinked
[devdependencies-image]: https://david-dm.org/panates/doublylinked/dev-status.svg
[devdependencies-url]:https://david-dm.org/panates/doublylinked?type=dev
[quality-image]: http://npm.packagequality.com/shield/doublylinked.png
[quality-url]: http://packagequality.com/#?package=doublylinked