main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
452 bytes
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var isFinite = require('../helpers/isFinite');
|
---|
| 4 |
|
---|
| 5 | var modulo = require('./modulo');
|
---|
| 6 | var ToNumber = require('./ToNumber');
|
---|
| 7 | var truncate = require('./truncate');
|
---|
| 8 |
|
---|
| 9 | // https://262.ecma-international.org/14.0/#sec-touint8
|
---|
| 10 |
|
---|
| 11 | module.exports = function ToUint8(argument) {
|
---|
| 12 | var number = ToNumber(argument);
|
---|
| 13 | if (!isFinite(number) || number === 0) {
|
---|
| 14 | return 0;
|
---|
| 15 | }
|
---|
| 16 | var int = truncate(number);
|
---|
| 17 | var int8bit = modulo(int, 0x100);
|
---|
| 18 | return int8bit;
|
---|
| 19 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.