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

mapda

v2.0.1

Published

A library that makes working with Maps in a functional way possible.

Downloads

26

Readme

Mapda v2.0.0

Installation

Using npm:

$ npm install --save mapda

Motivation

Historically JavaScript has only had objects but no dictionaries or maps. This has resulted in objects doing the heavy lifting for both the data structure to store data as well as for dictionaries. There are a few problems with this detailed by Dr. Axel Rauschmayer in this blogpost. As of ES2015 we now have Maps to address some of these issues. The major problem with Maps as they were implemented was that they are difficult to work with JSON data and they do not have nearly enough methods to make it worth the trouble. This package alleviates those problems by having a method to convert to and from json and JavaScript Objects as well as providing map, filter and reduce functions. For more behind the motivation of this package and why you should use it see the blogpost I wrote on the overuse of Objects.

Usage

jsonToMap

converts valid json to a new Map

const json = JSON.stringify({a: 'maps', b: 'are', c: 'awesome!'});
jsonToMap(json); // Map(3) {"a" => "maps", "b" => "are", "c" => "awesome!"}

mapToJson

converts a Map containing keys that are strings to valid json

mapToJson(new Map([['a', 'maps'], ['b', 'are'], ['c', 'awesome!']])); // '{"a": "maps", "b": "are", "c": "awesome!"}'

mapToObject

converts a Map containing keys that are strings to an object

mapToObject(new Map([['a', 'maps'], ['b', 'are'], ['c', 'awesome!']])); // {a: 'maps', b: 'are', c: 'awesome!'}

objectToMap

converts an object to a Map.

objectToMap({a: 'maps', b: 'are', c: 'awesome!'}); // Map(3) {"a" => "maps", "b" => "are", "c" => "awesome!"}

map

Takes a callback function and a Map and returns a new Map. Follows same pattern as JavaScript's Array.prototype.map method.

Callback arguments

  • value - the value in the Map's key/value pair
  • key - the key in the Map's key/value pair
const myMap = new Map([['a', 'maps'], ['b', 'are'], ['c', 'awesome!']]);

map((value, key) => {
  return value = 'hi';
}, myMap) // Map(3) {"a" => "hi", "b" => "hi", "c" => "hi"}

filter

Takes a predicate function and a Map and returns a new Map containing the key/value pairs that pass the predicate function. Follows the same pattern as JavaScript's Array.prototype.filter method.

Predicate arguments:

  • value - the value in the Map's key/value pair
  • key - the key in the Map's key/value pair
const myMap = new Map([['a', 'maps'], ['b', 'are'], ['c', 'awesome!']]);

filter((value, key) => {
  return key === 'b'
}, myMap) // Map(1) {"b" => "hi"}

reduce

Takes a callback function, an initial value and a Map and returns an accumulator. Follows the same pattern as JavaScript's Array.prototype.reduce method.

Callback arguments:

  • accumulator - value to be built up as the Map's key/value pairs are iterated over.
  • value - the value in the Map's key/value pair
  • key - the key in the Map's key/value pair
const myMap = new Map([ [ 'foo', 5 ], [ 'bar', 3 ], [ 'baz', 10 ] ]);

reduce((a, v) => (a += v), 5, myMap); // 23