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

@dsts/linked-list

v0.0.18

Published

Linked List Data Structure in TypeScript

Downloads

6

Readme

DataStructures TS

Linked List


The Linked List is a linear structure of Nodes. Each node is a seperate object. Each data item (Node) is made with a relationship to its nextNode.

This is the Linked List Package of Data Structures TS.


Setup

The commmands below provide package manager install instructions.

NPM


npm i @dsts/linked-list -D

Yarn


yarn add @dsts/linked-list -D

Usage

New Linked Lists can be created by importing the Linked List and setting them up similarly to the example below.


import { LinkedList } from '@dsts/linked-list'

const List = new LinkedList()
List.appendNode('foo')
List.appendNode('bar')

Furthermore, the Linked List accepts nodes with a name and data. This creates the ability to find Nodes and also contain useful data with them.


import { LinkedList } from '@dsts/linked-list'

const List = new LinkedList()
List.appendNode('foo', data)
List.appendNode('foo', data)

API

Linked List Illustration

Listed below is the Linked List API. This Linked List utility is built as a calss

Node Arguments

name: when adding a Node a string is always required

ex: const List = LinkedList(); List.appendNode('foo')

data: a data {object} for containing useful data with a Node

ex: const List = LinkedList(); List.appendNode('foo', { name: 'foo' })

Methods

appendNode(name, data): adds a Node with a name and an optional data {object} to the List.

ex: List.appendNode('foo')

removeNode(name): removes a Node by name from the List

ex: List.removeNode('foo')

traverseList(fn): envokes a callback function (fn) on each node within a list

ex: const fn = (node) => console.log("This node's name is ", node.name); List.removeNode(fn)

appendNodeAt(index, name): moves a pre-existing node to a certain position within the list by index and name

ex: List.appendNodeAt(2, 'foo')

reverseList: reverses the order of Nodes within a List

ex: List.reverseList()

findNode(name): finds a Node within a List based on Node name

ex: List.findNode('foo')

toArray: returns a List as an array

ex: List.toArray()

getIndexOfNode(name): returns the index of Node with a list based on Node name

ex: List.getIndexOfNode('foo')

length: returns the length of the List

ex: List.length()

clear: clears the List

ex: List.clear()

removeDuplicateNodes: removes nodes that have the same name

ex: List.removeDuplicateNodes()

constructNewList: creates a new List with an array of Nodes

ex: const nodes = [{ name: 'foo' }, { name: 'bar' }];List.constructNewList(nodes)


Resources

The list below provides links to other helpful tools for understanding the Linked List data structure.

Code Examples