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

@xstd/deep-map

v1.0.0

Published

A deep Map

Readme

npm (scoped) npm NPM npm type definitions coverage

@xstd/deep-map

A deep Map implementation.

📦 Installation

yarn add @xstd/deep-map
# or
npm install @xstd/deep-map --save

📜 Documentation

The DeepMap object holds key-value pairs where the key is an Iterable of unknown values.

export declare class DeepMap<GValue> {
  
  constructor(input?: Iterable<readonly [DeepMapKey, GValue]>);
  
  /**
   * The number of elements present in the DeepMap.
   */
  get size(): number;
  
  /**
   * Adds a new element with a specified key and value to the DeepMap.
   * If an element with the same key already exists, the element will be updated.
   */
  set(key: DeepMapKey, value: GValue): this;
  
  /**
   * Returns the element associated with the specified key from the DeepMap.
   *
   * @returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
   */
  get(key: DeepMapKey): GValue | undefined;
  
  /**
   * Returns `true` if the element associated with the specified key exists in the DeepMap
   *
   * @returns boolean indicating whether an element with the specified key exists or not.
   */
  has(key: DeepMapKey): boolean;
  
  /**
   * Returns the element associated with the specified key from the DeepMap.
   * If this element does not exist, then `factory` is called, the returned value is inserted in the DeepMap, and this value is returned.
   *
   * @returns the value existing or inserted associated with the specified key.
   */
  upsert(key: DeepMapKey, factory: () => GValue): GValue;
  
  /**
   * Removes the element associated with the specified key from the DeepMap.
   *
   * @returns true if an element in the DeepMap existed and has been removed, or false if the element does not exist.
   */
  delete(key: DeepMapKey): boolean;
  
  /**
   * Removes all elements from the DeepMap.
   */
  clear(): void;
  
  /**
   * Returns an Iterable of key/value pairs for every entry in the DeepMap.
   */
  entries(): Generator<readonly [DeepMapKey, GValue]>;
  
  /**
   * Returns an Iterable of keys in the DeepMap.
   */
  keys(): Generator<DeepMapKey>;
  
  /**
   * Returns an Iterable of values in the DeepMap.
   */
  values(): Generator<GValue>;
  
  /**
   * Returns an Iterable of entries in the DeepMap.
   */
  [Symbol.iterator](): Generator<readonly [DeepMapKey, GValue]>;
  
  /**
   * Executes the provided function once per each key/value pair in the DeepMap.
   */
  forEach(callbackFnc: (value: GValue, key: DeepMapKey, map: this) => void): void;
}

Example

const pool = new DeepMap<WebSocket>();

function getWebSocketFromPool(url: string | URL, protocol?: string): WebSocket {
  return pool.upsert([url.toString(), protocol], () => new WebSocket(url, protocol));
}

const ws1 = getWebSocketFromPool('wss://echo.websocket.org/');
const ws2 = getWebSocketFromPool('wss://echo.websocket.org/');
console.assert(ws1 === ws2);