I see a first problem in your code:
function realBinary(data, file_id){
var BufferData = new Buffer.alloc(data.size);
const file = fs.createReadStream('data/'+file_id+'.pro/Project Title.pro');
fs.open('data/'+file_id', 'r', function(err, fd){
// ^ this quote should be removed
var read = fs.readSync(fd, BufferData, 0, size, imageAddress);
console.log(BufferData.toString('base64') // correct result.
data.src = 'data:image/jpeg;base64, '+BufferData.toString('base64');
console.log(data.src) // correct value
fs.close(fd, function(){
console.log("cloe fd");
})
});
/* here data.src is undefined */
console.log(data.src)
}
[Update]
Professional programmer's editors have features especially tailored for programmers like indentation, parenthesis matching and syntax highlighting.
Notepad++ Home[
^]
ultraedit[
^]
Enabling Open Innovation & Collaboration | The Eclipse Foundation[
^]
Indentation style - Wikipedia[
^]