diff --git a/src/rails-status.js b/src/rails-status.js index 45b66fb5d..0bde425d9 100644 --- a/src/rails-status.js +++ b/src/rails-status.js @@ -1,3 +1,4 @@ +/** Status order: later elements have higher precedence. */ const statusOrder = [ 'deprecated', 'experimental', @@ -6,6 +7,12 @@ const statusOrder = [ 'stable' ] +/** + * Get the latest status, based on the order of precedence + * + * @param {readonly string[]} statuses list of status to pick from + * @returns {string | null} latest status if valid, `null` otherwise + */ export const latestStatusFrom = (statuses) => { let highestRank = -1 let latestStatus = null @@ -22,6 +29,13 @@ export const latestStatusFrom = (statuses) => { return latestStatus } +/** + * Compare function, which is compatible with #Array.sort. + * + * @param {string} first + * @param {string} second + * @returns {1 | 0 | -1} sorting order + */ export const compareStatuses = (first, second) => { const firstRank = statusOrder.indexOf(first) const secondRank = statusOrder.indexOf(second)