Frontend/25_01_07/mai/node_modules/es-abstract/2023/ToUint8.js
szabomarton 7f4a15b9c3 asd
2025-01-28 11:38:27 +01:00

20 lines
457 B
JavaScript

'use strict';
var isFinite = require('math-intrinsics/isFinite');
var modulo = require('./modulo');
var ToNumber = require('./ToNumber');
var truncate = require('./truncate');
// https://262.ecma-international.org/14.0/#sec-touint8
module.exports = function ToUint8(argument) {
var number = ToNumber(argument);
if (!isFinite(number) || number === 0) {
return 0;
}
var int = truncate(number);
var int8bit = modulo(int, 0x100);
return int8bit;
};