Skip to content
A lightweight library that counts
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
demo
src
.babelrc
.gitignore
.npmignore
LICENSE
README.md
package-lock.json
package.json

README.md

npm npm bundle size NPM Downloads

counting-js

A lightweight library that counts

counting-js weighs in at 1.8KB, and provides a function with a simple API

Installation

Via NPM: npm i counting-js

Usage

You can include counting-js to use in your JavaScript file with:

import Count from 'counting-js';

Your JavaScript can be include in HTML:

<script type="module" src="./app.js"></script>

See the demo directory for an example.

Parameters

The Count function takes two parameters: id, which is the id of the element to count as a string, and countSpeed, which is the speed, in milliseconds at which to count.

If there is element with the id of foo that should count at 50ms, a call to Count would look like: Count('foo', 50);

The value to count to is taken from the inner HTML of the element with the given id, which must be a number, and it will count from 0.

Contributions

This code is a work in progress, and contribuions and suggestions for improvements are welcome.

You can’t perform that action at this time.