0.0.1 • Published 3 years ago
@gmjs/data-container-util v0.0.1
Data Container Utilities
Some utilities for data containers such as Map and Set.
Installation
npm install --save @gmjsdata-container-utilAPI
Map
mapGetOrThrow
Gets the value from a Map or throws an error if the key is not present.
const map = new Map<string, string>([['foo', 'bar']]);
const value: string = mapGetOrThrow(map, 'foo');
console.log(value);
// 'bar'const map = new Map<string, string>([['foo', 'bar']]);
// the following line throws an error
const value: string = mapGetOrThrow(map, 'baz');0.0.1
3 years ago