drop-rate
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Description

Drop-rate is a package for calculating probabilities through ratios

Installation

npm i drop-rate
yarn add drop-rate

Usage

import random from 'drop-rate'
const rates = [
  { name: "R", rate: 60 },
  {
    name: "SR",
    rate: 33.5,
  },
  {
    name: "SSR",
    rate: 5,
  },
  {
    name: "LSSR",
    rate: 1,
  },
  {
    name: "UR",
    rate: 0.5,
  }
]

const result = random.calculate(rates)
// {name: "R", rate: 60 }

> Make sure total rate is equal `100` percents

If you want to use more:

const rates = [
  { name: "R", rate: 60, other: any },
  {
    name: "SR",
    rate: 33.5,
    other: any,
  },
  ...
]

const result = random.calculate(rates)
// {name: "R", rate: 60, other: any }

Contributing

@Medium_Hieu https://github.com/bachtuyetx7chulun

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.4
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.4
    1
  • 1.0.3
    0
  • 1.0.2
    0
  • 1.0.1
    0

Package Sidebar

Install

npm i drop-rate

Weekly Downloads

1

Version

1.0.4

License

MIT

Unpacked Size

3.38 kB

Total Files

6

Last publish

Collaborators

  • medium_hieu