/quick-maths

A chain-able, small, quick maths+utils lib

Primary LanguageJavaScriptMIT LicenseMIT

Quick Maths

Quick Maths

A chain-able, small, quick maths+utils lib qm(4).plus(1).dividedby(2).fin() -> 2.5

Usage (coming to an npm repo near you soon)

$ yarn add quick-maths
const qm = require('quick-maths');
// or
import qm from 'quick-maths';

qm(1).times(-5).dividedby(3).minus(1).plus(5).times(2).fin(2)
//=> 4.66

qm(5).times(-5).fin()
//=> -25

qm(10).roughly(10.3)
//=> true

qm(10).equals(1850)
//=> false

API

qm(input)

input

Type: int/float

The initial that quick maths will evaluate with. Used as the beginning chain component.

.plus(input)

input

Type: int/float

Value that will be added to the current number.

.minus(input)

input

Type: int/float

Value that current number will be subtracted by.

.times(input)

input

Type: int/float

Value that the current number will be multiplied by.

.dividedby(input)

input

Type: int/float

Value that the current number will be divided by.

.equals(input)

input, returns boolean

Type: int/float

Value that is checked to see if it equal to the current number. Used as an ending chain component, nothing after will be calculated.

.roughly(input)

input, returns boolean

Type: int/float

Value that is checked to see if it is within 0.5 of the current number. Used as an ending chain component, nothing after will be calculated.

.fin(input)

input, optional

Type: int

Value that will truncate decimal places, not round. Used as THE ending chain component, not to be used after .roughly or .equals.

License

MIT © Evan Kysley