Skip to main content

@std/semver@0.215.0

latest
Works with
It is unknown whether this package works with Browsers, Deno, Node.js, Cloudflare Workers, Bun
It is unknown whether this package works with Browsers
It is unknown whether this package works with Deno
It is unknown whether this package works with Node.js
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score76%
Published2 years ago (0.215.0)
function increment
increment(
version: SemVer,
release: ReleaseType,
prerelease?: string,
buildmetadata?: string
): SemVer

Returns the new version resulting from an increment by release type.

premajor, preminor and prepatch will bump the version up to the next version, based on the type, and will also add prerelease metadata.

If called from a non-prerelease version, the prerelease will work the same as prepatch. The patch version is incremented and then is made into a prerelease. If the input version is already a prerelease it will simply increment the prerelease metadata.

If a prerelease identifier is specified without a number then a number will be added. For example pre will result in pre.0. If the existing version already has a prerelease with a number and its the same prerelease identifier then the number will be incremented. If the identifier differs from the new identifier then the new identifier is applied and the number is reset to 0.

If the input version has build metadata it will be preserved on the resulting version unless a new build parameter is specified. Specifying "" will unset existing build metadata.

Parameters

The version to increment

The type of increment to perform

optional
prerelease: string

The pre-release metadata of the new version

optional
buildmetadata: string

Return Type

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/semver

Import symbol

import { increment } from "@std/semver";
or

Import directly with a jsr specifier

import { increment } from "jsr:@std/semver";