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

ratev

v1.0.0

Published

ratev is a simple rate value module to rate array of object and return value based on percent 0.1 or higher than 100

Downloads

2

Readme

rate value

ratev is a simple rate value module to rate array of object and return value based on percent 0.1 or higher than 100

Installation

npm install ratev
yarn add ratev

CommonJS

const Ratev = require("ratev");
const MyfirstRate = new Ratev();

ES6

import Ratev from "ratev";
const MyfirstRate = new Ratev();

Example

const Ratev = require("ratev");
//new Ratev support array of object or ...args of object
const MyfirstRate = new Ratev([
  { rate: 90, value: "BRONZE" }, //90% chance to return BRONZE
  { rate: 70, value: "SILVER" }, //70% chance to return SILVER
  { rate: 50, value: "GOLD" }, //50% chance to return GOLD
  {
    rate: 20,
    value: "PLATINUM", //20% chance to return PLATINUM
  },
  {
    rate: 15,
    value: "DIAMOND", //15% chance to return DIAMOND
  },
  {
    rate: 10,
    value: "MASTER", //10% chance to return MASTER
  },
  {
    rate: 0.1,
    value: "GRANDMASTER", //0.1% chance to return GRANDMASTER
  },
]);
setInterval(function () {
  console.log(MyfirstRate.value); //return random value based on rate
}, 1000);

Methods

push

push new value if ther duplicate value it will be replace with new rate

MyfirstRate.push(...<Objects>);
//or
MyfirstRate.push([...<Objects>]);

EX

push(...<Objects>);

MyfirstRate.push({ rate: 0.1, value: "CHALLENGER" });
//return array of object with new value

push([...<Objects>]);

MyfirstRate.push([
  { rate: 0.1, value: "CHALLENGER" },
  { rate: 0.1, value: "GRANDMASTER" },
]);
//return array of object with new value

edit

edit multiple rate by push new rate with same value

same as push but it just edit rate

MyfirstRate.push(...<Objects>);
//or
MyfirstRate.push([...<Objects>]);

delete

delete object from array of object by value you can delete multiple value by passing multiple value

MyfirstRate.delete(...<valus>);

EX

MyfirstRate.delete("BRONZE", "SILVER", "GOLD");
//return array of object without BRONZE,SILVER,GOLD

Properties

value

return random value based on rate

MyfirstRate.value;

data

return array of object

MyfirstRate.data;

Links

License