About
Ruxe is an open-source npm package used to wrap text into paragraphs for command line interfaces. It takes 2 lines of code to that. And saves you a lot of time for formatting text. You can also change paragraph colors and change the alignment of the paragraph in seconds.
Installation
npm install ruxe
Parameters
The wrap()
function requires atleast 1 parameter. And maximum of 2 parameters. The first parameter is the string
that you would like to turn into a paragraph. And the second parameter is a configeration object
consisting of at most 3 fields. Which are -
color
- Textcolor of the paragraph :string:
align
- Alignment format of the paragraph :string:
separateAt
- Words after which a new line is created :number:
By default color
parameter is treated as white
, the align
parameter is treated as left
and separateAt
is treated as 13
Available Colors: black, red, green, yellow, blue, magenta, cyan and white
Available Alignment Formats: left and right (Center will be added in the next version.)
Example Usage
const wrap = require("ruxe");
let textwrapped = wrap("Harry has a little farm, he has 4 cows, 15 chickens and 3 goats in his farm. He likes to grow a variety of crops such as wheat, barley, rice and corn! He loves farming! He also has good storage facilities in the farm and modern irrigation systems!", { color:"cyan", separateAt:7, align:"left" });
console.log(textwrapped);
Output:
Harry has a little farm he has 4
cows 15 chickens and 3 goats in
his farm. He likes to grow a
variety of crops such as wheat barley
rice and corn! He loves farming! He
also has good storage facilities in the
farm and modern irrigation systems!
For more examples click me!
Contribution
For contributing to this project, fork the repository here, make the changes and open a pull request! Pull requests will be reviewed before being merged.