@btmills/default-map
v1.0.0
Published
An extension of ES2015's Map that provides a default value when accessing a key that has not been explicitly set.
Downloads
5
Readme
@btmills/default-map
An extension of ES2015's Map that provides a default value when accessing a key that has not been explicitly set.
import DefaultMap from '@btmills/default-map';
const counter = new DefaultMap<string, number>(() => 0);
for (const word of input) {
counter.set(word, counter.get(word) + 1);
}