Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@final-hill/multi-key-map

final-hill38AGPL-3.0-only1.1.4

A map implementation that supports multiple keys

multi-key-map, multi key map, multikey map, multikeymap, trie, digital-tree, digital tree, prefix-trie, prefix trie

readme

MultiKeyMap

Build npm version Downloads

Table of Contents

Introduction

This library is a map implementation that supports multiple keys. Also known as a Trie

Note that the license for this library is AGPL-3.0-only. You should know what that means before using this library. If you would like an exception to this license per section 7 contact the author.

Library Installation

As a dependency run the command:

npm install @final-hill/multi-key-map

You can also use a specific version:

npm install @final-hill/multi-key-map@1.0.0

For use in a webpage:

<script src="https://unpkg.com/@final-hill/multi-key-map"></script>

With a specific version:

<script src="https://unpkg.com/@final-hill/multi-key-map@1.0.0></script>

Usage

After installation the library can be imported as such:

import MultiKeyMap from '@final-hill/multi-key-map';

The interface is similar to the standard Map, but extended to support multiple keys:

interface MultiKeyMap<KS extends unknown[], V> {
    *[Symbol.iterator](): IterableIterator<[KS, V]>
    constructor(entries?: readonly (readonly [...KS, V])[] | null)
    clear(): void
    delete(...keys: KS): boolean
    *entries(): IterableIterator<[KS, V]>
    forEach(callbackfn: (value: V, keys: KS, multiKeyMap: MultiKeyMap<KS, V>) => void, thisArg?: any): void
    get(...keys: KS): V | undefined
    has(...keys: KS): boolean
    *keys(): IterableIterator<KS>
    set(...keysValue: [...KS, V]): this
    get size(): number
    toString(): string
    *values(): IterableIterator<V>
}

For examples view src/index.test.ts

changelog

Changelog

v1.1.4

  • Added files and types entries to package.json

v1.1.3

  • Additional github publish action fix

v1.1.2

  • Bugfix of github publish action

v1.1.1

  • Updated github actions

v1.1.0

  • added package.json keyword aliases
  • npm audit fix
  • updated dependencies
  • converted build to ECMAScript module

v1.0.2

  • Updated Contact info
  • npm audit fix