source: imaps-frontend/node_modules/es-abstract/2021/ToIntegerOrInfinity.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 600 bytes
Line 
1'use strict';
2
3var abs = require('./abs');
4var floor = require('./floor');
5var ToNumber = require('./ToNumber');
6
7var $isNaN = require('../helpers/isNaN');
8var $isFinite = require('../helpers/isFinite');
9var $sign = require('../helpers/sign');
10
11// https://262.ecma-international.org/12.0/#sec-tointegerorinfinity
12
13module.exports = function ToIntegerOrInfinity(value) {
14 var number = ToNumber(value);
15 if ($isNaN(number) || number === 0) { return 0; }
16 if (!$isFinite(number)) { return number; }
17 var integer = floor(abs(number));
18 if (integer === 0) { return 0; }
19 return $sign(number) * integer;
20};
Note: See TracBrowser for help on using the repository browser.