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 🙏

© 2025 – Pkg Stats / Ryan Hefner

oz-hash-map

v0.0.6

Published

Map which can handles objects as keys

Downloads

7

Readme

hash-map

Map which can handles objects as keys.

HashMap let you decide how to search for key:

  • selectKey: Function(obj): any function to select what to use as key

HashMap implements all Map interface:

  • clear() Removes all key/value pairs from the Map object.
  • delete(key) Returns true if an element in the Map object existed and has been removed, or false if the element does not exist. has(key) will return false afterwards.
  • entries() Returns a new Iterator object that contains an array of [key, value] for each element in the Map object in insertion order.
  • forEach(callbackFn[, thisArg]) Calls callbackFn once for each key-value pair present in the Map object, in insertion order. If a thisArg parameter is provided to forEach, it will be used as the this value for each callback.
  • get(key) Returns the value associated to the key, or undefined if there is none.
  • has(key) Returns a boolean asserting whether a value has been associated to the key in the Map object or not.
  • keys() Returns a new Iterator object that contains the keys for each element in the Map object in insertion order.
  • set(key, value) Sets the value for the key in the Map object. Returns the Map object.
  • values() Returns a new Iterator object that contains the values for each element in the Map object in insertion order.
  • [@@iterator]() Returns a new Iterator object that contains an array of [key, value] for each element in the Map object in insertion order.

install

$ npm install oz-hash-map

require / import

typescript

import HashMap from 'oz-hash-map'

typescript

var HashMap = require('oz-hash-map');

Usage

let map = new HashMap()

map.set({ x:1 }, 'some value') // map.size = 1
let res1 = map.get({ x:1 }) // res1 will be 'some value'

map.set({ x:1 }, 'override value') // map.size = 1
let res2 = map.get({ x:1 }) // res1 will be 'override value'

HashMap let's you iterate it's keys and/or values:

let map = new HashMap()
map.set({ x:1 }, 'some value') 
map.set({ x:2 }, 'other value')

for (let [k, v] of map){
  console.log(k, v)
}
// output:
// Object {x: 1}
// some value
// Object {x: 2}
// other value

for (let k of map.keys()){
  console.log(k)
}
// output:
// Object {x: 1}
// Object {x: 2}

for (let v of map.values()){
  console.log(v)
}
// output:
// some value
// other value

HashMap let's you decide what to use as key:

let map = new HashMap()
let select = obj => { return { x: obj.x } }
map.selectKey = select
map.set({ x:1, y: 2 }, 'some value') 
map.set({ x:1, z: 3 }, 'override value')
// map will have only 1 item: { x:1, z: 3 }, 'override value'