Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
timreichen committed Feb 22, 2024
1 parent 3e42606 commit b307447
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
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("||");
}

0 comments on commit b307447

Please sign in to comment.