mirror of
https://github.com/0x5eal/semver-luau.git
synced 2024-12-12 15:00:36 +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
2f0fa8e5c4
commit
63858958c8
1 changed files with 14 additions and 1 deletions
|
@ -170,6 +170,19 @@ local PRERELEASE_LEX_ORDER: { [PreleaseType]: number } = table.freeze({
|
|||
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
|
||||
@function parse
|
||||
|
@ -344,7 +357,7 @@ function Semver.parse(ver: string): SemverResult<SemverImpl>
|
|||
end
|
||||
end
|
||||
|
||||
return Result.Ok(setmetatable(parsed :: Version, Semver))
|
||||
return Result.Ok(Semver.new(parsed))
|
||||
end
|
||||
|
||||
local function prereleaseEq(leftPrerelease: PrereleaseVersion?, rightPrerelease: PrereleaseVersion?): boolean
|
||||
|
|
Loading…
Reference in a new issue