@remusao/counter
TypeScript icon, indicating that this package has built-in type declarations

1.4.0 • Public • Published

@remusao/counter

A simpler counter implementation inspired by Python's Counter

Usage

const { Counter } = require('@remusao/counter');
const counter = new Counter([
  ['foo', 2],
  ['bar', 1],
]); // optional init

counter.has('foo'); // true
counter.get('foo'); // 2

counter.has('baz'); // false
counter.get('baz'); // 0
counter.incr('baz');
counter.has('baz'); // true
counter.get('baz'); // 1
counter.decr('baz');
counter.has('baz'); // false
counter.get('baz'); // 0

Readme

Keywords

none

Package Sidebar

Install

npm i @remusao/counter

Weekly Downloads

581

Version

1.4.0

License

MPL-2.0

Unpacked Size

29.4 kB

Total Files

14

Last publish

Collaborators

  • remusao