Skip to content

Commit

Permalink
feat(rails-status): add JSDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
mxdvl authored Nov 25, 2023
1 parent 76b278d commit 504d03e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/rails-status.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const statusOrder = [
const statusOrder = /** @type {const} */ ([
'deprecated',
'experimental',
'alpha',
'beta',
'stable'
]
]);

export const latestStatusFrom = (statuses) => {
let highestRank = -1
Expand All @@ -22,6 +22,11 @@ export const latestStatusFrom = (statuses) => {
return latestStatus
}

/**
* @param {string} first
* @param {string} second
* @returns {1 | 0 | -1} sorting order @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#description
*/
export const compareStatuses = (first, second) => {
const firstRank = statusOrder.indexOf(first)
const secondRank = statusOrder.indexOf(second)
Expand Down

0 comments on commit 504d03e

Please sign in to comment.