🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

wrapline

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wrapline

Add prefix/suffix to lines of a text stream.

2.0.1
latest
Source
npm
Version published
Weekly downloads
9.5K
-14.93%
Maintainers
1
Weekly downloads
 
Created
Source

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 a stream

var WrapLine = require('wrapline')
var stream = WrapLine()
fs.createReadStream('before.txt')
.pipe(WrapLine('  ')) // indent entire stream with 2 spaces
.pipe(fs.createWriteStream('after.txt'))

before.txt

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.

after.txt

  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 and suffix to each line

var WrapLine = require('wrapline')
var stream = WrapLine()
fs.createReadStream('before.txt')
.pipe(WrapLine('<', '>')) // indent entire stream with 2 spaces
.pipe(fs.createWriteStream('after.txt'))

after.txt

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

Dynamically add prefix/suffix to line

var WrapLine = require('wrapline')
var stream = WrapLine()
fs.createReadStream('before.txt')
.pipe(WrapLine(' '))
.pipe(WrapLine(function(pre, line) {
  pre = pre || -1
  return pre + 1
}))
.pipe(fs.createWriteStream('after.txt'))

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
  • hughsk/wrapstream

License

MIT

Keywords

indent

FAQs

Package last updated on 10 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts