kriszyp/promised-io — Issue #24: Can't pass encoding to readFile
Author: jdeal
Created: 2011-12-05 04:56:15+00:00
State: open

This code:

```js
var fs = require('promised-io/fs');
file = fs.readFile('myfile.txt', 'utf-8');
file.then(function (content) {
console.log(content)
});
```

will print out the raw stream, rather than the plain text, because the encoding is not being passed to the underlying readFile. This is because the underlying function is declared as:

```js
fs.readFile = function(path, encoding_) {
```

so its length is 2, but when passing the encoding, the callback is at position 3.