# split-text-to-chunks

> Split a text string to chunks for e.g. word wrapping

Latest version **1.0.0** (published 2017-09-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install split-text-to-chunks
pnpm add split-text-to-chunks
yarn add split-text-to-chunks
bun add split-text-to-chunks
```

Provides the command `wordwrap`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2017-09-18 |
| First published | 2017-09-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | thomas-jensen |

## Links

- npm: https://www.npmjs.com/package/split-text-to-chunks
- Repository: https://github.com/srcagency/wrap-words
- Homepage: https://github.com/srcagency/wrap-words#readme
- Issues: https://github.com/srcagency/wrap-words/issues
- npm.io page: https://npm.io/package/split-text-to-chunks

## Dependencies (2)

- [minimist](https://npm.io/package/minimist.md) ^1.2.0
- [get-stdin](https://npm.io/package/get-stdin.md) ^5.0.1

## Recent versions

- 1.0.0 (latest) — 2017-09-18

## README

# Split text into chunks

Prefers splitting at whitespace characters, but falls back to "hard wrapping",
and obeys existing newlines.

```js
const {split,width} = require('split-text-to-chunks')

const str = 'A lazy 🐶 made a pile of 💩'

split(str, 8/*columns*/)
// -> [ 'A lazy 🐶', 'made a ', 'pile of ', '💩' ]

split('A lazy dog', 3)
// -> [ 'A ', 'laz', 'y ', 'dog' ]

split('A lazy\ndog', 10)
// -> [ 'A lazy', 'dog' ]

width(str)
// -> 25

width(str, 20/* max, stop counting */)
// -> 20

width('one\ntwo\nthree')
// -> 5
```

```sh
$ npm i -g split-text-to-chunks

$ printf "A lazy 🐶 made a pile of 💩" | wordwrap --columns 8 # default: 80
A lazy 🐶
made a
pile of
💩

$ printf "A lazy 🐶\nmade a pile of 💩" | wordwrap --width
16
```

---
_Source: https://npm.io/package/split-text-to-chunks · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
