Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

std/semver/try_parse.ts

Deno standard library
Go to Latest
File
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.import { SemVer } from "./types.ts";import { parse } from "./parse.ts";
/** * Returns the parsed version, or undefined if it's not valid. * @param version The version string to parse * @returns A valid SemVer or `undefined` */export function tryParse(version?: string): SemVer | undefined { if (version === undefined) { return undefined; } try { return parse(version); } catch { return undefined; }}