2.0.5 • Published 5 years ago

rangecal v2.0.5

Weekly downloads
29
License
MIT
Repository
github
Last release
5 years ago

rangecal

Build Status npm Version

Basic range calculations.

Installation

$ npm install rangecal --save

Usage

var rangecal = require('rangecal')

//------------------------
// amount
//------------------------
console.log(rangecal.amount(3, 6)) //-> 3
console.log(rangecal.amount(2, -8)) //-> -10

//------------------------
// rate
//------------------------
console.log(rangecal.rate(4, 6, 3)) //-> -0.5
console.log(rangecal.rate(2, 9, 6)) //-> 0.5714285714285714

//------------------------
// round
//------------------------
console.log(rangecal.round(4, 6, 3)) //-> 4
console.log(rangecal.round(2, 9, 6)) //-> 6

//------------------------
// contains
//------------------------
console.log(rangecal.contains(4, 6, 3)) //-> false
console.log(rangecal.contains(2, 9, 6)) //-> true

//------------------------
// value
//------------------------
console.log(rangecal.value(3, 6, 0.3)) //-> 3.9
console.log(rangecal.value(2, -8, 0.5)) //-> -3

API

SignatureDescription
.amount(min, max)Get amount in range.
.rate(min, max, value)Get rate for value in range.
.value(min, max, rate)Get value for rate in range.
.contains(min, max, value)Value contained in range or not.
.round(min, max, value)Round value to fit in range.

License

This software is released under the MIT License.

Links

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.1

6 years ago

2.0.0

8 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago