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

1.3.1 • 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

27

Version

1.3.1

License

MPL-2.0

Unpacked Size

160 kB

Total Files

18

Last publish

Collaborators

  • remusao