fix(core): Implemented, fixes #1
This commit is contained in:
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/beautyfiglet',
|
||||
version: '1.0.4',
|
||||
description: 'A Node.js module for creating figlet text displays.'
|
||||
}
|
@ -1,2 +1,6 @@
|
||||
const removeme = {};
|
||||
export { removeme };
|
||||
import figlet, { type Fonts } from 'figlet';
|
||||
|
||||
export {
|
||||
figlet,
|
||||
type Fonts,
|
||||
}
|
47
ts/index.ts
47
ts/index.ts
@ -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");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user