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:
573 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var ToNumber = require('./ToNumber');
|
---|
4 |
|
---|
5 | var $isNaN = require('../helpers/isNaN');
|
---|
6 | var $isFinite = require('../helpers/isFinite');
|
---|
7 | var $sign = require('../helpers/sign');
|
---|
8 |
|
---|
9 | var abs = require('./abs');
|
---|
10 | var floor = require('./floor');
|
---|
11 | var modulo = require('./modulo');
|
---|
12 |
|
---|
13 | // https://262.ecma-international.org/6.0/#sec-touint8
|
---|
14 |
|
---|
15 | module.exports = function ToUint8(argument) {
|
---|
16 | var number = ToNumber(argument);
|
---|
17 | if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; }
|
---|
18 | var posInt = $sign(number) * floor(abs(number));
|
---|
19 | return modulo(posInt, 0x100);
|
---|
20 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.