Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/ drwxr-xr-x | |
| Viewing file: Select action/file-type: import { FormatNumericToString } from './FormatNumericToString';
import { SameValue } from '../262';
import { ComputeExponent } from './ComputeExponent';
import formatToParts from './format_to_parts';
/**
* https://tc39.es/ecma402/#sec-formatnumberstring
*/
export function PartitionNumberPattern(numberFormat, x, _a) {
var _b;
var getInternalSlots = _a.getInternalSlots;
var internalSlots = getInternalSlots(numberFormat);
var pl = internalSlots.pl, dataLocaleData = internalSlots.dataLocaleData, numberingSystem = internalSlots.numberingSystem;
var symbols = dataLocaleData.numbers.symbols[numberingSystem] ||
dataLocaleData.numbers.symbols[dataLocaleData.numbers.nu[0]];
var magnitude = 0;
var exponent = 0;
var n;
if (isNaN(x)) {
n = symbols.nan;
}
else if (!isFinite(x)) {
n = symbols.infinity;
}
else {
if (internalSlots.style === 'percent') {
x *= 100;
}
_b = ComputeExponent(numberFormat, x, {
getInternalSlots: getInternalSlots,
}), exponent = _b[0], magnitude = _b[1];
// Preserve more precision by doing multiplication when exponent is negative.
x = exponent < 0 ? x * Math.pow(10, -exponent) : x / Math.pow(10, exponent);
var formatNumberResult = FormatNumericToString(internalSlots, x);
n = formatNumberResult.formattedString;
x = formatNumberResult.roundedNumber;
}
// Based on https://tc39.es/ecma402/#sec-getnumberformatpattern
// We need to do this before `x` is rounded.
var sign;
var signDisplay = internalSlots.signDisplay;
switch (signDisplay) {
case 'never':
sign = 0;
break;
case 'auto':
if (SameValue(x, 0) || x > 0 || isNaN(x)) {
sign = 0;
}
else {
sign = -1;
}
break;
case 'always':
if (SameValue(x, 0) || x > 0 || isNaN(x)) {
sign = 1;
}
else {
sign = -1;
}
break;
default:
// x === 0 -> x is 0 or x is -0
if (x === 0 || isNaN(x)) {
sign = 0;
}
else if (x > 0) {
sign = 1;
}
else {
sign = -1;
}
}
return formatToParts({ roundedNumber: x, formattedString: n, exponent: exponent, magnitude: magnitude, sign: sign }, internalSlots.dataLocaleData, pl, internalSlots);
}
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0053 ]-- |