Skip to content

Commit

Permalink
refactor(utils): remove unused apostrophize function
Browse files Browse the repository at this point in the history
  • Loading branch information
matejchalk committed Jul 31, 2024
1 parent b2db9ed commit 2dcce47
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 29 deletions.
1 change: 0 additions & 1 deletion packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export { isSemver, normalizeSemver, sortSemvers } from './lib/semver';
export * from './lib/text-formats';
export {
CliArgsObject,
apostrophize,
capitalize,
countOccurrences,
distinct,
Expand Down
9 changes: 0 additions & 9 deletions packages/utils/src/lib/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,6 @@ export function capitalize<T extends string>(text: T): Capitalize<T> {
)}` as Capitalize<T>;
}

export function apostrophize(text: string, upperCase?: boolean) {
const lastCharMatch = text.match(/(\w)\W*$/);
const lastChar = lastCharMatch?.[1] ?? '';

return `${text}'${
lastChar.toLocaleLowerCase() === 's' ? '' : upperCase ? 'S' : 's'
}`;
}

export function toNumberPrecision(
value: number,
decimalPlaces: number,
Expand Down
19 changes: 0 additions & 19 deletions packages/utils/src/lib/transform.unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { describe, expect, it } from 'vitest';
import {
apostrophize,
capitalize,
countOccurrences,
deepClone,
Expand Down Expand Up @@ -262,24 +261,6 @@ describe('capitalize', () => {
});
});

describe('apostrophize', () => {
it("should add apostrophe and 's'", () => {
expect(apostrophize('cli')).toBe("cli's");
});

it("should add apostrophe without 's' for words ending with 's'", () => {
expect(apostrophize('yargs')).toBe("yargs'");
});

it("should add capital 'S' when upper case is defined", () => {
expect(apostrophize('WORLD', true)).toBe("WORLD'S");
});

it('should leave formatting if provided', () => {
expect(apostrophize('`git`')).toBe("`git`'s");
});
});

describe('toNumberPrecision', () => {
it.each([
[12.1, 0, 12],
Expand Down

0 comments on commit 2dcce47

Please sign in to comment.