npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dlinkedlist

v1.6.4

Published

Double Linked List in Javascript

Downloads

7

Readme

#dlinkedlist

Simple Doubly Linked List implemented in Javascript (using Webpack). https://github.com/ArcQ/DoublyLinkedListJS

Install:

npm install dlinkedlist

##Iteration

#####Apply To Every Node To apply a callback function one very node, use list.applyToEveryNode() which takes 1-2 arguments:

  1. callback (required), (always returns true to apply to all nodes)
  2. arg: optional, if you need to plug arguments into callback
function MakeAllNodesZero(){
  var makeNodeZero = function(currentNode,arg){
    console.log(arg.test);
    currentNode.obj = 0;
  }
  var callbackArgument = {test};
  linkedListTest.applyToEveryNode(makeNodeZero,callbackArgument);
}

//iterate takes 4-5 arguments

#####Iterate With Stop Condition To iterate and apply your callback for a select number of nodes, use list.iterate() which takes 3-4 arguments

  1. callback (required), returns true if you want to continue (return true to apply to all nodes)
  2. isForward: true for forwards iteration(required) or false backwards iteration
  3. starting node
  4. ifCircular: true if you want tail's next to be head, head's prev to be tail
  5. arg: optional, if you need to plug arguments into callback
function Iterate(){   
    var i = 0;
    var iterateCallback = function(currentNode){
        currentNode.obj = i;
        i++;
        if(i<3){
            return true;
        }
        else{
            return false;
        }
    }
    var startingNode = linkedListTest.tail.prev;
    linkedListTest.iterate(iterateCallback,false,startingNode);
  }

##Basic Usage #####Create After importing DLinkedList.js

var list = window.dLinkedList();

#####Basic Node Structure

var node = {
		obj: obj,
		next: null,
		prev: null
	};

#####Push

var newNode = list.push(1);

#####FindFirst

//Set Search Condition Callback Based on CurrentNode Value

var searchCB = function(currentNode){
                return (currentNode.obj == "2");
            };
var oneNode = linkedListTest.findFirst(searchCB);

#####Insert

//insert 8 after 5
var searchCB = function(currentNode){
                return (currentNode.obj == "1");
            };
var oneNode = linkedListTest.findFirst(searchCB);
if (oneNode !== undefined)
{
    linkedListTest.insertAfter(oneNode,2);
    linkedListTest.insertBefore(oneNode,3);
}

####Remove

var searchCB = function(currentNode){
                return (currentNode.obj == "1");
            };
var oneNode = linkedListTest.findFirst(searchCB);
linkedListTest.remove(oneNode);

####Get Next (Circular Linked List) Use this function to retrive the next node if your linked list is linked in a circular manner.

var searchCB = function(currentNode){
                return (currentNode.obj == "1");
            };
var oneNode = linkedListTest.findFirst(searchCB);var twoNode = linkedListTest.cGetNext(oneNode);

####Get Prev (Circular Linked List) Use this function to retrive the previous node if your linked list is linked in a circular manner.

var searchCB = function(currentNode){
                return (currentNode.obj == "1");
            };
var oneNode = linkedListTest.findFirst(searchCB);var threeNode = linkedListTest.cGetPrev(oneNode);