Skip to content

TypeScript utility extending Map with strict key-value type constraints

License

leumasic/constrained-map

Repository files navigation

constrained-map

Install

npm install constrained-map

Usage

import { ConstrainedMap } from 'constrained-map'

class Request { /* ... */ }
const map = new ConstrainedMap<[[Request, number], [string, string]]>

const requestKey = new Request()
map.set(requestKey, 1)

const requestValue = map.get(requestKey) // type constrained to number


const strKey = 'key'
map.set(strKey, 'value')

const strValue = map.get(strKey) // type constrained to string

Credits

  • Me, myself and I

About

TypeScript utility extending Map with strict key-value type constraints

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •