npm/multi-fs — pull request #8 by ceejbot (2014-10-24 22:01:49+00:00)
Title: Chain up Zalgo's cousin the exhausted stream aka the shambling mummy.

The base client class now wraps all incoming data in a stream (if necessary) and pipes immediately to a pass-through stream before handing the task off to individual clients. This ensures that all the clients get piped
to properly in the first tick, so no one client can race ahead & snag all the data before others are read.

Removed repeated stream-wrapping code from the implementations of `_writeFileCore`. (Manta continues to have its own standalone implementation.)

To reproduce, install `request` somewhere then run this:

```javascript
var
fs = require('fs'),
MultiFS = require('../multi-fs'),
path = require('path'),
Request = require('request'),
stream = require('stream')
;

var base = path.resolve(__dirname, 'fixtures')
var mf = new MultiFS([
'scp://localhost:',
{
path: '.',
type: 'scp',
user: 'remote-user',
host: 'some-non-local-host.example.com'
}
]);

var pt = new stream.PassThrough()
var req = Request.get('https://i.cloudup.com/Dizy8E2LSU.jpg').pipe(pt);
mf.writeFile('calvin_and_hobbes.jpg', pt, 'binary', function(err, result)
{
mf.close();
process.exit();
});
```

(Replace example with a real host!) Before this fix, the second client will get 0 bytes. After, it gets the full data payload as desired.