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

12 lines
328 B
TypeScript
Raw Normal View History

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