Add JSDoc documentation and file headers to all source files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 18:55:36 +08:00
parent 3b7b6ae859
commit 7fec6cb63f
199 changed files with 2764 additions and 503 deletions

View File

@@ -1,6 +1,19 @@
// The Lucia project.
// Copyright 2023-2026 DSP, inc. All rights reserved.
// Authors:
// chiayin.kuo@dsp.im (chiayin), 2023/1/31
// imacat.yang@dsp.im (imacat), 2023/9/23
// cindy.chang@dsp.im (Cindy Chang), 2024/5/30
/** @module jsUtils General JavaScript utility functions. */
/**
* Recursively prints an object's properties to the console.
* @param {Object} obj - The object to print.
* @param {number} [indent=0] - The current indentation level.
*/
export const printObject = (obj, indent = 0) => {
const padding = ' '.repeat(indent);
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
if (typeof obj[key] === 'object' && obj[key] !== null) {
@@ -14,8 +27,13 @@ export const printObject = (obj, indent = 0) => {
}
};
/**
* Returns a cryptographically random integer between 0 and max (inclusive).
* @param {number} max - The upper bound (inclusive).
* @returns {number} A random integer in [0, max].
*/
export const getRandomInt = (max) => {
const array = new Uint32Array(1);
window.crypto.getRandomValues(array);
return Math.floor(array[0] / (0xFFFFFFFF + 1) * (max + 1));
};
};