npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@srexi/purecounterjs

v1.5.0

Published

A simple yet configurable native javascript counter which you can count on.

Downloads

1,735

Readme

A simple yet configurable native javascript counter you can count on.

1.4kb GZIPPED Lightweight Javascript Counter

Demo

Proudly Hosted On Github Pages

Install

NPM

npm i --save @srexi/purecounterjs

In your app.js import and initialized the module like normal.

import PureCounter from "@srexi/purecounterjs";
const pure = new PureCounter();

Vanilla

If you wish to skip the modular build and NOT use npm you can use the vanilla build like so:

CDN

<html>
    <head>
        ...
    </head>
    <body>
        ...

        <script src="https://cdn.jsdelivr.net/npm/@srexi/purecounterjs/dist/purecounter_vanilla.js"></script>
        <script>
            new PureCounter();
        </script>
    </body>
</html>

Self hosted

Download the dist/purecounter_vanilla.js file(for the minified version) or the js/purecounter.js file (for the prettified) version and include it right before your closing body tag:

<html>
    <head>
        ...
    </head>
    <body>
        ...

        <script src="dist/purecounter_vanilla.js"></script>
        <script>
            new PureCounter();
        </script>
    </body>
</html>

Or you can take the contents of the file and paste it into your bundle.js file.

How to use it:

1. Initialize PureCounter:

new PureCounter();

// Or you can customize it for override the default config.
// Here is the default configuration for all element with class 'filesizecount'
new PureCounter({
    // Setting that can't' be overriden on pre-element
    selector: ".purecounter", // HTML query selector for spesific element

    // Settings that can be overridden on per-element basis, by `data-purecounter-*` attributes:
    start: 0, // Starting number [uint]
    end: 100, // End number [uint]
    duration: 2, // The time in seconds for the animation to complete [seconds]
    delay: 10, // The delay between each iteration (the default of 10 will produce 100 fps) [miliseconds]
    once: true, // Counting at once or recount when the element in view [boolean]
    pulse: false, // Repeat count for certain time [boolean:false|seconds]
    decimals: 0, // How many decimal places to show. [uint]
    legacy: true, // If this is true it will use the scroll event listener on browsers
    filesizing: false, // This will enable/disable File Size format [boolean]
    currency: false, // This will enable/disable Currency format. Use it for set the symbol too [boolean|char|string]
    formater: "us-US", // Number toLocaleString locale/formater, by default is "en-US" [string|boolean:false]
    separator: false, // This will enable/disable comma separator for thousands. Use it for set the symbol too [boolean|char|string]
});

2. Set the element:

To use it simply add the class: 'purecounter' to an element.

<p>I can count: <span class="purecounter">0</span></p>

Lazy Loading Is Applied Out Of The Box

You can configure it per element by adding a data-purecounter-* attribute, here's an example:

<p>
    It's over (wait for it):
    <span
        data-purecounter-start="0"
        data-purecounter-end="9001"
        data-purecounter-currency="$"
        class="purecounter"
        >0</span
    >!!!
</p>
  • The end of this count will be showing $9.0 K.
  • Most settings can be overriden on the pre-element basis. The element configuration will only be used on that element.

Default Values:

If you do not override the methods default to these values:

start: 0 [uint]
end: 100 [uint]
duration: 2 [seconds|uint]
delay: 10 [milliseconds|uint]
once: true [boolean]
pulse: false [boolean:false|seconds|uint]
decimals: 0 [uint]
legacy: true [boolean]
filesizing: false [boolean]
currency: false [boolean|char|string]
separator: false [boolean|char|string]
selector: '.purecounter' [query selector]

Browser Tests By Browserstack

Browser Support

  • Chrome/Edge/Opera: Yes
  • Firefox: Yes
  • IE: 9+
  • Safari: 7+
  • MISSING A BROWSER? Make A Pull Request