npm

Need private packages and team management tools?Check out npm Orgs. »

rate-map

1.0.5 • Public • Published

rate-map

npm version Build Status Coverage Status

Map a number in the range of 0-1 to a new value with a given range

import rateMap from 'rate-map';
 
rateMap(0.5, 0, 100); //=> 50
rateMap(0.5, 100, 200); //=> 150
rateMap(0.5, -100, 100); //=> 0

Installation

Use npm.

npm install rate-map

API

rateMap(value, start, end)

value: number in the range of 0..1
start: number
end: number
Return: number

rateMap(0.1, 0, -1); //=> -0.1
rateMap(0.1, 1, -1); //=> -0.8
rateMap(0.1, -1, -2); //=> -1.1
 
rateMap(0, 5, 5); //=> 5
rateMap(0.5, 5, 5); //=> 5
rateMap(1, 5, 5); //=> 5

License

ISC License © 2018 Shinnosuke Watanabe

install

npm i rate-map

Downloadsweekly downloads

817

version

1.0.5

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability