New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

mk2mt

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mk2mt

MK2MT stands for "Map Key to Multiple Types". Unlike JS native `Map` class which can only map keys to one type, MK2MT allows you to map specific keys to corresponding types. More, this type allows you to get values that are sharing the same key with par

latest
npmnpm
Version
0.2.4
Version published
Maintainers
1
Created
Source

MK2MT

MK2MT stands for "Map Key to Multiple Types". Unlike JS native Map class which can only map keys to one type, MK2MT allows you to map specific keys to corresponding types. More, this type allows you to get values that are sharing the same key with partially inputted keys.

Example

import { MK2MT } from 'MK2MT';

const tmp = new MK2MT<
  | [["a" | "b"   ], number ]   // map "a" and "b" to number
  | [["c"         ], string ]   // map "c" to string
  | [["a", "b"    ], boolean]   // map ("a", "b") to boolean  (order doesn't matter)
  | [["a", "d"|"e"], number ]   // map ("a", "d") and ("a", "e") to number
>();

tmp.set(1, "a");        // OK
tmp.set(2, "b");        // OK
tmp.set(3, "c");        // Error
tmp.set(4, "d");        // Error
tmp.set(5, "a", "d");   // OK

tmp.fuzzyGet("a");      // type is undefined | number[] | boolean[]
tmp.fuzzyGet("a", "d"); // type is undefined | number[]
tmp.fuzzyGet("a", "e"); // type is undefined | number[]
tmp.fuzzyGet("d");      // type is undefined | number[]

Keywords

map

FAQs

Package last updated on 03 Oct 2023

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