JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 136
  • Score
    100M100P100Q74929F
  • License ISC

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

Package Exports

  • rate-map

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rate-map) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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