probability-to-friendly-string
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

Package on npm: probability-to-friendly-string. Requires ES6, can be used with or without node.js.

Usage:

// This line isn't needed if you're not using through npm
import FriendlyProbability from 'probability-to-friendly-string';
let friendly = FriendlyProbability.fromProbability(.723);

friendly is a class of type FriendlyProbability that has properties

  • friendlyString: a string representing the probability (in this case "5 in 7")
  • friendlyDescription: a qualitative description of the probability ("Still possible", "Flip a coin", "Good chance", etc.)
  • numerator: the numerator of the probability (in this case 5)
  • denominator: the denominator of the probability (in this case 7)

Note that passing a value less than 0 or greater than 1 to FriendlyProbability.fromProbability() will throw an Error.

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i probability-to-friendly-string

      Weekly Downloads

      3

      Version

      1.2.1

      License

      MIT

      Unpacked Size

      8.48 kB

      Total Files

      5

      Last publish

      Collaborators

      • gregstoll