Reputation: 307
I have two .js files with several functions defined in them and I wish to compare the contents of these two files. Is there an npm package for such a comparison or any other way to do this?
Upvotes: 0
Views: 2327
Reputation: 101
You just need to compare them as if they were 2 plain text files. You could do something like this:
function readFile(name) {
return new Promise((resolve, reject) =>
fs.readFile(name, function (err, data) {
if (err) { reject(err); }
resolve(data);
});
});
}
Promise.all(readFile('file1'), readFile('file2')).then(data => {
var file1 = data[0];
var file2 = data[1];
});
Upvotes: 3