I am following a tutorial about nodejs. In the tutorial it has this example:
const fs = require('fs');
const conversionMap = {
'88': '65',
'89': '66',
'90': '67',
};
fs.readFile(__filename, (err, buffer) => {
let tag = buffer.slice(-4, -1);
for(let i=0;i < tag.length; i++) {
tag[i] = conversionMap[tag[i]];
}
console.log(buffer.toString());
});
// TAG: XYZ
I am pretty sure I know what this example is doing. It is reading the file, then allocating it to a buffer and writing it out. I know that it finds the TAG via slice(-4, -1) (The tag it 1 up from the bottom and for over). I am just not sure it changes it.
Thanks in advance for the help!
via Zoe Carver
No comments:
Post a Comment