gdDocumentation0.8.0

API reference

GD.version

Entry for parsing, comparing, and range-matching Semantic Versions.

Methods

parse

parse(raw: String) -> Dictionary, Err

Parse version text into a component dictionary.

Parameters

NameTypeDefaultDescription
rawStringRequiredSemantic-version text to parse or validate.

Return value

Dictionary, Err

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

is_canonical

is_canonical(raw: String) -> bool

Require a complete semantic version suitable for packages.

Parameters

NameTypeDefaultDescription
rawStringRequiredSemantic-version text to parse or validate.

Return value

bool

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

compare

compare(a: Dictionary, b: Dictionary) -> int

Compare two versions.

Parameters

NameTypeDefaultDescription
aDictionaryRequiredFirst semantic-version string.
bDictionaryRequiredSecond semantic-version string.

Return value

int

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

is_stable

is_stable(v: Dictionary) -> bool

Check whether a version is not a prerelease.

Parameters

NameTypeDefaultDescription
vDictionaryRequiredVersion value to format or test.

Return value

bool

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

text

text(v: Dictionary) -> String

Format a version dictionary as text.

Parameters

NameTypeDefaultDescription
vDictionaryRequiredVersion value to format or test.

Return value

String

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.

best

best(list: PackedStringArray, range: String = "*") -> Dictionary, Err

Select the newest version within a range.

Parameters

NameTypeDefaultDescription
listPackedStringArrayRequiredCandidate versions from which a matching version is selected.
rangeString"*"Version constraint to test against, rather than a numeric interval.

Return value

Dictionary, Err

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

best_async

best_async(list: PackedStringArray, range: String = "*") -> await Dictionary, Err

Dispatch selection from large version lists to a CPU worker.

Parameters

NameTypeDefaultDescription
listPackedStringArrayRequiredCandidate versions from which a matching version is selected.
rangeString"*"Version constraint to test against, rather than a numeric interval.

Return value

await Dictionary, Err

Returns a Signal. Use await to receive the completion value shown in the signature.

Errors

The result carries a value and an Err. Check the error before using the value; a failure may retain partial progress. In a function returning value, Err, use ? to propagate failure to the caller. The ! operator terminates the program on failure; in serve it fails the current handler.

satisfies

satisfies(v: Dictionary, range: String) -> bool

Check whether a version satisfies a range.

Parameters

NameTypeDefaultDescription
vDictionaryRequiredVersion value to format or test.
rangeStringRequiredVersion constraint to test against, rather than a numeric interval.

Return value

bool

Errors

This call has no Err return slot. Its return type and documented sentinel values determine how to inspect the result.