summaryrefslogtreecommitdiff
path: root/source/libs/utils.ts
diff options
context:
space:
mode:
authorGravatar yakov116 <16872793+yakov116@users.noreply.github.com> 2020-03-13 17:52:44 -0400
committerGravatar GitHub <noreply@github.com> 2020-03-13 22:52:44 +0100
commit4f25a67d0688afe55c85f95f1ca720c172553150 (patch)
treeb4325e8d8bb640ef2c7e9d3665b6462fee467f54 /source/libs/utils.ts
parent1db2495e9b840a8e4f9fc7d8822227b8f4bf6e49 (diff)
downloadrefined-github-4f25a67d0688afe55c85f95f1ca720c172553150.tar.gz
refined-github-4f25a67d0688afe55c85f95f1ca720c172553150.tar.zst
refined-github-4f25a67d0688afe55c85f95f1ca720c172553150.zip
Add `pr-commit-lines-changed` feature (#2858)20.3.13
Co-authored-by: Federico Brigante <opensource@bfred.it>
Diffstat (limited to 'source/libs/utils.ts')
-rw-r--r--source/libs/utils.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/libs/utils.ts b/source/libs/utils.ts
index 73b5fb09..8f0729e0 100644
--- a/source/libs/utils.ts
+++ b/source/libs/utils.ts
@@ -27,6 +27,18 @@ export const getDiscussionNumber = (): string | undefined => {
return undefined;
};
+export const pluralize = (count: number, single: string, plural: string, zero?: string): string => {
+ if (count === 0 && zero) {
+ return zero.replace('$$', '0');
+ }
+
+ if (count === 1) {
+ return single.replace('$$', '1');
+ }
+
+ return plural.replace('$$', String(count));
+};
+
// Drops leading and trailing slash to avoid /\/?/ everywhere
export const getCleanPathname = (): string => location.pathname.replace(/^[/]|[/]$/g, '');