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 🙏

© 2026 – Pkg Stats / Ryan Hefner

array-ts

v0.0.5

Published

Type-safe array implementation for TypeScript

Readme

Array-TS

Type-first dense vs sparse array abstractions for TypeScript.

Goal: Let the type system tell you when undefined is possible. No reliance on runtime hole or undefined detection for correctness; correctness is encoded in the APIs you can call.

The Problem

TypeScript's native Array<T> (or T[]) does not distinguish between a logically dense sequence and a sparse structure with holes. That means both indexed access and iteration claim T even when runtime values are missing (T | undefined is possible in reality).

function getArrayWithHoles(): number[] {
  const myArray: number[] = [];
  myArray[2] = 777;
  return myArray; // [undefined, undefined, 777]
}

const myArray = getArrayWithHoles();
for (const arrayElement of myArray) {
  // type = number; but in reality it can be undefined!!!
  type justNumber = typeof arrayElement;

  console.log(arrayElement);
  // 1st iteration: undefined
  // 2nd iteration: undefined
  // 3rd iteration: 777
}

Installation

npm install array-ts

Usage

import { SparseArray, DenseArray } from "array-ts";

const sparseArray = new SparseArray<number>([1, undefined, 3]);
sparseArray.push(1);
sparseArray.set(8, 777); // add 777 at index 8, leaving holes
for (const arrayElement of sparseArray) {
  // type = number | undefined; as expected
  type numberOrUndefined = typeof arrayElement;
}

const denseArray = new DenseArray<number>();
denseArray.push(1);
denseArray.push(2);
denseArray.push(3); // no holes allowed
for (const arrayElement of denseArray) {
  // type = number; as expected
  type justNumber = typeof arrayElement;
}