mirror of
https://github.com/joelwmale/webhook-action.git
synced 2024-08-25 08:08:00 +00:00
1ada95e04a
- Convert project to Javascript/Typescript - Allow custom headers to be passed in (optional) - Allow body to be optional
25 lines
607 B
JavaScript
25 lines
607 B
JavaScript
'use strict';
|
|
|
|
var GetIntrinsic = require('../GetIntrinsic');
|
|
|
|
var $Math = GetIntrinsic('%Math%');
|
|
|
|
var ToNumber = require('./ToNumber');
|
|
|
|
var $isNaN = require('../helpers/isNaN');
|
|
|
|
var $floor = $Math.floor;
|
|
|
|
// https://www.ecma-international.org/ecma-262/6.0/#sec-touint8clamp
|
|
|
|
module.exports = function ToUint8Clamp(argument) {
|
|
var number = ToNumber(argument);
|
|
if ($isNaN(number) || number <= 0) { return 0; }
|
|
if (number >= 0xFF) { return 0xFF; }
|
|
var f = $floor(argument);
|
|
if (f + 0.5 < number) { return f + 1; }
|
|
if (number < f + 0.5) { return f; }
|
|
if (f % 2 !== 0) { return f + 1; }
|
|
return f;
|
|
};
|