Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecation(semver): rename rangeFormat() to formatRange() #4090

Merged
merged 13 commits into from
Jan 8, 2024
14 changes: 14 additions & 0 deletions semver/format_range.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import type { 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): string {
return range.ranges.map((c) => c.map((c) => comparatorFormat(c)).join(" "))
.join("||");
}
11 changes: 5 additions & 6 deletions semver/range_format.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import type { SemVerRange } from "./types.ts";
import { comparatorFormat } from "./comparator_format.ts";

import { formatRange } from "./format_range.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
*
* @deprecated (will be removed after 0.213.0) Use {@linkcode formatRange} instead.
*/
export function rangeFormat(range: SemVerRange): string {
return range.ranges.map((c) => c.map((c) => comparatorFormat(c)).join(" "))
.join("||");
}
export const rangeFormat = formatRange;
timreichen marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions semver/range_test.ts
timreichen marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Isaac Z. Schlueter and Contributors. All rights reserved. ISC license.
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assert, assertEquals } from "../assert/mod.ts";
import { rangeFormat } from "./range_format.ts";
import { formatRange } from "./format_range.ts";
import { parse } from "./parse.ts";
import { parseRange } from "./parse_range.ts";
import { testRange } from "./test_range.ts";
Expand Down Expand Up @@ -278,7 +278,7 @@ Deno.test({
name: `${r} -> ${expected}`,
fn: () => {
const range = parseRange(r);
const actual = rangeFormat(range);
const actual = formatRange(range);
assertEquals(actual, expected);
},
});
Expand Down