mirror of
https://github.com/denoland/std.git
synced 2024-11-22 04:59:05 +00:00
aa3f026e93
* initial commit * Update semver/is_range.ts Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com> * bump deprecation notice * add test cases * fmt * Update types.ts Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com> * Update types.ts Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com> * Update is_semver_range.ts Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com> --------- Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com> Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
17 lines
550 B
TypeScript
17 lines
550 B
TypeScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
import type { Range, SemVerRange } from "./types.ts";
|
|
import { comparatorFormat } from "./comparator_format.ts";
|
|
|
|
/**
|
|
* Formats the range into a string
|
|
* @example >=0.0.0 || <1.0.0
|
|
* @param range The range to format
|
|
* @returns A string representation of the range
|
|
*/
|
|
export function formatRange(range: SemVerRange | Range): string {
|
|
return (Array.isArray(range) ? range : range.ranges).map((c) =>
|
|
c.map((c) => comparatorFormat(c)).join(" ")
|
|
)
|
|
.join("||");
|
|
}
|