Add a lil’ divider string beneath a source string. Use it to create separation in console logs or stdout.
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);
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);
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);
Return just the divider with a length equal to the input length
const output = divide('string', { omitSource: true });
/* Returns:
------
*/
console.log(output);
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);
In honesty, I made this to test Rollup, continuous integrations, and npm packages, but it totally does what it says on the box, too!