Skip to content

Commit 15b17e5

Browse files
committed
refactor: move pluralize() to utils
1 parent 3b737ac commit 15b17e5

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/lib/ggshield-results-parser.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
Occurrence,
1414
Validity,
1515
} from "./api-types";
16+
import { pluralize } from "../utils";
1617

1718
const validityDisplayName: Record<Validity, string> = {
1819
unknown: "Unknown",
@@ -46,9 +47,6 @@ function filterUriOccurrences(occurrences: Occurrence[]): Occurrence[] {
4647
* @returns incidents diagnostics
4748
*/
4849

49-
const pluralize = (num: number, word: string, plural = word + "s") =>
50-
[1, -1].includes(Number(num)) ? word : plural;
51-
5250
export function parseGGShieldResults(
5351
results: GGShieldScanResults,
5452
): Diagnostic[] {

src/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ export function getCurrentFile(): string {
2929
return "";
3030
}
3131
}
32+
33+
export function pluralize(num: number, word: string): string {
34+
return `${[1, -1].includes(num) ? word : word + "s"}`
35+
}

0 commit comments

Comments
 (0)