counter-map

a basic map that keeps count of each item you enter and cleans up only when all counters have been deleted

Usage no npm install needed!

<script type="module">
  import counterMap from 'https://cdn.skypack.dev/counter-map';
</script>

README

Counting Map

A basic map that keeps count of each unique item you set and cleans up only when all counters have been deleted.

Examples:

 const counter = new CountingMap();
 counter.set('key', 'value');

Adding and removing:

    counter.set('key', 'value');
    counter.set('key', 'value');
    counter.delete('key');

This example will keep one instance of key in the map If we run another delete:

    counter.delete('key');

no items with key 'key' are in the map

Only updating with no incrementing:

    const counter = new CountingMap();
    counter.set('key', 'value');
    counter.update('key', 'value1');