Product Lead @ Pulse Energy
Paul Teehan
Energy Analytics Developer @ Pulse Energy
+
+
+
Energy utilities
Smart grid data
Make the world a better place
fs.readFile(filename, [options], callback)
var callback = function (err, data) {}
fs.readFile('/buildings.csv', function (err, data) {
if (err) {
throw err;
}
console.log(data);
});
var result = fs.readFile('/buildings.csv', function (err, data) {
if (err) {
throw err;
}
return data;
});
console.log(result); // ????
var loadBuildings = function (buildingType, cb) {
fs.readFile('/buildings.csv', function (err, data) {
if (err) {
cb(err);
}
processData(data, cb);
});
}
loadBuildings(buildingType).then(function (buildingData) {
return processData(buildingData);
}).fail(function (err) {
return handleError(err);
});
process.on('uncaughtException', function (err) {
logger.error(err, 'Unhandled error');
process.exit(1);
});
process.on('exit', function () {
logger.info('Process is exiting');
});