deno.land / std@0.224.0 / semver / try_parse_range.ts

try_parse_range.ts
View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.// This module is browser compatible.
import type { Range } from "./types.ts";import { parseRange } from "./parse_range.ts";
/** * A tries to parse a valid Range string or returns undefined * @param range The range string * @returns A Range object if valid otherwise `undefined` */export function tryParseRange( range: string,): Range | undefined { try { // Return '*' instead of '' so that truthiness works. // This will throw if it's invalid anyway return parseRange(range); } catch { return undefined; }}
std

Version Info

Tagged at
6 months ago