🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

iterable-keyed-map

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

iterable-keyed-map

TS/JS Map-like data structure using iterables as keys

unpublished
latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

iterable-keyed-map

This package is a Typescript-rewriting of anko/array-keyed-map. With some additional tweakings and features.

import { IterableKeyedMap } from "iterable-keyed-map";

// init
const ikmap = new IterableKeyedMap<string, string | number>();

// set
ikmap.set(["1", "2", "3"], 1);
ikmap.set(["1", "2"], 2);
ikmap.set(["3", "2", "1"], "random string");

// get
console.log(ikmap.get(["1", "2"]));
console.log(ikmap.get(["1", "2", "3"]));
console.log(ikmap.get(["3", "2", "1"]));

// iterate (in insertion order)
console.log([...ikmap]);

// delete
ikmap.delete(["1", "2"]);

// iterate
console.log([...ikmap]);

Features

  • Fully written in Typescript.
  • Pure ESM package.
  • Using class private fields.
  • The underlying tree structure is exactly the same with anko/array-keyed-map.
  • Keeping all the APIs the same with Map ensured by implements clauses.
  • Iterating in insertion order.
  • No dependencies.

Todos

  • Support custom comparison functions.
  • Unit tests.
  • Code minification. (use esm.run)

Keywords

map

FAQs

Package last updated on 12 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts