Added StringHelpers, UniqIdGenerators and UrlParser test

UniqIdGenerators skips window.crypt test

URL tests need to be more in detail
This commit is contained in:
2025-03-07 19:01:58 +09:00
parent ea9882256e
commit 233fb6a235
8 changed files with 118 additions and 32 deletions

View File

@@ -14,28 +14,6 @@
</body>
<script languagae="JavaScript">
/**
* converts a int number into bytes with prefix in two decimals precision
* currently precision is fixed, if dynamic needs check for max/min precision
* @param {Number|BigInt} bytes bytes in int
* @return {String} string in GB/MB/KB
*/
function _formatBytes(bytes)
{
var i = -1;
// If this ia bigint -> convert to number, we need the decimals
if (typeof bytes === "bigint") {
bytes = Number(bytes);
}
do {
bytes = bytes / 1024;
i++;
} while (bytes > 99);
return (
Math.round(bytes * Math.pow(10, 2)) / Math.pow(10, 2)
) + ['kB', 'MB', 'GB', 'TB', 'PB', 'EB'][i];
}
document.addEventListener('DOMContentLoaded', function() {
console.log('JavaScript Utils Test');
let el = document.getElementById('test-div');
@@ -52,10 +30,6 @@ document.addEventListener('DOMContentLoaded', function() {
el.innerHTML += '<div>formatBytes: ' + formatBytes(bytes) + '</div>';
el.innerHTML += '<div>formatBytesLong: ' + formatBytesLong(bytes) + '</div>';
// el.innerHTML += '<div>_formatBytes: ' + _formatBytes(1024n) + '</div>';
el.innerHTML += '<div>_formatBytes: ' + _formatBytes(1021152n) + '</div>';
el.innerHTML += '<div>_formatBytes: ' + _formatBytes(1021152) + '</div>';
// console.log('TR: %s', l10n.__('Original'));
// console.log('TR: %s', l10n.__('Not exists'));
});