npm.io
0.1.0 • Published 4 years ago

@afoot/divide

Licence
MIT
Version
0.1.0
Deps
0
Size
8 kB
Vulns
0
Weekly
0

@afoot/divide

Add a lil’ divider string beneath a source string. Use it to create separation in console logs or stdout.

usage

Provide a string and it will return the string and a divider of equal length on a separate line.

const output = divide('string');
/* Returns:
string
-----
*/
console.log(output);

config options

character

Normally returning a series of hyphens, you can specify any combination of characters with the character key in the config object.

const output = divide('string', { character: '•–' });
/* Returns:
string
•–•–•–
*/
console.log(output);
width

Override the default string length by specifiying a numeric override with width.

const output = divide('string', { width: 10 });
/* Returns:
string
----------
*/
console.log(output);

Setting width to less than one omits the divider

const output = divide('string', { width: -1 });
/* Returns:
string
*/
console.log(output);
omitSource

Return just the divider with a length equal to the input length

const output = divide('string', { omitSource: true });
/* Returns:
------
*/
console.log(output);
bypass input

Create a divider by passing in only a config object with at least a width.

const output = divide({ width: 5, character: '•' });
/* Returns:
•••••
*/
console.log(output);

what is this for?

In honesty, I made this to test Rollup, continuous integrations, and npm packages, but it totally does what it says on the box, too!

license

MIT Matthew Smith

made with and by

Niftiness Afoot! Matthew Smith

Keywords