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 🙏

© 2024 – Pkg Stats / Ryan Hefner

map-utility-functions

v0.1.0

Published

A utility function library for working with ES2015 map objects.

Downloads

2

Readme

map-utility-functions

A utility function library for working with ES2015 map objects.

API

assign(target: Map, sources: ...Map): Map

Works the same as Object.assign, but for maps instead of objects.

const assign = require('map-utility-functions').assign;
// import { assign } from 'map-utility-functions'; // ES2015 syntax
const x = new Map();
x.set('key1', 1);
x.set('key2', 2);
const y = new Map();
y.set('key2', 5);
y.set('key3', 6);
assign(x, y); // Map { 'key1' => 1, 'key2' => 5, 'key3' => 6 }

every(map: Map, callback: function(value: *, key: *, map: Map): boolean, thisArg: *): boolean

Works the same as Array.every, but for maps instead of arrays.

const every = require('map-utility-functions').every;
// import { every } from 'map-utility-functions'; // ES2015 syntax
const x = new Map();
x.set('key1', 5);
x.set('key2', 6);
every(x, (value) => value > 1); // true
every(x, (value, key) => key.startsWith('test')); // false

filter(map: Map, callback: function(value: *, key: *, map: Map): boolean, thisArg: *): Map

Works the same as Array.filter, but for maps instead of arrays.

const filter = require('map-utility-functions').filter;
// import { every } from 'map-utility-functions'; // ES2015 syntax
const x = new Map();
x.set('key1', 1);
x.set('key2', 2);
const y = filter(x, (value) => value > 1); // Map { 'key2' => 2 }
const z = filter(x, (value, key) => key === 'key1'); // Map { 'key1' => 1 }

reduce(map: Map, callback: function(accumulator: *, value: *, key: *, map: Map): *, initialValue: *): *

Works the same as Array.reduce, but for maps instead of arrays.

const reduce = require('map-utility-functions').reduce;
// import { reduce } from 'map-utility-functions'; // ES2015 syntax
const x = new Map();
x.set(1, 1);
x.set(2, 2);
x.set(3, 3);
reduce(x, (accumulator, value, key) => accumulator + value + key, 0); // 12

some(map: Map, callback: function(value: *, key: *, map: Map): boolean, thisArg: *): boolean

Works the same as Array.some, but for maps instead of arrays.

const some = require('map-utility-functions').some;
// import { some } from 'map-utility-functions'; // ES2015 syntax
const x = new Map();
x.set('key1', 1);
x.set('key2', 2);
some(x, (value) => value > 0); // true
some(x, (value, key) => key.length > 10); // false