You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var fs = require('fs/promises');
fs.readFile(path,"utf8").then((data)=>...
data will be of type string, when specifying the encoding in the method call, but with the latest version (v10.0.0-nightly20180309099e621648) I have to data.toString("utf8")again, to get the result as string.
Activity
benjamingr commentedon Mar 12, 2018
Looks like a bug to me,
fs.readFileSyncreturns a string for the same call.benjamingr commentedon Mar 12, 2018
Can reproduce locally
Note this works correctly when calling
util.promisifyonfs.readFilebenjamingr commentedon Mar 12, 2018
Looks like the encoding handling is missing in
fs/promisesand it is simply ignored https://github.com/nodejs/node/blob/master/lib/fs.js#L403-L405https://github.com/nodejs/node/blob/master/lib/fs/promises.js#L132 ignores
optionspassed in.benjamingr commentedon Mar 12, 2018
Going to tackle this one
[-]Question: require('fs/promises')[/-][+]fsPromises.readFile ignores encoding[/+][-]fsPromises.readFile ignores encoding[/-][+]fsPromises.readFile ignores encoding option[/+]fs: use encoding in readFile