|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
607 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 | // `Math.scale` method implementation
|
|---|
| 3 | // https://rwaldron.github.io/proposal-math-extensions/
|
|---|
| 4 | module.exports = function scale(x, inLow, inHigh, outLow, outHigh) {
|
|---|
| 5 | var nx = +x;
|
|---|
| 6 | var nInLow = +inLow;
|
|---|
| 7 | var nInHigh = +inHigh;
|
|---|
| 8 | var nOutLow = +outLow;
|
|---|
| 9 | var nOutHigh = +outHigh;
|
|---|
| 10 | // eslint-disable-next-line no-self-compare -- NaN check
|
|---|
| 11 | if (nx !== nx || nInLow !== nInLow || nInHigh !== nInHigh || nOutLow !== nOutLow || nOutHigh !== nOutHigh) return NaN;
|
|---|
| 12 | if (nx === Infinity || nx === -Infinity) return nx;
|
|---|
| 13 | return (nx - nInLow) * (nOutHigh - nOutLow) / (nInHigh - nInLow) + nOutLow;
|
|---|
| 14 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.