API Docs for:
Show:

Utils.Counter Class

Implementation of a simple counter class

Item Index

Methods

Methods

makeCounter

(
  • max
  • now
  • min
)
Object

Returns a circular counter with value(), countTo(), countUp() and countDown() methods

Parameters:

  • max Number

    Maximum value of the counter

  • now Number

    Initial value to start counting from

  • min Number

    Minimum value of the counter

Returns:

Object:

A counter object

Example:

import makeCounter from './utils/counter';

var counter = makeCounter(3, 1);

counter.value();
// -> 1

counter.countUp(2).value();
// -> 3

counter.countUp().value();
// -> 0