Skip to content

Commit 996e59f

Browse files
committed
fix: private method => function
1 parent e9be8cd commit 996e59f

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/duration.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -266,13 +266,7 @@ export class Duration {
266266
* The string representation of this `Duration`. e.g. "645 seconds"
267267
*/
268268
public toString(): string {
269-
return this.pluralize();
270-
}
271-
272-
private pluralize(num = this.quantity, unit = this.unit): string {
273-
const name = Duration.Unit[unit].toLowerCase();
274-
if (num === 1) return `${num} ${name.slice(0, name.length - 1)}`;
275-
return `${num} ${name}`;
269+
return pluralize(this.quantity, this.unit);
276270
}
277271
}
278272

@@ -296,7 +290,7 @@ export namespace Duration {
296290
*/
297291
export type Interruptable = {
298292
interrupt: () => void;
299-
}
293+
};
300294

301295
/**
302296
* A promise of result type `T` that can be interrupted prematurely, resulting in an early resolution.
@@ -358,3 +352,8 @@ export function sleep(
358352
});
359353
return Object.assign(promise, { interrupt: wake });
360354
}
355+
356+
const pluralize = (num: number, unit: Duration.Unit): string => {
357+
const name = Duration.Unit[unit].toLowerCase();
358+
return `${num} ${num === 1 ? name.slice(0, name.length - 1) : name}`;
359+
};

0 commit comments

Comments
 (0)