range-fit

0.1.1 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i range-fit

Weekly Downloads

1

Version

0.1.1

License

MIT

Last publish

Collaborators

  • b3ngr33ni3r