JSPM

percent-calc

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q20864F
  • License MIT

Helper functions for basic percentage calculations

Package Exports

  • percent-calc

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (percent-calc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Percent Calculator

Basic helper functions for percentage based calculations

Installation

npm install percent-calc

import percent from 'percent-calc' or const percent = require('percent-calc')


Usage

as()

What is num1 as a percentage of num2

What is 20 as a percentage of 80

percent.as(20, 80) // 25.00

Params:

  • num1
  • num2
  • decimal (optional, default 2)

of()

What is num1% of num2

What is 23% of 62

percent.of(23, 62) // 14.26

Params:

  • num1
  • num2
  • decimal (optional, default 2)

ofWhat()

num1% of what is num2

30% of what is 150

percent.ofWhat(30, 150) // 500.00

Params:

  • num1
  • num2
  • decimal (optional, default 2)