Skip to content

Instantly share code, notes, and snippets.

@bendrucker
Created December 29, 2015 05:45
Show Gist options
  • Save bendrucker/6efe250deeac7297a5a3 to your computer and use it in GitHub Desktop.
Save bendrucker/6efe250deeac7297a5a3 to your computer and use it in GitHub Desktop.
function getUrls (callback) {
fs.readFile('./cache.json', function (err, data) {
if (err && err.code !== 'ENOENT') return callback(err)
getDataFromServer(function (err, data) {
if (err) return callback(err)
callback(null, data)
fs.writeFile('./cache.json', JSON.stringify(data), noop)
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment