Socket
Socket
Sign inDemoInstall

readline-stream

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

readline-stream

super-simple line-by-line Stream reader


Version published
Maintainers
1
Created
Source

readline-stream -- buffered Stream for reading lines

byline is a super-simple module providing a ReadlineStream for node.js.

This is based on 'byline' transform by @jahewson with modifications from @Tsenzuk. I've clean-up their code and used a better RegEx that allow to include breaklines and have a behaviour more similar to Python readline function

  • node v0.10 streams2 (transform stream)
  • supports pipe
  • supports both UNIX and Windows line endings
  • can be used as a readable-writable "through-stream" (transform stream)

Install

npm install readline-stream

or from source:

git clone git://github.com/piranna/readline-stream.git
cd readline-stream
npm link

#Convenience API

The data event then emits lines:

stream.on('data', function(line) {
  console.log(line);
});

#Standard API

You just need to add one line to wrap your readable Stream with a ReadlineStream.

var fs = require('fs'),	
    byline = require('readline-stream');

var stream = fs.createReadStream('sample.txt');
stream = stream.pipe(ReadlineStream());

stream.on('data', function(line) {
  console.log(line);
});

#Piping

byline supports pipe while remaining the line endings.

#Transform Stream

The readline-stream transform stream can be directly manipulated like so:

var LineStream = require('byline').LineStream;

var input = fs.createReadStream('sample.txt');
var output = fs.createWriteStream('nolines.txt');

var lineStream = new ReadlineStream();
input.pipe(lineStream);
lineStream.pipe(output);

#Tests

mocha -R spec

#Simple Unlike other modules (of which there are many), readline-stream contains no:

  • monkeypatching
  • limitations to only file streams
  • CoffeeScript
  • mostly unnecessary code

FAQs

Package last updated on 19 May 2017

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