# wrapline

> Add prefix/suffix to lines of a text stream.

Latest version **2.0.1** (published 2014-08-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install wrapline
pnpm add wrapline
yarn add wrapline
bun add wrapline
```

## 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 | 2.0.1 |
| Published | 2014-08-10 |
| First published | 2014-08-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Tim Oxley |
| Maintainers | timoxley |
| Keywords | indent, stream, prefix, suffix |

## Links

- npm: https://www.npmjs.com/package/wrapline
- Repository: https://github.com/timoxley/wrapline
- Issues: https://github.com/timoxley/wrapline/issues
- npm.io page: https://npm.io/package/wrapline

## Dependencies (3)

- [split2](https://npm.io/package/split2.md) ^0.1.2
- [through2](https://npm.io/package/through2.md) ^0.5.1
- [duplexer2](https://npm.io/package/duplexer2.md) ~0.0.2

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2014-08-10
- 2.0.0 — 2014-08-10

## README

# wrapline

[![Build Status](https://travis-ci.org/timoxley/wrapline.svg?branch=master)](https://travis-ci.org/timoxley/wrapline)

Add a prefix and/or suffix each line of a text stream.

This package used to be named `indent-stream` until 2.0.0 when the
ability to add suffixes was added. Still proves good for indenting
streams.

## Examples

### Indent each line of a stream

```js
var WrapLine = require('wrapline')
var stream = WrapLine()
fs.createReadStream('before.txt')
.pipe(WrapLine('  ')) // indent entire stream with 2 spaces
.pipe(fs.createWriteStream('after.txt'))
```
Input:
```
Lorem ipsum dolor sit amet, quo ad quis latine.
Erant scribentur ne ius.
Nostrud vocibus luptatum eam ex, mel novum delenit scaevola no.
No iriure mentitum platonem usu, te nec ocurreret instructior.
Vim quem quis at.
```

Output:
```
  Lorem ipsum dolor sit amet, quo ad quis latine.
  Erant scribentur ne ius.
  Nostrud vocibus luptatum eam ex, mel novum delenit scaevola no.
  No iriure mentitum platonem usu, te nec ocurreret instructior.
  Vim quem quis at.
```

### Add prefix/suffix to each line

```js
var WrapLine = require('wrapline')
var stream = WrapLine()
fs.createReadStream('before.txt')
.pipe(WrapLine('<', '>')) // <surround line contents>
.pipe(fs.createWriteStream('after.txt'))
```

```
<Lorem ipsum dolor sit amet, quo ad quis latine.>
<Erant scribentur ne ius.>
```

### Dynamically add prefix/suffix to each line

e.g. Adding line numbers

```js
var WrapLine = require('wrapline')
var stream = WrapLine()
fs.createReadStream('before.txt')
.pipe(WrapLine(' ')) // add space
.pipe(WrapLine(function(pre, line) {
  // add 'line numbers' to each line
  pre = pre || 0
  return pre + 1
}))
.pipe(fs.createWriteStream('after.txt'))
```

```
1 Lorem ipsum dolor sit amet, quo ad quis latine.
2 Erant scribentur ne ius.
3 Nostrud vocibus luptatum eam ex, mel novum delenit scaevola no.
4 No iriure mentitum platonem usu, te nec ocurreret instructior.
5 Vim quem quis at.
```

## See Also

* [neoziro/stream-line-wrapper](https://github.com/neoziro/stream-line-wrapper)
* [hughsk/wrapstream](https://github.com/hughsk/wrap-stream)

## License

MIT

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