mirror of
https://github.com/0x5eal/semver-luau.git
synced 2024-12-13 16:50:35 +00:00
feat: Semver.new
for construction
Includes a `Semver.new` method, which constructs a `SemverImpl` from a `Version`, by setting its metatable.
This commit is contained in:
parent
957e63cca9
commit
30c104d844
1 changed files with 14 additions and 1 deletions
|
@ -170,6 +170,19 @@ local PRERELEASE_LEX_ORDER: { [PreleaseType]: number } = table.freeze({
|
||||||
rc = 3,
|
rc = 3,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
--[=[
|
||||||
|
@within Semver
|
||||||
|
@function new
|
||||||
|
|
||||||
|
Creates a new Semver instance from a [Version]
|
||||||
|
|
||||||
|
@param ver Version -- The version to create a Semver instance from
|
||||||
|
@return SemverImpl -- The new Semver instance
|
||||||
|
]=]
|
||||||
|
function Semver.new(ver: Version): SemverImpl
|
||||||
|
return setmetatable(ver, Semver)
|
||||||
|
end
|
||||||
|
|
||||||
--[=[
|
--[=[
|
||||||
@within Semver
|
@within Semver
|
||||||
@function parse
|
@function parse
|
||||||
|
@ -344,7 +357,7 @@ function Semver.parse(ver: string): SemverResult<SemverImpl>
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return Result.Ok(setmetatable(parsed :: Version, Semver))
|
return Result.Ok(Semver.new(parsed))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function prereleaseEq(leftPrerelease: PrereleaseVersion?, rightPrerelease: PrereleaseVersion?): boolean
|
local function prereleaseEq(leftPrerelease: PrereleaseVersion?, rightPrerelease: PrereleaseVersion?): boolean
|
||||||
|
|
Loading…
Reference in a new issue