source: trip-planner-front/node_modules/core-js/modules/es.math.hypot.js@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 983 bytes
Line 
1var $ = require('../internals/export');
2
3// eslint-disable-next-line es/no-math-hypot -- required for testing
4var $hypot = Math.hypot;
5var abs = Math.abs;
6var sqrt = Math.sqrt;
7
8// Chrome 77 bug
9// https://bugs.chromium.org/p/v8/issues/detail?id=9546
10var BUGGY = !!$hypot && $hypot(Infinity, NaN) !== Infinity;
11
12// `Math.hypot` method
13// https://tc39.es/ecma262/#sec-math.hypot
14$({ target: 'Math', stat: true, forced: BUGGY }, {
15 // eslint-disable-next-line no-unused-vars -- required for `.length`
16 hypot: function hypot(value1, value2) {
17 var sum = 0;
18 var i = 0;
19 var aLen = arguments.length;
20 var larg = 0;
21 var arg, div;
22 while (i < aLen) {
23 arg = abs(arguments[i++]);
24 if (larg < arg) {
25 div = larg / arg;
26 sum = sum * div * div + 1;
27 larg = arg;
28 } else if (arg > 0) {
29 div = arg / larg;
30 sum += div * div;
31 } else sum += arg;
32 }
33 return larg === Infinity ? Infinity : larg * sqrt(sum);
34 }
35});
Note: See TracBrowser for help on using the repository browser.