Configuration.read()
Description
Appends a read filter to the current pipeline layout.
A read filter reads from a file and outputs its content as a Data stream.
- INPUT - Any types of Events.
- OUTPUT - File content as a Data stream.
The specified file is opened at the first received input event, whatever type of event it is. The filter's output has only Data events from the file's content, ended with a StreamEnd event. All input events are simply discarded.
The pathname of the file to read is specified in the first parameter. It can be a function that returns a pathname. The pathname can be "-" for reading from the standard input.
Syntax
pipy().pipeline().read(filename)pipy().pipeline().read(() => getFilename())
Parameters
read(filename)
filename
Pathname to read from or a callback function that returns the pathname. Can be "-" for reading from the standard input.
Return Value
The same Configuration object.
Example
pipy().task().onStart(() => new Message).read('/path/to/input.txt') // Open and read from file /path/to/input.txt.dump() // Dump to stdout whatever is in the file