-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
ES5
+: add abs
, floor
; use modulo
consistently
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
'use strict'; | ||
|
||
var GetIntrinsic = require('../GetIntrinsic'); | ||
|
||
var $Math = GetIntrinsic('%Math%'); | ||
|
||
var ToNumber = require('./ToNumber'); | ||
|
||
var $isNaN = require('../helpers/isNaN'); | ||
var $isFinite = require('../helpers/isFinite'); | ||
var $sign = require('../helpers/sign'); | ||
var $mod = require('../helpers/mod'); | ||
|
||
var $floor = $Math.floor; | ||
var $abs = $Math.abs; | ||
var abs = require('./abs'); | ||
var floor = require('./floor'); | ||
var modulo = require('./modulo'); | ||
|
||
// https://ecma-international.org/ecma-262/6.0/#sec-touint8 | ||
|
||
module.exports = function ToUint8(argument) { | ||
var number = ToNumber(argument); | ||
if ($isNaN(number) || number === 0 || !$isFinite(number)) { return 0; } | ||
var posInt = $sign(number) * $floor($abs(number)); | ||
return $mod(posInt, 0x100); | ||
var posInt = $sign(number) * floor(abs(number)); | ||
return modulo(posInt, 0x100); | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.