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

@dmohindru/typescript-adt

v0.0.8

Published

Common Abstract datatype implementation in Typescript

Downloads

26

Readme

Introduction

Welcome to TypeScript ADT Library! This library provides implementations of common data structures using TypeScript. An interface-based approach is taken to ensure flexibility and consistency in how you interact with different data structures implementations. Whether working on a backend project with Node.js or a frontend application with React, Angular, or Vue.js, this library is designed to be easy to use and integrate.

Usage

Installation

npm install @dmohindru/typescript-adt

CommonJS

const { ArrayList } = require('@dmohindru/typescript-adt/list');

// Create List
const list = new ArrayList(['one', 'two', 'three']);

// Add Items to list
list.append('four');

// Run operation on each item
list.forEach((item, index) =>
    console.log(`[${index}] - ${item}`));

...

ES Module

import { ArrayList } from '@dmohindru/typescript-adt/list';

// Create List
const list = new ArrayList(['one', 'two', 'three']);

// Add Items to list
list.append('four');

// Run operation on each item
list.forEach((item, index) =>
    console.log(`[${index}] - ${item}`))

...

Typescript Config

For typescript to be able to find type definition files for this library make sure tsconfig.json as following settings

{
  ... other setting
  "module": "NodeNext",
  "moduleResolution": "NodeNext"
}

Interfaces and Implementations

Library is built on a robust set of interfaces to ensure consistency and flexibility. Below are the primary interfaces provided by the library and some of their implementations.

Interfaces

  • List<T>: A linear collection that allows for indexed access to elements.
  • Stack<T>: A collection that follows the Last-In-First-Out (LIFO) principle.
  • Queue<T>: A collection that follows the First-In-First-Out (FIFO) principle. (TBI)
  • Graph<T>: A collection of nodes connected by edges. (TBI)
  • Tree<T>: A hierarchical structure of nodes. (TBI)

Implementation

List<T>

  • ArrayList
// CommonJS
const { List, ArrayList } = require('@dmohindru/typescript-adt/list');

// ES Module
import { List, ArrayList } from '@dmohindru/typescript-adt/list';

Stack<T>

  • ArrayStack
// CommonJS
const { Stack, ArrayStack } = require('@dmohindru/typescript-adt/stack');

// ES Module
import { Stack, ArrayStack } from '@dmohindru/typescript-adt/stack';

Links