Last change
on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
583 bytes
|
Line | |
---|
1 | // `Math.scale` method implementation
|
---|
2 | // https://rwaldron.github.io/proposal-math-extensions/
|
---|
3 | module.exports = Math.scale || function scale(x, inLow, inHigh, outLow, outHigh) {
|
---|
4 | if (
|
---|
5 | arguments.length === 0
|
---|
6 | /* eslint-disable no-self-compare -- NaN check */
|
---|
7 | || x != x
|
---|
8 | || inLow != inLow
|
---|
9 | || inHigh != inHigh
|
---|
10 | || outLow != outLow
|
---|
11 | || outHigh != outHigh
|
---|
12 | /* eslint-enable no-self-compare -- NaN check */
|
---|
13 | ) return NaN;
|
---|
14 | if (x === Infinity || x === -Infinity) return x;
|
---|
15 | return (x - inLow) * (outHigh - outLow) / (inHigh - inLow) + outLow;
|
---|
16 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.