Doubly linked list implementation for JavaScript with iterator and array-like interface
$ npm install doublylinked [--save]
const list = new DoublyLinked([element1[, ..[, elementN]]]);
- 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]
Merges cursor list with and given lists/values into new list.
list.concat(otherList1[, element1[, ...[otherList2]]])
-
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()
- 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])
-
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])
-
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])
-
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])
-
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])
-
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])
-
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])
-
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]])
-
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])
-
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])
-
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()
- 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()
- 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()
- 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]])
-
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])
-
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])
-
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()
- 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()
- Return value : Returns the DoublyLinked instance which this method is called
Removes the first element from the list and returns that element
list.shift()
- 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])
-
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])
-
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()
- Return value : A new Array instance contains elements of the list
Returns a string representing the specified list and its elements
list.toString()
- 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]])
-
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]()
for (const val in list) {
...
}
- Return value : Returns the iterator object contains entries
Returns current located node of the list
Returns first node of the list
Returns the element count of the list
Returns last node of the list
- node
>= 6.0
;