Skip to main content
Home

Parsing and comparing of semantic versions (SemVer)

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
94%
Published
a month ago (1.0.6)
function parse
parse(value: string): SemVer

Attempt to parse a string as a semantic version, returning a SemVer object.

Examples

Usage

import { parse } from "@std/semver/parse";
import { assertEquals } from "@std/assert";

const version = parse("1.2.3");
assertEquals(version, {
  major: 1,
  minor: 2,
  patch: 3,
  prerelease: [],
  build: [],
});

Parameters

value: string

The version string to parse

Return Type

A valid SemVer

Throws

TypeError

If the input string is invalid.

New Ticket: 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 { parse } from "@std/semver";
or

Import directly with a jsr specifier

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

Add Package

pnpm i jsr:@std/semver
or (using pnpm 10.8 or older)
pnpm dlx jsr add @std/semver

Import symbol

import { parse } from "@std/semver";

Add Package

yarn add jsr:@std/semver
or (using Yarn 4.8 or older)
yarn dlx jsr add @std/semver

Import symbol

import { parse } from "@std/semver";

Add Package

vlt install jsr:@std/semver

Import symbol

import { parse } from "@std/semver";

Add Package

npx jsr add @std/semver

Import symbol

import { parse } from "@std/semver";

Add Package

bunx jsr add @std/semver

Import symbol

import { parse } from "@std/semver";