How to use the Reader function from fstream

Find comprehensive JavaScript fstream.Reader code examples handpicked from public code repositorys.

The fstream.Reader is a Node.js module that reads file streams and directories as well as filters or transforms files.

143
144
145
146
147
148
149
150
151
152

if (!fs.existsSync(self.path))
  wrench.mkdirSyncRecursive(self.path);

// Copy everything over
var reader = fstream.Reader(self.sourcePath);
var writer = fstream.Writer(self.path);

// Ok fs copy is done
writer.on('close', function() {
fork icon111
star icon839
watch icon53

6
7
8
9
10
11
12
13
14
15
var fs = require('fs-extra');
var fstream = require('fstream');
var tags = require('common-tags');
var tar = require('tar');

var Reader = fstream.Reader;

// Internal
var commands = require('../commands');
var lists = require('./lists/rust');
fork icon56
star icon115
watch icon30

+ 3 other calls in file

How does fstream.Reader work?

fstream.Reader is a readable stream class in Node.js that reads a directory, applying optional filters, and emitting an object for each directory entry. It is typically used to read and process the contents of a directory.

229
230
231
232
233
234
  }, callback);
};


publish._pack = function(dir, file, callback) {
  fstream.Reader({
fork icon34
star icon223
watch icon29

+ 3 other calls in file

125
126
127
128
129
130
131
132
133
134
if (err) return this.emit('error', err);
rimraf(this.localPath, function (err) {
  if (err) return this.emit('error', err);
  return fs.rename(this.path, this.localPath, function (err) {
    if (!err) return this.cleanUpLocal();
    fstream.Reader(this.path)
      .on('error', this.emit.bind(this, 'error'))
      .on('end', rimraf.bind(this, this.path, this.cleanUpLocal.bind(this)))
      .pipe(
        fstream.Writer({
fork icon2
star icon4
watch icon0

+ 3 other calls in file

Ai Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const fstream = require("fstream");
const path = require("path");

const filePath = path.join(__dirname, "file.txt");

const reader = new fstream.Reader(filePath);

reader.on("data", (chunk) => {
  console.log(chunk.toString());
});

reader.on("end", () => {
  console.log("End of stream");
});

reader.on("error", (error) => {
  console.error(error);
});

In this example, a fstream.Reader instance is created with the path to a file, and event listeners are attached to handle data, end, and error events emitted by the stream. When data is received from the stream, it's logged to the console as a string. When the end event is emitted, a message is logged to the console. And if an error occurs, the error is logged to the console.

2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
  'working-dir'
);
projectPath = path.join(temp.mkdirSync('atom'));

const writerStream = fstream.Writer(projectPath);
fstream.Reader(sourceProjectPath).pipe(writerStream);

await new Promise(resolve => {
  writerStream.on('close', resolve);
  writerStream.on('error', resolve);
fork icon1
star icon2
watch icon1

+ 2 other calls in file

17
18
19
20
21
22
23
24
25
if (reader.type === 'Directory' && reader.ignore) {
    ignore = reader.ignore;
    reader = fstreamIgnore(reader);
    reader.addIgnoreRules(ignore);
} else {
    reader = fstream.Reader(reader);
}

deferred = Q.defer();
fork icon0
star icon2
watch icon0

137
138
139
140
141
142
143
144
145
146
  var wanted = expectEntries[ee++]
  t.equivalent(found, wanted, 'tar entry ' + ee + ' ' + (wanted && wanted.path))
})

function next () {
  var r = fstream.Reader({
    path: target,
    type: 'Directory',
    sort: 'alpha'
  })
fork icon0
star icon1
watch icon1

+ 2 other calls in file