All Projects â†’ zdroid â†’ Percent

zdroid / Percent

Licence: mit
📈 Percent control done right

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Percent

Primesieve
🚀 Fast prime number generator
Stars: ✭ 644 (+9100%)
Mutual labels:  math
Pragmatapro
PragmataPro font is designed to help pros to work better
Stars: ✭ 887 (+12571.43%)
Mutual labels:  math
Mobius Assignment
Staffjoy Suite (V1) Microservice - Shift Assignment Subject To Constraints
Stars: ✭ 23 (+228.57%)
Mutual labels:  math
Shipjs
Take control of what is going to be your next release.
Stars: ✭ 668 (+9442.86%)
Mutual labels:  semver
Expr Eval
Mathematical expression evaluator in JavaScript
Stars: ✭ 752 (+10642.86%)
Mutual labels:  math
Binary.dart
Utilities for working with binary data and bit manipulation in Dart.
Stars: ✭ 16 (+128.57%)
Mutual labels:  math
Swix
Swift Matrix Library
Stars: ✭ 581 (+8200%)
Mutual labels:  math
Ionengine
3D graphics engine designed for rapid prototyping and extensibility
Stars: ✭ 25 (+257.14%)
Mutual labels:  math
Semver
Semantic Versioning (semver) library written in golang
Stars: ✭ 804 (+11385.71%)
Mutual labels:  semver
Theoremjs
A Math library for computation in JavaScript 📕
Stars: ✭ 917 (+13000%)
Mutual labels:  math
Mdmath
LaTeX Math for Markdown inside of Visual Studio Code.
Stars: ✭ 675 (+9542.86%)
Mutual labels:  math
Long.js
A Long class for representing a 64-bit two's-complement integer value.
Stars: ✭ 719 (+10171.43%)
Mutual labels:  math
Rpn
Math functional language, inspired by Hewlett-Packard Reverse Polish Notation (RPL) language
Stars: ✭ 17 (+142.86%)
Mutual labels:  math
Tutorials
Ipython notebooks for math and finance tutorials
Stars: ✭ 654 (+9242.86%)
Mutual labels:  math
Php Math Parser
Simple mathematical expression parser and calculator.
Stars: ✭ 24 (+242.86%)
Mutual labels:  math
Semver
Work with Semantic Versions in Go
Stars: ✭ 608 (+8585.71%)
Mutual labels:  semver
Cglm
📽 Highly Optimized Graphics Math (glm) for C
Stars: ✭ 887 (+12571.43%)
Mutual labels:  math
Hx Mathparser
Evaluates math expressions. Written in Haxe.
Stars: ✭ 7 (+0%)
Mutual labels:  math
Pas Coogeo
Pas-CooGeo is coordinate geometry library for Pascal.
Stars: ✭ 25 (+257.14%)
Mutual labels:  math
Coord Rs
[deprecated] A simple, ergonomic vector mathematics crate for Rust
Stars: ✭ 18 (+157.14%)
Mutual labels:  math

Percent

Build status devDependencies status

Percent control done right

Percent is a npm module which gives you nice options to control percentages. It's like semver for percentages.

Install

$ npm install percent

Examples

Calculate percentage

const percent = require('percent');

console.log(percent.calc(5, 20, 0)); // => 25

Validate percentage

const percent = require('percent');

if (percent.valid(5)) { // => true
  console.log('5 is a valid percent value');
}

Compare percentages

const percent = require('percent');

if (percent.lt('5%', 6)) { // => true
  console.log('a is smaller than b');
}

API

const percent = require('percent');

.calc()

Usage: percent.calc(value, total, decimal, [sign])
Example: percent.calc(5, 20, 0)

Calculates percentage from the given number (value) and total number (total) with specified number of decimals (decimal).

sign may be boolean which turns percent sign (%) addition. Returns percent value with percent sign if sign is true (it's false by default). If sign is string, it will be used as value suffix.

.re

Usage: percent.re

Returns supreme percent regexp.

.valid()

Usage: percent.valid(value)
Example: percent.valid('5%')

Checks if value is valid percent value. It is valid if it's a number, number-like string (e.g. '10', not 10), or string with number and percent sign. Spaces are allowed in strings.

.sign()

Usage: percent.sign(value)
Example: percent.sign(5)

Adds percent sign to value.

.unsign()

Usage: percent.unsign(value)
Example: percent.unsign('5%')

Removes percent sign(s) from value.

.clean()

Usage: percent.clean(value)
Example: percent.clean(' 5 % ')

Removes percent sign(s) and spaces from value.

.convert()

Usage: percent.convert(value, [negative])
Example: percent.convert(' 5 % ')

Converts percent-like string to number. Returns negative number if negative is true.

.lt()

Usage: percent.lt(l, t)
Example: percent.lt('5%', 6)

Checks is the first argument smaller than second.

.gt()

Usage: percent.gt(g, t)
Example: percent.gt('6%', 5)

Checks is the first argument greater than second.

.eq()

Usage: percent.eq(e, q)
Example: percent.eq('5%', 5)

Checks are the arguments logically equal.

.neq()

Usage: percent.neq(ne, q)
Example: percent.neq('6%', 5)

Checks are the arguments logically unequal.

.satisfies()

Usage: percent.satisfies(value, min, max)
Example: percent.satisfies(5.5, 5, 6)

Checks does the value satisfy the given range. It will exchange min and max values if min is bigger than max.

License

MIT © Zlatan Vasović

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].