Add types for moment

This commit is contained in:
Cohee
2024-05-11 14:49:11 +03:00
parent f421139402
commit e73b5713fd
2 changed files with 793 additions and 5 deletions

View File

@ -612,8 +612,8 @@ const dateCache = new Map();
/**
* Cached version of moment() to avoid re-parsing the same date strings.
* Important: Moment objects are mutable, so use clone() before modifying them!
* @param {any} timestamp String or number representing a date.
* @returns {*} Moment object
* @param {string|number} timestamp String or number representing a date.
* @returns {moment.Moment} Moment object
*/
export function timestampToMoment(timestamp) {
if (dateCache.has(timestamp)) {
@ -663,8 +663,8 @@ function parseTimestamp(timestamp) {
/**
* Compare two moment objects for sorting.
* @param {*} a The first moment object.
* @param {*} b The second moment object.
* @param {moment.Moment} a The first moment object.
* @param {moment.Moment} b The second moment object.
* @returns {number} A negative number if a is before b, a positive number if a is after b, or 0 if they are equal.
*/
export function sortMoments(a, b) {