Socket
Book a DemoInstallSign in
Socket

calc-percent

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

calc-percent

Calculate percent

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

calc-percent Build Status

Calculate percentage

Install

$ npm install --save calc-percent

Usage

var calcPercent = require('calc-percent');

calcPercent(10, 50);
//=> 20

calcPercent(10, 50, {suffix: '%'});
//=> 20%

calcPercent(100 / 3, 100, {decimal: 2});
//=> 33.33

API

calcPercent(val, total, opts)

val

Type: number

Value which should be calculated.

total

Type: number

Total that val should be compared against.

opts.decimal

Type: number
Default: 0

Number of decimals.

opts.suffix

Type: string

Append a suffix.

License

MIT © Kevin Mårtensson

FAQs

Package last updated on 13 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts