mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-22 01:42:47 +00:00
fix: add timeout for device responses
This commit is contained in:
@@ -1,20 +1,25 @@
|
||||
export class SemVer {
|
||||
major: number
|
||||
minor: number
|
||||
patch: number
|
||||
major = 0
|
||||
minor = 0
|
||||
patch = 0
|
||||
preRelease?: string
|
||||
meta?: string
|
||||
|
||||
constructor(versionString: string) {
|
||||
const [, major, minor, patch, preRelease, meta] =
|
||||
const result =
|
||||
/^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+))?$/.exec(
|
||||
versionString,
|
||||
)!
|
||||
this.major = Number.parseInt(major)
|
||||
this.minor = Number.parseInt(minor)
|
||||
this.patch = Number.parseInt(patch)
|
||||
if (preRelease) this.preRelease = preRelease
|
||||
if (meta) this.meta = meta
|
||||
)
|
||||
if (!result) {
|
||||
console.error("Invalid version string:", versionString)
|
||||
} else {
|
||||
const [, major, minor, patch, preRelease, meta] = result
|
||||
this.major = Number.parseInt(major)
|
||||
this.minor = Number.parseInt(minor)
|
||||
this.patch = Number.parseInt(patch)
|
||||
if (preRelease) this.preRelease = preRelease
|
||||
if (meta) this.meta = meta
|
||||
}
|
||||
}
|
||||
|
||||
toString() {
|
||||
|
||||
Reference in New Issue
Block a user