Files
discord-decomp/sources/utils/NumberUtils.tsx
T
2026-07-28 01:06:53 +03:00

81 lines
3.8 KiB
TypeScript

/* Metro module 1856; source: utils/NumberUtils.tsx; dependencies: [1244, 2] */
import * as FileImportTrackerModule from '../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as IndexNativeModule from '../intl/index.native.tsx'; /* Metro dependency 1244 */
function _fun20018(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#20018, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1983:6, offset: 0x00ebc806, size: 127 bytes, params: 8, frame: 18
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
(FileImportTrackerModule).fileFinishedImporting('utils/NumberUtils.tsx');
exports.shortenAndLocalizeNumber = shortenAndLocalizeNumber;
exports.humanizeValue = humanizeValue;
exports.parseInteger = function(a0) {
var r0;
var value = a1;
r0 = value !== undefined ? value : global.NaN;
if (a0 == null) {
return r0;
}
value = (0, global.parseInt)(a0);
return global.Number.isNaN(value) ? r0 : value;
};
exports.formatPercent = function(a0, a1) {
var r0;
var object;
var value = a2;
r0 = value !== undefined ? value : {};
var Intl = global.Intl;
object = {'style': 'percent', 'minimumFractionDigits': 0};
copyDataProperties(object, r0, Intl);
return Intl.NumberFormat(a0, object).format(a1);
};
function shortenAndLocalizeNumber(a0) { // fn#20019, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1983:184, offset: 0x00ebc885, size: 167 bytes, params: 2, frame: 17
const intl = (IndexNativeModule).intl;
const t = (IndexNativeModule).t;
if (a0 < 1000000) {
return intl.formatToPlainString(t.OiHat3, {value: a0});
}
let value = a0 / 1000000;
value = value.toFixed(1);
const formatToPlainString = intl.formatToPlainString;
const Iku48I = t.Iku48I;
return Reflect.apply(formatToPlainString, intl, [Iku48I, {value: value}]);
}
function humanizeValue(a0, a1) { // fn#20020, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1983:404, offset: 0x00ebc92c, size: 369 bytes, params: 3, frame: 18
var object;
const intl = (IndexNativeModule).intl;
var formatToPlainString;
const t = (IndexNativeModule).t;
var property;
var OiHat3;
if (a0 < 1000) {
formatToPlainString = intl.formatToPlainString;
OiHat3 = t.OiHat3;
object = {};
object.value = global.Math.floor(a0);
return Reflect.apply(formatToPlainString, intl, [OiHat3, object]);
}
if (a0 < 1000000) {
formatToPlainString = intl.formatToPlainString;
property = t['84R4Tc'];
object = {};
object.value = global.Math.floor(a0 / 1000);
return Reflect.apply(formatToPlainString, intl, [property, object]);
}
const Math = global.Math;
let value = Math.floor(10 * a0 / 1000000) / 10;
const Intl = global.Intl;
const NumberFormat = Intl.NumberFormat;
const value2 = Object.create(NumberFormat.prototype, {constructor: {value: NumberFormat}});
const numberFormat = new NumberFormat(a1, {maximumFractionDigits: 1});
value = (numberFormat instanceof Object ? numberFormat : value2).format(value);
formatToPlainString = intl.formatToPlainString;
const Iku48I = t.Iku48I;
return Reflect.apply(formatToPlainString, intl, [Iku48I, {value: value}]);
}
}
global.__d(_fun20018, 1856, [1244, 2]) /* metro module 1856, dependencies: [1244, 2] */;