Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

readline-transform

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

readline-transform

Transform stream to read line-by-line and write a string

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ReadlineTransform

npm Node License dependencies Status Build Status Coverage Status

Reading String or Buffer content from a Readable stream and writing each line which ends without line break as object

Install

$ npm install -save readline-transform

How to Use

Create a ReadlineTransform

new ReadlineTransform(options)

  • options <Object>
    • breakMatcher is the regular expression to split content by line break for str.split(). (default: /\r?\n/)
    • ignoreEndOfBreak is boolean. if content ends with line break, ignore last empty line. (default: true)
    • skipEmpty is boolean. if line is empty string, skip it (default: false)

An example

const { PassThrough } = require('stream');
const ReadlineTransform = require('readline-transform');

const readStream = new PassThrough();
const transform = new ReadlineTransform({ skipEmpty: true });
const writeStream = new PassThrough({ objectMode: true });

writeStream.on('data', (line) => {
  console.log(line);
}).on('finish', () => {
  console.log('<<< all done >>>');
});

readStream.pipe(transform).pipe(writeStream);

readStream.write(new Buffer('foo\nba'));
readStream.write(new Buffer('r\r\n\n\r'));
readStream.end(new Buffer('\nbaz'));

Console output

$ node example.js
foo
bar
baz
<<< all done >>>

Keywords

FAQs

Package last updated on 07 Aug 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc