Last active
August 29, 2015 14:27
-
-
Save PetterKraabol/fe58c23c96c99ffaf645 to your computer and use it in GitHub Desktop.
Asynchronous JSON reader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
// Read data from file | |
exports.read = function(file, callback){ | |
fs.readFile(file, function(err, dataString){ | |
if(err) callback(err); | |
var data = JSON.parse(dataString, function(key, value){ | |
return value; | |
}); | |
return callback(null, data); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment