mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-09 18:34:55 +08:00
chore(jsdoc):Linting fixes (#3703)
* fixed the lockfile having a different version * jsdoc
This commit is contained in:
@@ -1,20 +1,22 @@
|
||||
/**
|
||||
* An object that can be used as an array with a key
|
||||
* Like PHP's array
|
||||
* @template K
|
||||
* @template V
|
||||
*/
|
||||
class ArrayWithKey {
|
||||
/**
|
||||
* All keys that are stored in the current object
|
||||
* @type {K[]}
|
||||
* @private
|
||||
*/
|
||||
__stack = [];
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
constructor() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* @param value
|
||||
* Push an element to the end of the array
|
||||
* @param {K} key The key of the element
|
||||
* @param {V} value The value of the element
|
||||
* @returns {void}
|
||||
*/
|
||||
push(key, value) {
|
||||
this[key] = value;
|
||||
@@ -22,7 +24,8 @@ class ArrayWithKey {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the last element and remove it from the array
|
||||
* @returns {V|undefined} The first value, or undefined if there is no element to pop
|
||||
*/
|
||||
pop() {
|
||||
let key = this.__stack.pop();
|
||||
@@ -32,7 +35,8 @@ class ArrayWithKey {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the last key
|
||||
* @returns {K|null} The last key, or null if the array is empty
|
||||
*/
|
||||
getLastKey() {
|
||||
if (this.__stack.length === 0) {
|
||||
@@ -42,7 +46,8 @@ class ArrayWithKey {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the first element
|
||||
* @returns {{key:K,value:V}|null} The first element, or null if the array is empty
|
||||
*/
|
||||
shift() {
|
||||
let key = this.__stack.shift();
|
||||
@@ -55,15 +60,16 @@ class ArrayWithKey {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the length of the array
|
||||
* @returns {number} Amount of elements stored
|
||||
*/
|
||||
length() {
|
||||
return this.__stack.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last element
|
||||
* @returns {*|null} The last element, or null if the array is empty
|
||||
* Get the last value
|
||||
* @returns {V|null} The last element without removing it, or null if the array is empty
|
||||
*/
|
||||
last() {
|
||||
let key = this.getLastKey();
|
||||
|
@@ -6,11 +6,22 @@ const { ArrayWithKey } = require("./array-with-key");
|
||||
*/
|
||||
class LimitQueue extends ArrayWithKey {
|
||||
|
||||
/**
|
||||
* The limit of the queue after which the first element will be removed
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
__limit;
|
||||
/**
|
||||
* The callback function when the queue exceeds the limit
|
||||
* @private
|
||||
* @callback onExceedCallback
|
||||
* @param {{key:K,value:V}|nul} item
|
||||
*/
|
||||
__onExceed = null;
|
||||
|
||||
/**
|
||||
* @param {number} limit
|
||||
* @param {number} limit The limit of the queue after which the first element will be removed
|
||||
*/
|
||||
constructor(limit) {
|
||||
super();
|
||||
|
Reference in New Issue
Block a user