mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-03 02:11:07 +05:30
14 lines
475 B
TypeScript
14 lines
475 B
TypeScript
import figlet from 'figlet';
|
|
import type { Fonts } from 'figlet';
|
|
|
|
export const FIGLET_FONTS = ['Standard', 'Big', 'Small', 'Banner', 'Doom', 'Slant', 'Block'] as const;
|
|
export type FigletFont = typeof FIGLET_FONTS[number];
|
|
|
|
export function figletText(text: string, font: FigletFont): Promise<string> {
|
|
return new Promise((resolve, reject) => {
|
|
figlet.text(text, { font }, (err, result) => {
|
|
if (err) reject(err);
|
|
else resolve(result ?? '');
|
|
});
|
|
});
|
|
} |