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

vilike

v0.2.2

Published

A lightweight counts of visit and like plugin.

Downloads

108

Readme

Installation

Add Vilike.js to your project.

<script src="https://unpkg.com/vilike/dist/Vilike.min.js"></script>

You can get the corresponding CDN link from unpkg or jsdelivr.

Vilike.js is available via npm, and you can also use NPM:

npm install --save vilike
# or yarn add vilike

Basic usage

Vilike.exec(pkey, skey, mode)

Get the returned data through pkey and skey, the initial value is 1. Each time this method is executed, the data on the CountAPI server will automatically increase by one.
NOTE: If the corresponding pkey and skey exist in the CountAPI service, the corresponding data will be returned directly, otherwise the default data will be created automatically.

Parameter Description

  • pkey : Fill in the primary key that needs to be queried. If it does not exist, it will be created automatically and keep the default configuration.
  • skey : Fill in the subkey that needs to be queried. If it does not exist, it will be created automatically and keep the default configuration.
  • mode : LocalStorage mode, after opening, you can use isHit to judge whether the current browser has been visited.
    • 0 : Don't open LocalStorage, and return the value of value directly after the request is successful.
    • 1 : Turn on LocalStorage, and the value of isHit can be returned after the request is successful.

E.g.

Vilike.exec('github','vilike',1).then((result) => {
  console.log(result);
});

Result

{
  isHit: true,
  value: 1
}

Advanced Usage

Vilike.create(pkey, skey, value, ctrl, upperbound)

Used to create custom data, including key value, data controllability, and data additivity.

Parameter Description

  • pkey : Primary key, usually fill in the primary domain name, such as vilike.vercel.app etc.
  • skey : Subkeys, filled with unique strings, such as Hash, MD5, etc.
  • value : The initial value of the data, the default value is 0.
  • ctrl : Used to configure whether the data can be changed or not, the default value is 0.
    • 0 : The data is locked and cannot be changed using the Vilike.update method.
    • 1 : The data is unlocked and can be changed using the Vilike.update method.
  • upperbound : The maximum limit can be added to the data, and the default value is 1.

E.g.

Vilike.create('github.zpfz','vilike', 82382, 1, 999).then((result) => {
  console.log(result);
});

Result

{
  key: "vilike"
  namespace: "github.zpfz"
  value: 82382
}

Vilike.update(pkey, skey, value, type)

Used to update the corresponding values of pkey and skey, provided that the data needs to be created with the Vilike.create method and the value of ctrl is guaranteed to be 1.

Parameter Description

  • pkey : Fill in the primary key to be queried.
  • skey : Fill in the subkey that needs to be queried.
  • value : Fill in the value that needs to be updated, the default value is divided into two cases:
    • When type is 0: value The default value is 0.
    • When type is 1: value The default value is 1.
  • type : Set the data change type.
    • 0 : Replace the original data, you can replace the original data.
    • 1 : Additive counters that can be superimposed on the original data upwards.

E.g. 1

Vilike.update('github.zpfz','vilike', 565, 0).then((result) => {
  console.log(result);
});

Result

{
  old_value: 82382,
  value: 565
}

E.g. 2

Vilike.update('github.zpfz','vilike', 565, 1).then((result) => {
  console.log(result);
});

Result

{
  value: 1130
}

Vilike.info(pkey, skey)

Used to query all the information of the current data.

Parameter Description

  • pkey : Fill in the primary key to be queried.
  • skey : Fill in the subkey that needs to be queried.

E.g.

Vilike.info('github.zpfz','vilike').then((result) => {
  console.log(result);
});

Result

{
  created: 1622122993446
  enable_reset: true
  key: "vilike"
  namespace: "github.zpfz"
  ttl: 15769999666
  update_lowerbound: 0
  update_upperbound: 999
  value: 1130
}

NOTE: The fields above are in order: creation time, whether the data can be changed, subkey, primary key, TTL, maximum limit for data reduction, maximum limit for data addition, current value.

Contributors

This project exists thanks to all the people who contribute.

Feng L.H.

License

RVerify © 2020-present, Feng L.H. Released under the MIT License.