A lightweight library that counts
counting-js weighs in at 1.8KB, and provides a function with a simple API
npm i counting-js
import Count from 'counting-js';
<script type="module" src="./app.js"></script>
demo directory for an example.
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:
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.
This code is a work in progress, and contribuions and suggestions for improvements are welcome.