balanced-line-split

2.0.0 • Public • Published

balanced-line-split

Split a string into multiple lines of similar lengths.

Install

$ npm install balanced-line-split

Usage

import balancedLineSplit from 'balanced-line-split';

const string = 'split me evenly';
const result = balancedLineSplit(string, 3);

// split
// me
// evenly

API

balancedLineSplit(str, lines = 1, maxLineLength = Infinity)

string

Type: string

The string to split.

lines

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.

maxLineLength

Type: Number

Attempt to stay within a specified maximum line length.

Related

  • Balance Text - balanced-line-split is based off the algorithm from this package

License

MIT © Brad Dougherty

Readme

Keywords

none

Package Sidebar

Install

npm i balanced-line-split

Weekly Downloads

10

Version

2.0.0

License

MIT

Unpacked Size

5.56 kB

Total Files

4

Last publish

Collaborators

  • bdougherty