Ruxe is an open-source npm package used to wrap text into clean and neat paragraphs for command line interfaces. It takes 2 lines of code to do 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.
npm install ruxe
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:
wordsPerLine
- 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 wordsPerLine
is treated as 13
Available Colors: black, red, green, yellow, blue, magenta, cyan and white
Available Alignment Formats: left, right and center
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", wordsPerLine:8, align:"left" });
console.log(textwrapped); //each line of he paragraph will have 8 words, text color will be cyan in color and alignment of the paragraph will be left.
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!
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.
Your pull request must contain the following information in detail -
- Explain the pull request and the need for it to be merged in not more than 30 words
- What did you add/edit?
All pull requests are reviewed thoroughly. Pull requests that pass the review are merged and then closed while the pull requests that fail the review are not merged and are closed.
Found a bug? Having an issue with the package? Open a new issue here!