mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-24 10:14:08 +08:00
Generated documentation :)
This commit is contained in:
@@ -7,6 +7,12 @@ import { localeDirection, currentLocale } from "./i18n";
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
|
||||
/**
|
||||
* Returns the offset from UTC in hours for the current locale.
|
||||
* @returns {number} The offset from UTC in hours.
|
||||
*
|
||||
* Generated by Trelent
|
||||
*/
|
||||
function getTimezoneOffset(timeZone) {
|
||||
const now = new Date();
|
||||
const tzString = now.toLocaleString("en-US", {
|
||||
@@ -18,7 +24,14 @@ function getTimezoneOffset(timeZone) {
|
||||
return -offset;
|
||||
}
|
||||
|
||||
export function timezoneList() {
|
||||
export /**
|
||||
* Returns a list of timezones sorted by their offset from UTC.
|
||||
* @param {Array} timezones - An array of timezone objects.
|
||||
* @returns {Array} A list of the given timezones sorted by their offset from UTC.
|
||||
*
|
||||
* Generated by Trelent
|
||||
*/
|
||||
function timezoneList() {
|
||||
let result = [];
|
||||
|
||||
for (let timezone of timezones) {
|
||||
|
14
src/util.js
14
src/util.js
@@ -121,6 +121,13 @@ let getRandomBytes = ((typeof window !== 'undefined' && window.crypto)
|
||||
: function () {
|
||||
return require("crypto").randomBytes;
|
||||
})();
|
||||
/**
|
||||
* Returns a random integer between min (inclusive) and max (exclusive).
|
||||
* @param {number} min The minimum value.
|
||||
* @param {number} max The maximum value.
|
||||
*
|
||||
* Generated by Trelent
|
||||
*/
|
||||
function getCryptoRandomInt(min, max) {
|
||||
// synchronous version of: https://github.com/joepie91/node-random-number-csprng
|
||||
const range = max - min;
|
||||
@@ -151,6 +158,13 @@ function getCryptoRandomInt(min, max) {
|
||||
}
|
||||
}
|
||||
exports.getCryptoRandomInt = getCryptoRandomInt;
|
||||
/**
|
||||
* Generates a random string of length `length` from the characters in `chars`.
|
||||
* @param {number} length The number of characters to generate.
|
||||
* @param {string} chars A string containing all the possible characters to use for generating the random string.
|
||||
*
|
||||
* Generated by Trelent
|
||||
*/
|
||||
function genSecret(length = 64) {
|
||||
let secret = "";
|
||||
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
Reference in New Issue
Block a user