an

ascii-numbers

Convert numbers to ASCI art text

Showing:

Popularity

Downloads/wk

15

GitHub Stars

0

Maintenance

Last Commit

3yrs ago

Contributors

4

Package

Dependencies

0

Size (min+gzip)

1.0KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

ascii-numbers

Greenkeeper badge Build Status Coverage Status

a simple lib for converting numbers to ASCII art text.

Usage

import font from 'ascii-numbers/fonts/ANSI_Shadow';
import ASCIINumbers from 'ascii-numbers';

const asciiNumbersWithFont = new ASCIINumbers(font);

console.log(asciiNumbersWithFont.getNumber(123))

/* Output
     ██╗  ██████╗  ██████╗
    ███║  ╚════██╗ ╚════██╗
    ╚██║   █████╔╝  █████╔╝
     ██║  ██╔═══╝   ╚═══██╗
     ██║  ███████╗ ██████╔╝
     ╚═╝  ╚══════╝ ╚═════╝
*/

Options

You can pass second parameter with options to ASCIINumbers constructor.

const config = {
    lineLength: 80,
    minDigits: null,
    space: ''
};

const asciiNumbersWithFont = new ASCIINumbers(font, config);

lineLength defines the maximum usable space for ascii text output. Default is 80 characters.

minDigits defines number alignment. If the printed number has fewer than 'minDigits' digits, then is prefixed by spaces.

...

const asciiNumbersWithFont = new ASCIINumbers(font, { minDigits: 6 });
console.log(asciiNumbersWithFont.getNumber(123))

/* Output
                                ██╗  ██████╗  ██████╗
                               ███║  ╚════██╗ ╚════██╗
                               ╚██║   █████╔╝  █████╔╝
                                ██║  ██╔═══╝   ╚═══██╗
                                ██║  ███████╗ ██████╔╝
                                ╚═╝  ╚══════╝ ╚═════╝
*/

space defines separator between digits.

...

const asciiNumbersWithFont = new ASCIINumbers(font, { space: '***' });
console.log(asciiNumbersWithFont.getNumber(123))

/* Output
     ██╗ *** ██████╗ *** ██████╗
    ███║ *** ╚════██╗*** ╚════██╗
    ╚██║ ***  █████╔╝***  █████╔╝
     ██║ *** ██╔═══╝ ***  ╚═══██╗
     ██║ *** ███████╗*** ██████╔╝
     ╚═╝ *** ╚══════╝*** ╚═════╝
*/

Fonts

This lib use ANSI Shadow font from figlet, but you can simply create your own font. Check ANSI_Shadow.js for font structure.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100