
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
linkedlist-js
Advanced tools
#LinkedList.js A simple doubly linked list implementation in Javascript.
npm install linkedlist-js
require the module...
var List = require('linkedlist-js').List;
instantiate a List object...
var list = new List();
// PUSH!
list.push('HUEHUE');
list.each(function (index, node) {
console.log(index + ': ' + node.value());
});
var node = list.head();
while (node != null) {
console.log(node.value());
node = node.next();
}
List
APICreates a node with the value specified, adds it to the end of the list and returns the Node
object.
var a = list.push('A');
a.value(); //'A'
Creates a node with the value specified, adds it to the beginning of the list and returns the Node
object.
var b = list.unshift('B');
b.value(); //'B'
Returns the tail Node
and removes it from the list.
var list = new List();
list.push('A');
list.push('B');
list.pop().value(); //'B'
Returns the head Node
and removes it from the list.
var list = new List();
list.push('A');
list.push('B');
list.shift().value(); //'A'
Returns the Node
at the specified index. (Linear Lookup, not very performant)
var list = new List();
list.push('A');
list.push('B');
list.push('C');
list.get(1).value(); //'B'
Returns the head Node
or null
in list is empty
var list = new List();
var node_a = list.push('A');
var node_b = list.push('B');
list.head() === node_a; // true
Returns the tail Node
or null
in list is empty
var list = new List();
var node_a = list.push('A');
var node_b = list.push('B');
list.tail() === node_b; // true
Find the node with the specified value and returns it. (Linear search, not very performant)
var list = new List();
list.push('A');
var node_b = list.push('B');
list.find('B') === node_b; // true
Sets the value of the Node
at the specifiec index.
var list = new List();
list.push('A');
list.set(0, 'B');
list.head().value(); // 'B'
Returns the number of Node
s in the list.
var list = new List();
list.push('A');
list.push('B');
list.count(); // 2
Returns true
if list has no Node
s and false
if otherwise.
var list = new List();
list.isEmpty(); // true
list.push('A');
list.isEmpty(); // false
Truncates the list to the specified size.
var list = new List();
list.push('A');
list.push('B');
list.truncateTo(1);
list.count(); // 1
Same as calling truncateTo(0)
. Empties the list.
var list = new List();
list.push('A');
list.push('B');
list.empty();
list.count(); // 0
list.isEmpty(); // true
Returns the list as an Array.
var list = new List();
list.push('A');
list.push('B');
list.asArray(); // ['A', 'B']
Node
APIReturns the value of the Node
Returns the previous Node
in the list of null
if the node is the forst Node
.
Returns the next Node
in the list of null
if the node is the last Node
.
Sets the value of the node
var node = new Node();
node.set('A');
node.value(); // 'A'
Node
node)Sets the previous pointer of the Node
var node_a = new Node();
var node_b = new Node();
node_b.setPrevious(node_a);
node_b.previous() === node_a; // true
Node
node)Sets the next pointer of the Node
var node_a = new Node();
var node_b = new Node();
node_a.setNext(node_b);
node_a.next() === node_b; // true
Retunrs true if the node is the first node in the list.
var list = new List();
list.push('A');
list.push('B');
list.head().isHead(); // true
Retunrs true if the node is the last node in the list.
var list = new List();
list.push('A');
list.push('B');
list.tail().isTail(); // true
npm test
if you have mocha installed, you may also run
mocha tests
FAQs
A Doubly Linked List Implementation in Javascript
The npm package linkedlist-js receives a total of 54 weekly downloads. As such, linkedlist-js popularity was classified as not popular.
We found that linkedlist-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.