Skip to content

Commit 80d01d5

Browse files
committed
feat(lists): allow adding an empty list placeholder
1 parent 0e352a3 commit 80d01d5

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/textHelper.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,17 @@ export function text(
7272
* @param words list of words
7373
* @returns written list
7474
*/
75-
export function writeList(words: (Writable | string)[]): string {
76-
if (words.length === 0) return '';
75+
export function writeList(
76+
words: (Writable | string)[],
77+
emptyMessage?: Writable | string
78+
): string {
79+
if (words.length === 0) {
80+
if (emptyMessage) {
81+
if (typeof emptyMessage === 'string') return emptyMessage;
82+
return emptyMessage.write();
83+
}
84+
return '';
85+
}
7786
if (words.length === 1) {
7887
if (typeof words[0] === 'string') return words[0];
7988
return words[0].write();

0 commit comments

Comments
 (0)