
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
@mpaauw/data-structures-typescript
Advanced tools
A collection of commonly used data structures written in TypeScript.
A collection of commonly used data structures written in TypeScript.
To install, simply add as an npm dependency:
npm install @mpaauw/data-structures-typescript
This library offers a variety of data structures out-of-the-box. Currently supported structures include: Hash Table, Singly-Linked List, Queue, Stack, and Binary Search Tree. See the sections below for usage instructions.
import { HashTable } from '@mpaauw/data-structures-typescript';
// instantiate a new Hash Table, choosing a default of 100 buckets
const hashTable = new HashTable<string, object>(100);
// insert a new key-value pair into the Hash Table:
hashTable.put('cat', {
name: 'Ms. Kitty',
type: Animal.Cat,
weightInLbs: 4.20
});
// retrieve an entry from the Hash Table, given a key:
const cat = hashTable.get('cat');
// determine whether or not the Hash Table is empty:
const isEmpty = hashTable.isEmpty();
// determine whether or not the Hash Table contains a given key:
const containsCat = hashTable.contains('cat');
// remove an entry from the Hash Table, given a key:
hashTable.remove('cat');
import { SinglyLinkedList } from '@mpaauw/data-structures-typescript';
// instantiate a new Singly-Linked List:
const singlyLinkedList = new SinglyLinkedList<string>();
// insert a value into the head of the list:
singlyLinkedList.insertAtHead('red');
// insert a value into the tail of the list:
singlyLinkedList.insertAtTail('blue');
// insert a value into a specific index of the list:
singlyLinkedList.insertAt(1, 'yellow');
// attempt to find a value within the linked list:
const valueFound = singlyLinkedList.find('green');
// attempt to find the value at a specific index within the list:
const valueFoundAt = singlyLinkedList.findAt(2);
// retrieve the head of the list:
const head = singlyLinkedList.getHead();
// retrieve the tail of the list:
const tail = singlyLinkedList.getTail();
// determines if the list is empty or not:
const isEmpty = singlyLinkedList.isEmpty();
// removes value from the head of the list:
singlyLinkedList.removeAtHead();
// removes value from the tail of the list:
singlyLinkedList.removeAtTail();
// removes value from a specified index within the list:
singlyLinkedList.removeAt(2);
import { Queue } from '@mpaauw/data-structures-typescript';
// instantiate a new Queue:
const queue = new Queue<string>();
// insert a value into the tail of the Queue:
queue.enqueue('dog');
// return the value from the head of the Queue:
const peekedValue = queue.peek();
// remove and return the value from the head of the Queue:
const dequeuedValue = queue.dequeue();
// determine if the Queue is empty or not:
const isEmpty = queue.isEmpty();
import { Stack } from '@mpaauw/data-structures-typescript';
// instantiate a new Stack:
const stack = new Stack<string>();
// insert a value onto the top of the Stack:
stack.push('fish');
// return the value from the top of the Stack:
const peekedValue = stack.peek();
// remove and return the value from the top of the Stack:
const poppedValue = stack.pop();
// determine if the Stack is empty or not:
const isEmpty = stack.isEmpty();
import { BinarySearchTree } from '@mpaauw/data-structures-typescript';
// instantiate a new Binary Search Tree:
const binarySearchTree = new BinarySearchTree<number>();
// insert a value into the Tree, either iteratively or recursively:
binarySearchTree.insertIteratively(5);
binarySearchTree.insertRecursively(10);
// determine whether or not a value exists within the Tree:
const foundNode = binarySearchTree.find(9001);
// find the minimum value in the Tree, passing an optional node to be used as the subtree within the search:
const minNode = binarySearchTree.findMinimumNode(foundNode);
// find the maximum value within the Tree, passing an optional node to be used as the subtree within the search:
const maxNode = binarySearchTree.findMaximumNode(minNode);
// remove a value from the Tree, either iteratively or recursively:
binarySearchTree.removeIteratively(1337);
binarySearchTree.removeRecursively(420);
// determine whether or not the Tree is empty:
const isEmpty = binarySearchTree.isEmpty();
// validate whether or not the Tree maintains BST rules:
const isBST = binarySearchTree.validateRecursively();
FAQs
A collection of commonly used data structures written in TypeScript.
We found that @mpaauw/data-structures-typescript 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
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.