source: imaps-frontend/node_modules/es-abstract/2015/ToUint16.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: 564 bytes
Line 
1'use strict';
2
3var abs = require('./abs');
4var floor = require('./floor');
5var modulo = require('./modulo');
6var ToNumber = require('./ToNumber');
7
8var $isNaN = require('../helpers/isNaN');
9var $isFinite = require('../helpers/isFinite');
10var $sign = require('../helpers/sign');
11
12// http://262.ecma-international.org/5.1/#sec-9.7
13
14module.exports = function ToUint16(value) {
15 var number = ToNumber(value);
16 if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; }
17 var posInt = $sign(number) * floor(abs(number));
18 return modulo(posInt, 0x10000);
19};
Note: See TracBrowser for help on using the repository browser.