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

danmatrix

v2.0.0

Published

Utilities to handle and manipulate 2d-vectors

Downloads

53

Readme

DanMatrix

DanMatrix is a data structure able to handle and manipulate 2D-vectors

How to use it

import { DanMatrix } from 'danmatrix';

const matrix = new DanMatrix<string>([
  ['a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa'],
  ['b', 'bb', 'bbb', 'bbbb', 'bbbbb', 'bbbbbb'],
  ['c', 'cc', 'ccc', 'cccc', 'ccccc', 'cccccc'],
  ['d', 'dd', 'ddd', 'dddd', 'ddddd', 'dddddd'],
  ['e', 'ee', 'eee', 'eeee', 'eeeee', 'eeeeee'],
  ['f', 'ff', 'fff', 'ffff', 'fffff', 'ffffff']
]);

matrix.addRow(['g', 'gg', 'ggg', 'gggg', 'ggggg', 'gggggg']);

matrix.removeColumnAt(1);

console.log(matrix.getMatrixString());

Documentation

Scripts

Build project

npm run build

Build documentation

npm run build:doc

Run tests

npm run test

Version 2

New Features

Coordinates class

import { Coordinates } from 'danmatrix';

const coord01 = Coordinates.fromArrayCoords([3, 4]);
const coord02 = Coordinates.fromStringCoords('2;9', ';');
console.log(`coord01: ${coord01.toString()}`);
console.log(`coord02: ${coord02.toString()}`);

DanMatrixElementsIterator

import { DanMatrix } from 'danmatrix';

const myMatrix01 = new DanMatrix<number>([
  [7253, 2223, 34587],
  [21144, 563, 51],
  [11243, 663, 31],
  [81144, 2263, 151],
  [41541, 178, 11],
  [23141, 1874, 751]
]);
for (const element of myMatrix01.getElementsIterator()) {
  console.log(`Element val: ${element.val}`);
  console.log(`Element coords: ${element.coordinates.toString()}`);
}

DanMatrix class - getAdjacentElements method

import { DanMatrix } from 'danmatrix';

const myMatrix01 = new DanMatrix<number>([
  [7253, 2223, 34587],
  [21144, 563, 51],
  [11243, 663, 31],
  [81144, 2263, 151],
  [41541, 178, 11],
  [23141, 1874, 751]
]);
for (const element of myMatrix01.getElementsIterator()) {
  const adjacents = element.danMatrix.getAdjacentElements(element.coordinates);
  if (adjacents === undefined) {
    throw new Error('adjacents was supposed to be a correct object');
  }
  console.log(`Element val: ${element.val}`);
  console.log(`Adjacent vals: ${JSON.stringify(adjacents.map((elem) => { return elem.val; }))}`);
}

Breaking Changes

DanMatrix class - Modified get method

From:

public get(x: number, y: number): T | undefined

To:

public get(coord: Coordinates): T | undefined

DanMatrix class - Modified set method

From:

public set(x: number, y: number, val: T): T | undefined

To:

public set(coord: Coordinates, val: T): T | undefined

DanMatrix class - Removed getCoord method

DanMatrix class - Removed setCoord method

DanMatrix class - Modified lookForValue method

From:

public lookForValue(val: T): Array<string>

To:

public lookForValue(val: T): Array<Coordinates>