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

@elenakay/listmap

v0.0.0-prealpha

Published

Javascript Object With Ordered Keys

Readme

ListMap: Javascript Object With Ordered Keys

Even though an object's keys are (mostly) enumerable in Javascript, there is no guaranteed order on this enumeration; consider the following snippet:

var obj = {};

obj['a'] = 1;
obj['b'] = 2;

for (var objectKey in obj) {
  if (obj.hasOwnProperty(objectKey) {
    console.log(objectKey);
  }
}

even though a was set first, the snippet above may still produce the sequence b a, i.e., there is not guarantee that it would always print a b.

But what if we want to keep track of the order in which an object's keys were set? this is where ListMap comes in handy:

Installation

npm install listmap

Usage

var listmap = require('listmap');

var lm = new listmap.ListMap();

lm.set('a', 1);
lm.set('b', 2);
lm.set('c', 12);
lm.set('d', 40);
lm.set('e', 55);

console.log('length:', lm.length);

// traverse listmap in reverse
while (lm.length > 0) {
  var i = lm.length - 1;

  var k = lm.keyAt(i);
  console.log('key at ['+i+'] is:', k);

  var v = lm.valueAt(i);
  console.log('value at ['+i+'] is:', v);

  var kIndex = lm.locateKey(k);
  console.log('key with name ['+k+'] is located at index:', kIndex);

  lm.deleteKey(k);
  console.log('deleted key name ['+k+']; listmap.length:', lm.length);

  kIndex = lm.locateKey(k);
  if (kIndex !== -1) // never happens, since entry `k: v` has just been deleted
    throw new Error('deleted key, but located it in the key list!');

  // re-insert (k,v) into the listmap
  lm.set(k, v);

  console.log('re-inserted ['+k+': '+v+']; list.length:', lm.length);

  var valueByKey = lm.get(k);
  console.log('value at key name [' + k +'] is:', v);

  kIndex = lm.locateKey(k);
  if (kIndex === -1) // never happens, since we have just inserted `k: v`
    throw new Error('key-value was just inserted into the listmap, but it was '+
      'not anywhere in the key list!');

  lm.removeIndex(kIndex);
  console.log('removed index at ['+kIndex+']; listmap.length:', (lm).length);

  console.log('--------------------\n');
}