New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

stream-sync

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-sync

Synchronous stream library. Includes FileReadStreamSync

latest
Source
npmnpm
Version
1.2.0
Version published
Maintainers
1
Created
Source

stream-sync

Synchronous streams for NodeJS. Compatible with default node stream.

Contains:

  • FileReadStreamSync (includes readLine function for big Files)
  • FileWriteStreamSync
  • BufferReadStreamSync (string or buffer stream reader)
  • BufferWriteStreamSync (string or buffer stream writer)

Installation

npm install stream-sync

Usage

Read file to String

const syncStream = require('stream-sync');
let rstream = new syncStream.FileReadStreamSync('test.txt');
let wstream = new syncStream.BufferWriteStreamSync({encoding: 'utf8'});
rstream.pipe(wstream);
console.info(wstream.toString());

Read file async to String

const syncStream = require('stream-sync');
let rstream = fs.createReadStream('test.txt');
let wstream = new syncStream.BufferWriteStreamSync({encoding: 'utf8'});
rstream.pipe(wstream);
rstream.on('end', function () {
	console.info(wstream.toString());
});

Read file

const syncStream = require('stream-sync');
let rstream = new syncStream.FileReadStreamSync('test.txt', {encoding: 'utf8'});
var chunk = null;
while ((chunk = rstream.read()) !== null) {
	console.info(chunk);
}

Read-Line file

const syncStream = require('stream-sync');
let rstream = new syncStream.FileReadStreamSync('test.txt', {encoding: 'utf8'});
var line = null;
while ((row = rstream.readLine()) !== null) {
	console.info(line);
}

Copy file

const syncStream = require('stream-sync');
let rstream = new syncStream.FileReadStreamSync('test.txt', {encoding: 'utf8'});
let wstream = new syncStream.FileWriteStreamSync('test2.txt', {encoding: 'utf8'});
rstream.pipe(wstream);

Keywords

syncronous

FAQs

Package last updated on 07 Apr 2022

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