I have a promisified method I called readFilePromise, that resolves to a Buffer object from fs' readFile method. When I execute the following line
return readFilePromise(filePath).then(Buffer.prototype.toString.call);
I get the following error:
TypeError: undefined is not a function
However, when I execute the block:
return readFilePromise(filePath).then((data) => {
return Buffer.prototype.toString.call(data);
});
I get no error and the code executes fine.
In my mind they should be the same. Am I missing something obvious?
node v6.10.1