Split a string into multiple lines of similar lengths.
MIT License
Split a string into multiple lines of similar lengths.
$ npm install balanced-line-split
import balancedLineSplit from 'balanced-line-split';
const string = 'split me evenly';
const result = balancedLineSplit(string, 3);
// split
// me
// evenly
Type: string
The string to split.
Type: Number
The number of lines to split the string across. Note that the resulting string will include enough line breaks to match this number of lines, even if there is no text to fill them.
Type: Number
Attempt to stay within a specified maximum line length.
MIT © Brad Dougherty