fix(core): Implemented, fixes #1

This commit is contained in:
2025-01-14 17:34:16 +01:00
parent 656f5b7dfb
commit f065ef0e94
13 changed files with 9880 additions and 123 deletions

View File

@@ -1,3 +1,46 @@
import * as plugins from './beautyfiglet.plugins';
import * as plugins from './beautyfiglet.plugins.js';
export let standardExport = 'Hi there! :) This is an exported string';
export class BeautyFiglet {
/**
* Render text with a specific figlet font.
* @param text - The text to render.
* @param font - The font to use (optional).
* @returns A promise that resolves to the rendered ASCII art.
*/
static async renderText(text: string, font: plugins.figlet.Fonts = "Standard"): Promise<string> {
return new Promise((resolve, reject) => {
plugins.figlet.text(text, { font }, (err, result) => {
if (err) {
reject(`Error rendering text: ${err.message}`);
} else {
resolve(result || "");
}
});
});
}
/**
* Get a list of all available fonts in figlet.
* @returns A promise that resolves to an array of font names.
*/
static async listFonts(): Promise<string[]> {
return new Promise((resolve, reject) => {
plugins.figlet.fonts((err, fonts) => {
if (err) {
reject(`Error fetching fonts: ${err.message}`);
} else {
resolve(fonts || []);
}
});
});
}
/**
* Render text with a default font (Standard).
* @param text - The text to render.
* @returns A promise that resolves to the rendered ASCII art.
*/
static async renderDefault(text: string): Promise<string> {
return this.renderText(text, "Standard");
}
}