Skip to content

Improve integration with streams #243

Closed
@mrmlnc

Description

@mrmlnc

Source issues

Code

public read(task: Task): Readable {
const root = this._getRootDirectory(task);
const options = this._getReaderOptions(task);
const source = this.api(root, task, options);
const destination = new Readable({ objectMode: true, read: () => { /* noop */ } });
source
.once('error', (error: ErrnoException) => destination.emit('error', error))
.on('data', (entry: Entry) => destination.emit('data', options.transform(entry)))
.once('end', () => destination.emit('end'));
destination
.once('close', () => source.destroy());
return destination;
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions