@btmills/default-map
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@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);
}

Readme

Keywords

Package Sidebar

Install

npm i @btmills/default-map

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

3.47 kB

Total Files

7

Last publish

Collaborators

  • btmills