Skip to content

isPrerelease

Returns true when the version string has a prerelease suffix (i.e. contains a - after the core MAJOR.MINOR.PATCH).

Available since v2.0.0

import { isPrerelease } from '@helpers4/version';
isPrerelease(version: string): boolean
ParameterTypeDescription
versionstringA semantic version string (e.g. '2.0.0-alpha.1', '1.0.0').

boolean — true if the version is a prerelease, false otherwise.

Returns true for any version string that contains a prerelease suffix.

isPrerelease('2.0.0-alpha.1') // true
isPrerelease('1.0.0-rc.0')   // true

Returns false when the version has no prerelease suffix.

isPrerelease('1.0.0') // false
isPrerelease('2.1.3') // false

Works with the result of parse() — checks the prerelease array instead of string matching.

isPrerelease(parse('2.0.0-alpha.1')) // true
isPrerelease(parse('1.0.0'))         // false

View source on GitHub