0

Not sure if it is bug or some hidden feature, but code below doesn't return anything if it is not in debugging. It supposed to return Hex buffer.

var fs = require("fs");
var d = fs.readFileSync("app.js");
console.log(d);

If I set break point on second line and debug - console.log prints buffer value.

Also all works if console.log(d.toString()).

I am developing in VSCode - may be bug with IDE?

Same code run as node app.js, outputs HEX buffer.

Any idea?

1
  • What do you use for debugging? I think that console log internally use util.inspect method. And this method can be customized. Maybe when debugging some customization is used? Commented Feb 11, 2018 at 15:02

1 Answer 1

1

Check now, added character encoding 'utf8'

var fs = require("fs");
var d = fs.readFileSync("app.js",  'utf8');
console.log(d);
Sign up to request clarification or add additional context in comments.

1 Comment

with utf8 it works, same as .toString(). Quesiton is why vsCode doesn't show pure buffer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.