ccounter

1.1.2 • Public • Published

Counter

Just a simple counter that when comes to the end go back to zero and when go less than zero return to total index

Properties:
index //current index
total //total items
prev //previous index
next //next index

Example:

var totalLength = 3
// Starts from 0, you can specify a start index as second parameter
var counter = Counter(totalLength, startIndex)
counter.inc() // counter = 1
counter.inc() // counter = 2
counter.dec() // counter = 1
counter.dec() // counter = 0
counter.dec() // counter = 2

Readme

Keywords

none

Package Sidebar

Install

npm i ccounter

Weekly Downloads

1

Version

1.1.2

License

ISC

Last publish

Collaborators

  • hellopath