jaredforth / counting-js

A lightweight library that counts

Home Page:https://www.npmjs.com/package/counting-js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

npm(https://www.npmjs.com/package/counting-js) Build Status npm bundle size(https://www.npmjs.com/package/counting-js) NPM Downloads(https://www.npmjs.com/package/counting-js)

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.

About

A lightweight library that counts

https://www.npmjs.com/package/counting-js

License:MIT License


Languages

Language:JavaScript 100.0%