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

@sec-ant/trie-map

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sec-ant/trie-map

TS/JS Map-like data structure backed by trie

Source
npmnpm
Version
1.1.1
Version published
Weekly downloads
15
-81.48%
Maintainers
1
Weekly downloads
 
Created
Source

trie-map

This package is greatly inspired by anko/array-keyed-map.

import { TrieMap } from "@sec-ant/trie-map";

const tmap = new TrieMap<string | any[], number | string>([
  [[0, [0, [0, [0, "0"], "0"], "0"], "0"], "hello world"],
]);

console.log(tmap.set("1", "foo").get("1"));
console.log(tmap.set([1, 2], "bar").get([1, 2]));
console.log(tmap.set(["1", "2"], 256).get(["1", "2"]));
console.log(
  tmap.set(["1", ["2", [3, 4], "5"]], 1024).get(["1", ["2", [3, 4], "5"]])
);

console.log(tmap.get([0, [0, [0, [0, "0"], "0"], "0"], "0"]));

console.log(...tmap);

console.log(tmap.delete(["1", "2"]));

console.log(...tmap);

Features

  • Fully written in Typescript.
  • Pure ESM package.
  • Allows deeply nested iterable keys.
  • The underlying tree structure is trie.
  • Uses class private fields.
  • Keeps all the APIs the same with Map ensured by implements clauses.
  • Iteration is in insertion order.
  • No dependencies.

Todos

  • Type issues.
  • Unit tests.
  • Code minification. (use esm.run)

Keywords

map

FAQs

Package last updated on 13 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