file-lines-stream
v0.2.0
Published
This package allows to read files line by line in both directions. It supports node stream and WebStream API
Downloads
16
Readme
file-lines-stream
This package allows to read files line by line in both directions. It supports node stream and WebStream API
Basic usage
WebStream API
import { createForwardReadableStream } from "file-lines-stream/WebStream";
const stream = await createForwardReadableStream('file.txt');
stream.pipeTo(new WritableStream({ write: line => console.log(line) }));
import { createBackwardReadableStream } from "file-lines-stream/WebStream";
const stream = await createBackwardReadableStream('file.txt');
stream.pipeTo(new WritableStream({ write: line => console.log(line) }));
node stream
import { createForwardReadStream } from "file-lines-stream/stream";
import { Writable } from 'stream';
const stream = await createForwardReadStream('file.txt');
stream.pipe(new Writable({
objectMode: true,
write: (line, _, cb) => {
console.log(line);
cb();
}
}));
import { createBackwardReadStream } from "file-lines-stream/stream";
import { Writable } from 'stream';
const stream = await createBackwardReadStream('file.txt');
stream.pipe(new Writable({
objectMode: true,
write: (line, _, cb) => {
console.log(line);
cb();
}
}));