PeerTube/shared/core-utils/common/version.ts

12 lines
328 B
TypeScript
Raw Normal View History

2023-01-19 06:53:24 -06:00
// Thanks https://gist.github.com/iwill/a83038623ba4fef6abb9efca87ae9ccb
function compareSemVer (a: string, b: string) {
2023-01-19 06:53:24 -06:00
if (a.startsWith(b + '-')) return -1
if (b.startsWith(a + '-')) return 1
2023-01-19 06:53:24 -06:00
return a.localeCompare(b, undefined, { numeric: true, sensitivity: 'case', caseFirst: 'upper' })
}
2019-04-24 08:10:37 -05:00
export {
compareSemVer
2019-04-24 08:10:37 -05:00
}