0.1.1 • Published 9 years ago

range-fit v0.1.1

Weekly downloads
11
License
MIT
Repository
github
Last release
9 years ago

range-fit Build Status

given a number and two ranges, fit from one range to another. This is basically http://stackoverflow.com/questions/929103/convert-a-number-range-to-another-range-maintaining-ratio for node.

npm install range-fit

API

(value, lowerInitial, upperInitial, lowerNew, upperNew)

Given a value, within range lowerInitial-upperInitial, return a value with the same ratio, between lowerNew-upperNew. If lowerInitial-upperInitial is 0, then we return lowerNew.

Examples

var rangeFit = require('range-fit');

var twenty = rangeFit(10, 0, 100, 0, 200);

see the tests for more.

License

Licensed under the MIT License