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 🙏

© 2025 – Pkg Stats / Ryan Hefner

js-dast

v1.1.2

Published

Implementation of useful data-structures in vanilla JavaScript. Linked list, stack, queue, sorted array and type safe extensions for these collections, plus array and set.

Downloads

4

Readme

js-dast

Implementation of useful data-structures in vanilla JavaScript.

Linked list, stack, queue, sorted array and type safe extensions for these collections, plus array and set.

See the package source on GitHub for more details.

Refer to js-dast documentation for more information.

Installation

npm install js-dast

Importing

import {
    LinkedList,
    TypeSafeLinkedList,
    Queue,
    TypeSafeQueue,
    Stack,
    TypeSafeStack,
    TypeSafeSet,
    TypeSafeArray,
    TypeSafeSortedArray,
    TYPE,
    COMPARE,
    getType,
    getArrayType,
    isType
} from "js-dast"; // ES6 import

import * as dast from "js-dast" // ES6 import all as alias

Usage

import {
    LinkedList,
    TypeSafeLinkedList,
    Queue,
    TypeSafeQueue,
    Stack,
    TypeSafeStack,
    TypeSafeSet,
    TypeSafeArray,
    TypeSafeSortedArray,
    TYPE,
    COMPARE,
    getType,
    getArrayType,
    isType
} from "js-dast";

/**
 * Create a collection
 */
// Create a new collection with constructor.
new Queue("foo", "bar", "baz");
// Or use static factory methods {from, of}.
Stack.from(["foo", "bar", "baz"]);

/**
 * Create a type safe collection
 */
// Create a new type safe collection with constructor, and {TYPE} constant to set the collection type.
new TypeSafeLinkedList(TYPE.STRING, "foo", "bar");
// Or use {getType} function to get the type of an element.
new TypeSafeSet(getType("foo"), "foo", "bar");
// Or use type safe static factory methods {from, of}, that will figure the elements type automatically.
TypeSafeArray.of("foo", "bar");
// This will throw an Error, as not all elements are of the same type.
TypeSafeQueue.from(["foo", "bar", 0, 1]);

/**
 * Type helper functions
 */
// {TYPE} constant stores common types references.
getType("foo"); // Gets an element type.
getArrayType(["foo", "bar", "baz"]); // Gets an array type.
getArrayType(["foo", "bar", 1, 2, 3]); // Will result in {undefined}.
isType("foo", TYPE.STRING); // Checks if element is of specific type.

/**
 * Using compare functions and sorted array
 */
// {COMPARE} constant stores common compare functions references.
// Set a compare function to a sorted array, upon initialization, using {COMPARE} constant.
new TypeSafeSortedArray(TYPE.NUMBER, COMPARE.NUMBER_DESCENDING, 1, 3, 2, 8, 5)
// Or sort any array or list using this constant.
const list = new LinkedList(1, 3, 2, 8, 5);
list.sort(COMPARE.NUMBER);
// Or set a compare function of your own.
const compare = (a, b) => a.name.localeCompare(b.name);
const sortedArray = new TypeSafeSortedArray(TYPE.OBJECT, compare, {name: "Foo", age: 33}, {name: "Bar", age: 32});
// Sorted array compare function could be reset, resulting in resorting the array.
const newCompare = (a, b) => a.age - b.age;
sortedArray.setCompareFunction(newCompare);

/**
 * Iterate over collections
 */
// All implemented collections are iterable. Either with {for ... of} loops.
const stack = new Stack(5, 4, 3, 2, 1);
for (const entry of stack) {
    console.log(entry, "is an entry in this Stack");
}
// Or with {forEach} function.
stack.forEach((entry, index) =>
    console.log(entry, "is in index", index)
);

/**
 * Array.prototype methods
 */
// Type safe array: All Array.prototype methods are implemented, some with type safe validations.
const typedArray = TypeSafeArray.from([1, 2, 3, 4, 5]);
// This will work without any issues, as nothing is mutating the array elements.
typedArray.every(
    entry => isType(entry, TYPE.NUMBER) // true
);
// This will check if the pushed items are of type Number, and then push it to the array.
typedArray.push(6, 7, 8);
// This will throw an Error, as "foo" is of type String and not Number.
typedArray.push("foo", "bar");
// Sorted array: All non-mutating Array.prototype methods are implemented.
// This will work without any issues, as nothing is mutating the array elements.
sortedArray.filter(
    entry => entry > 3
);
// This will throw an Error, as {push} is not a method in sorted array.
sortedArray.push(0, 10);
// Instead use {add} method.
sortedArray.add(0, 10);