N3RD/JN/EXT/OPENJS/open/lib/utils.js
2023-07-25 20:38:30 +08:00

36 lines
902 B
JavaScript

function isSub(ext) {
return ext == "srt" || ext == "ass" || ext == "ssa";
}
function getSize(size) {
if (size <= 0) return "";
if (size > 1024 * 1024 * 1024 * 1024.0) {
size /= (1024 * 1024 * 1024 * 1024.0);
return size.toFixed(2) + "TB";
} else if (size > 1024 * 1024 * 1024.0) {
size /= (1024 * 1024 * 1024.0);
return size.toFixed(2) + "GB";
} else if (size > 1024 * 1024.0) {
size /= (1024 * 1024.0);
return size.toFixed(2) + "MB";
} else {
size /= 1024.0;
return size.toFixed(2) + "KB";
}
}
function removeExt(text) {
return text.indexOf('.') > -1 ? text.substring(0, text.lastIndexOf(".")) : text;
}
async function log(str) {
// let url = 'remote log url';
// await req(url, {
// method: 'post',
// data: {log: str}
// });
}
export { isSub, getSize, removeExt, log};