std/semver/comparator_format.ts
Tim Reichen aa3f026e93
deprecation(semver): deprecate SemVerRange, introduce Range (#4161)
* 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>
2024-01-14 21:19:00 +00:00

17 lines
626 B
TypeScript

// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import type { Comparator } from "./types.ts";
import { format } from "./format.ts";
/**
* Formats the comparator into a string
* @example >=0.0.0
* @param comparator
* @returns A string representation of the comparator
*
* @deprecated (will be removed in 0.214.0) Use {@linkcode SemVerRange} instead of {@linkcode Comparator} and {@linkcode formatRange} for formatting it.
*/
export function comparatorFormat(comparator: Comparator): string {
const { semver, operator } = comparator;
return `${operator}${format(semver ?? comparator)}`;
}