2024-01-08 02:55:23 +00:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2024-01-14 21:19:00 +00:00
|
|
|
import type { Range, SemVerRange } from "./types.ts";
|
2024-01-08 02:55:23 +00:00
|
|
|
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
|
|
|
|
*/
|
2024-01-14 21:19:00 +00:00
|
|
|
export function formatRange(range: SemVerRange | Range): string {
|
|
|
|
return (Array.isArray(range) ? range : range.ranges).map((c) =>
|
|
|
|
c.map((c) => comparatorFormat(c)).join(" ")
|
|
|
|
)
|
2024-01-08 02:55:23 +00:00
|
|
|
.join("||");
|
|
|
|
}
|