Skip to content

Commit

Permalink
fix: private method => function
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Jun 18, 2024
1 parent e9be8cd commit 996e59f
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/duration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,7 @@ export class Duration {
* The string representation of this `Duration`. e.g. "645 seconds"
*/
public toString(): string {
return this.pluralize();
}

private pluralize(num = this.quantity, unit = this.unit): string {
const name = Duration.Unit[unit].toLowerCase();
if (num === 1) return `${num} ${name.slice(0, name.length - 1)}`;
return `${num} ${name}`;
return pluralize(this.quantity, this.unit);
}
}

Expand All @@ -296,7 +290,7 @@ export namespace Duration {
*/
export type Interruptable = {
interrupt: () => void;
}
};

/**
* A promise of result type `T` that can be interrupted prematurely, resulting in an early resolution.
Expand Down Expand Up @@ -358,3 +352,8 @@ export function sleep(
});
return Object.assign(promise, { interrupt: wake });
}

const pluralize = (num: number, unit: Duration.Unit): string => {
const name = Duration.Unit[unit].toLowerCase();
return `${num} ${num === 1 ? name.slice(0, name.length - 1) : name}`;
};

0 comments on commit 996e59f

Please sign in to comment.