main
Last change
on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
626 bytes
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var ToNumber = require('./ToNumber');
|
---|
| 4 |
|
---|
[79a0317] | 5 | var $isNaN = require('math-intrinsics/isNaN');
|
---|
| 6 | var $isFinite = require('math-intrinsics/isFinite');
|
---|
| 7 | var $sign = require('math-intrinsics/sign');
|
---|
| 8 | var abs = require('math-intrinsics/abs');
|
---|
| 9 | var floor = require('math-intrinsics/floor');
|
---|
| 10 | var modulo = require('math-intrinsics/mod');
|
---|
[d565449] | 11 |
|
---|
| 12 | // https://262.ecma-international.org/6.0/#sec-touint8
|
---|
| 13 |
|
---|
| 14 | module.exports = function ToUint8(argument) {
|
---|
| 15 | var number = ToNumber(argument);
|
---|
| 16 | if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; }
|
---|
| 17 | var posInt = $sign(number) * floor(abs(number));
|
---|
| 18 | return modulo(posInt, 0x100);
|
---|
| 19 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.