New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

just-a-list

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

just-a-list

a linked-list implementation

  • 0.2.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
285
increased by7.55%
Maintainers
1
Weekly downloads
 
Created
Source

just-a-list

A linked list implementation that draws on wikipedia's article on linked lists for available operations.


Objects

List
The linked list object returned when require is called on this library

var List = require('just-a-list');
var list = new List();

Node
The returned object type after insertion or removal from the list

var list = new List();
var node = list.insertBeginning('hello');
// list.head === node
// node.data === 'hello'
// node.next === null

Methods

insertBeginning(data)
Inserts data to the beginning of the list

var text = "hello my name is simon";
list.insertBeginning(text);

insertAfter(node, data)
Inserts data after the passed-in node

var intro = "hello my name";
var name = "is simon";
var node = list.insertBeginning(intro);
list.insertAfter(node, name);

removeBeginning()
Remove data from the beginning of the list

// list.length() === 6
var node = list.removeBeginning();
// list.length() === 5
// node.data === "some data"

removeAfter(node)
Remove data after the passed-in node

var removedNode = list.removeAfter(node);

clear()
A convenience method that calls removeBeginning() until the list is empty

// list.length() === 5
list.clear();
// list.length() === 0

reverse()
A convenience method that reverses the list

// list: 5 -> 6 -> 1 -> 4
list.reverse();
// list: 4 -> 1 -> 6 -> 5

Properties

head
The first node in the list

list.insertBeginning("hello");
console.log(list.head.data);
//> hello
list.insertBeginning("my name is");
console.log(list.head.next.data);
//> hello

length
The length of the list

console.log(list.length);
//> 5

Keywords

FAQs

Package last updated on 02 Nov 2012

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc