@cto.af/linewrap
v2.1.3
Published
Wrap lines using the Unicode Line Breaking algorithm from UAX #14
Downloads
55
Maintainers
Readme
@cto.af/linewrap
Wrap lines using Unicode UAX #14 line breaking rules.
Installation
npm install @cto.af/linewrap
CLI
A command line interface is available: @cto.af/linewrap-cli
API
import {LineWrap} from '@cto.af/linewrap'
const w = new LineWrap()
w.wrap('Lorem ipsum dolor sit amet...') // A string, wrapped to your console length
for (const line of w.lines('Lorem ipsum dolor sit amet...')) {
// `line` does not have a newline at the end
}
Full API docs are available.
Methods
Options
Options may be passed into the constructor in an object:
const w = new LineWrap({ width: 40 })
The following options are all optional, having the specified defaults: