Skip to main content

Function: compareModuleVersions()

compareModuleVersions(candidate, installed): VersionComparison

Defined in: Data/Core/ModuleVersion.ts:197

Order candidate (the incoming module) against installed (what is on disk).

Parameters

candidate

string | null | undefined

installed

string | null | undefined

Returns

VersionComparison

newer when the candidate supersedes the installed module, older when it is behind it, same when they are the same release, and incomparable when no ordering can be established — which callers must NOT treat as an upgrade.

Example

compareModuleVersions('2.0', '1.9.3') // 'newer'
compareModuleVersions('1.0', '1.0.0') // 'same' (trailing zeros)
compareModuleVersions('1.0.0-beta', '1.0.0') // 'older' (prerelease)
compareModuleVersions('20240115', '1.2') // 'incomparable'
compareModuleVersions('1769', '1769') // 'same' (identical strings)