Filesystem.readStream()

Open a readable stream that will pump out the contents from a file on disk.

This machine determines whether a file actually exists, is not a directory, and can be opened at the provided source path. The responsibility for any other validations falls on the consumer of the stream. However, this machine _DOES_ bind an `error` event handler on the stream to prevent emitted error events from crashing the process; ensuring that this machine is agnostic of its userland environment. If you plan to write code which uses the readable stream returned by this machine but you have never worked with file streams in Node.js, [check this out](https://docs.nodejitsu.com/articles/advanced/streams/how-to-use-fs-create-read-stream) for tips. For more information about readable streams in Node.js in general, check out the section on [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable) in the Node.js docs.

Usage

Hover over inputs/exits for more info.

var Filesystem = require('machinepack-fs');


// Open a readable stream that will pump out the contents from a file on disk.

Filesystem.readStream({

source: '/Users/mikermcneil/.tmp/foo',

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// No file could be found at the provided `source` path.

doesNotExist: function () {

 

},

// The specified path pointed to a directory.

isDirectory: function () {

 

},

// OK.

success: function (result) {

 

},

});

Inputs

source required

Absolute path to the source file (if relative path is provided, will resolve path from current working directory).

'/Users/mikermcneil/.tmp/foo'

Exits

error

An unexpected error occurred.

doesNotExist

No file could be found at the provided `source` path.

isDirectory

The specified path pointed to a directory.

success

OK.

'==='