how to export fs readfile

Solutions on MaxInterview for how to export fs readfile by the best coders in the world

showing results for - "how to export fs readfile"
Debora
04 Mar 2016
1var fs = require('fs');
2
3module.exports = {
4    parseFile: function(file_path, callback) {
5        fs.readFile(file_path.toString(), 'utf-8', function(err, data) {
6            if (err) return callback(err);
7            callback(null, data);
8        });
9    }
10}
11
12// much shorter version
13exports.parseFile = function(file_path, callback) {
14    fs.readFile(file_path.toString(), 'utf-8', callback);
15}
16