A Node.js module that facilitates the creation of ASCII art using figlet with customizable fonts and layouts.
## Install
To install `@push.rocks/beautyfiglet`, you need to have Node.js and npm installed on your machine. Then, you can install it via npm:
To install `@push.rocks/beautyfiglet`, ensure you have Node.js along with npm set up on your machine. Executing the following command in your terminal will install this module via npm:
```sh
npm install @push.rocks/beautyfiglet
@ -15,12 +14,12 @@ Alternatively, you can add it as a dependency in your `package.json`:
```json
{
"dependencies":{
"@push.rocks/beautyfiglet":"^1.0.3"
"@push.rocks/beautyfiglet":"^1.0.8"
}
}
```
Then run:
Then execute:
```sh
npm install
@ -28,315 +27,208 @@ npm install
## Usage
The `@push.rocks/beautyfiglet`package is designed to allow you to display figlet text in your nodejs application. Below are instructions and examples on how to use it efficiently in your projects. We will cover all functionalities and illustrate several practical scenarios.
`@push.rocks/beautyfiglet`is a comprehensive Node.js package that empowers developers to generate visually engaging figlet-style ASCII art. This section will delve into detailed use-case scenarios, ensuring you have a robust understanding of how to integrate and utilize this module effectively within your projects.
### Basic Usage
### Getting Started
First, you'll need to import the package. Here's an example of basic usage:
To begin using `@push.rocks/beautyfiglet`, import the `BeautyFiglet` class in your TypeScript file. This class serves as the gateway to generating your ASCII art.
console.log(beautyfiglet.standardExport);// Outputs: Hi there! :) This is an exported string
console.log('Welcome to BeautyFiglet!');// Outputs: Welcome to BeautyFiglet!
```
### Creating Figlet Text
### Rendering Text with Figlet
Let’s say you want to display custom figlet text. Follow these steps:
1. Import `figlet` from the figlet package, which `@push.rocks/beautyfiglet` might internally use.
2. Use the `figlet` function to create ASCII art.
Here is a simple example:
The quintessential feature of this module is its ability to convert plain text into ASCII art using popular figlet formats. Below is an example of how to achieve this with `renderDefault`.
```typescript
importfigletfrom'figlet';
figlet('Hello World',function(err,data){
if(err){
console.error('Something went wrong...');
console.dir(err);
return;
}
console.log(data);
});
```
### Using Promises
To work with promises and async/await, you can wrap the `figlet` method within a Promise:
console.log(artwork);// Output is rendered immediately without asynchronous behavior.
```
### Styling and Coloring
### Adding Color to the Output
While `figlet` itself doesn’t support colored text directly, you can use other npm packages like `chalk` to add colors to figlet text. Here’s an example:
To create more vibrant and visually appealing text displays, utilize libraries such as `chalk` to incorporate colors.
console.error(error.message);// Output: Error generating figlet text: Font not found
console.error(`Caught an error: ${error}`);// Captures and logs errors without halting the program.
}
})();
```
### Integration with Web Servers
### Web Server Integration
You can integrate `@push.rocks/beautyfiglet` with a Node.js web server like Express. Here’s an example:
The functionality of this module can be extended to serve ASCII art over HTTP, allowing integration with web services. Here’s a demonstration using Express.
2.Add a line to your `package.json` to register this as a bin command:
```json
"bin":{
"figlet-cli":"./path/to/figlet-cli.ts"
}
```
3. Make sure `figlet-cli.ts` is executable:
1. Save the script as `beautyfiglet-cli.ts`.
2.Make it executable:
```sh
chmod +x ./path/to/figlet-cli.ts
chmod +x ./beautyfiglet-cli.ts
```
4.Then you can run:
3.Establish a link via npm:
```sh
npm link
figlet-cli --text "Hello World"
```
This concludes the extensive usage documentation for the @push.rocks/beautyfiglet package, showcasing multiple ways to generate ASCII art using figlet in Node.js. Explore the various options and configurations to best fit your project's needs.
This CLI approach demonstrates seamless integration into development workflows, adding simplicity and efficiency for users.
### Comprehensive Summary
Throughout this comprehensive guide, we have demonstrated the varied and extensive capabilities of the `@push.rocks/beautyfiglet` module. From initializing the module and employing basic rendering to exploring intricate font customization, layout configurations, and error handling, the guide has covered an exhaustive list of functionalities available within this versatile module.
Developers are encouraged to delve deeper into exploring font selections and engaging with additional configuration settings to thoroughly harness the potential of this tool. By integrating colorful text arrangements and utilizing robust error management, applications can balance both aesthetic appeal and operational reliability.
This expansive exploration into the `@push.rocks/beautyfiglet` module underscores the creativity and potential this tool offers for implementing ASCII art in your Node.js projects.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
description:'A Node.js module for creating figlet text displays.'
version:'1.0.9',
description:'A Node.js module for creating customizable ASCII art using figlet with options for different fonts and layouts.'
}
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.