/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** * Get a human-readable string from a number of bytes, with the B, kB, MB, or * GB value.
*/ function getFormattedSize(bytes, decimals = REQUEST_DECIMALS) { if (bytes < MAX_BYTES_SIZE) { return L10N.getFormatStr("networkMenu.sizeB", bytes);
} if (bytes < MAX_KB_SIZE) { const kb = bytes / BYTES_IN_KB; const formattedDecimals = formatDecimals(kb, decimals);
/** * Get a human-readable string from a number of time, with the ms, s, or min * value.
*/ function getFormattedTime(ms) { if (ms < MAX_MILLISECOND) { return L10N.getFormatStr("networkMenu.millisecond", ms | 0);
} if (ms < MAX_SECOND) { const sec = ms / MAX_MILLISECOND; return L10N.getFormatStr("networkMenu.second", getTimeWithDecimals(sec));
} const min = ms / MAX_SECOND; return L10N.getFormatStr("networkMenu.minute", getTimeWithDecimals(min));
}
/** * Formats IP (v4 and v6) and port * * @param {string} ip - IP address * @param {string} port * @return {string} the formatted IP + port
*/ function getFormattedIPAndPort(ip, port) { if (!port) { return ip;
} return ip.match(/:+/) ? `[${ip}]:${port}` : `${ip}:${port}`;
}
/** * Formats the priority of a request * Based on unix conventions * See xpcom/threads/nsISupportsPriority.idl * * @param {Number} priority - request priority
*/ function getRequestPriorityAsText(priority) { if (priority < PRIORITY_HIGH) { return"Highest";
} elseif (priority >= PRIORITY_HIGH && priority < PRIORITY_NORMAL) { return"High";
} elseif (priority === PRIORITY_NORMAL) { return"Normal";
} elseif (priority > PRIORITY_NORMAL && priority <= PRIORITY_LOW) { return"Low";
} return"Lowest";
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.