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

refactor(semver): rename comparatorFormat() to formatComparator() #4373

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { format } from "./format.ts";
* @param comparator
* @returns A string representation of the comparator
*/
export function comparatorFormat(comparator: Comparator): string {
export function formatComparator(comparator: Comparator): string {
const { semver, operator } = comparator;
return `${operator === undefined ? "" : operator}${
format(semver ?? comparator)
Expand Down
10 changes: 5 additions & 5 deletions semver/comparator_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { parseRange } from "./parse_range.ts";
import { parse } from "./parse.ts";
import { testRange } from "./test_range.ts";
import { parseComparator } from "./_parse_comparator.ts";
import { comparatorFormat } from "./_comparator_format.ts";
import { formatComparator } from "./_format_comparator.ts";
import { Comparator } from "./types.ts";

Deno.test({
Expand Down Expand Up @@ -164,27 +164,27 @@ Deno.test({

Deno.test("comparatorFormat() handles semver inheritance", function () {
assertEquals(
comparatorFormat(parseComparator(">= v1.2.3")),
formatComparator(parseComparator(">= v1.2.3")),
">=1.2.3",
);
assertEquals(
comparatorFormat(parseComparator(">= v1.2.3-pre.1+b.2")),
formatComparator(parseComparator(">= v1.2.3-pre.1+b.2")),
">=1.2.3-pre.1+b.2",
);
});

Deno.test("comparatorFormat() handles deprecated Comparator.semver property", function () {
const c1 = parseComparator(">= v1.2.3");
assertEquals(
comparatorFormat(
formatComparator(
{ operator: c1.operator, semver: c1.semver } as Comparator,
),
">=1.2.3",
);
const c2 = parseComparator(">= v1.2.3-pre.1+b.2");

assertEquals(
comparatorFormat(
formatComparator(
{ operator: c2.operator, semver: c2.semver } as Comparator,
),
">=1.2.3-pre.1+b.2",
Expand Down
4 changes: 2 additions & 2 deletions semver/format_range.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import type { Range } from "./types.ts";
import { comparatorFormat } from "./_comparator_format.ts";
import { formatComparator } from "./_format_comparator.ts";

/**
* Formats the range into a string
Expand All @@ -9,6 +9,6 @@ import { comparatorFormat } from "./_comparator_format.ts";
* @returns A string representation of the range
*/
export function formatRange(range: Range): string {
return range.map((c) => c.map((c) => comparatorFormat(c)).join(" "))
return range.map((c) => c.map((c) => formatComparator(c)).join(" "))
.join("||");
}