Skip to content

Instantly share code, notes, and snippets.

@khaosdoctor
Created April 6, 2019 18:27
Show Gist options
  • Save khaosdoctor/7ac85949806b213763bfe2d5e87262e1 to your computer and use it in GitHub Desktop.
Save khaosdoctor/7ac85949806b213763bfe2d5e87262e1 to your computer and use it in GitHub Desktop.
const fs = require('fs')
function callbackRead(err, dados) {
if (err) throw new Error(err)
fs.writeFile('./outroarquivo.txt', dados, callbackWrite)
}
function callbackWrite (err) {
if (err) throw new Error(err)
outraFuncaoAssincrona(callbackAsync1)
}
function callbackAsync1 (err, dados) {
const x = dados.split(',')
const y = x.map((e) => e.toUpperCase())
maisUmaFuncaoAssincrona(y, callbackAsync2)
}
function callbackAsync2 (err, resultado) {
// ...
}
fs.readFile('./arquivo.txt', callbackRead)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment