Skip to content

Instantly share code, notes, and snippets.

@viniceosm
Created January 24, 2020 19:19
Show Gist options
  • Save viniceosm/cc4f8d0eba3aa8bc4b207f39f2e301dc to your computer and use it in GitHub Desktop.
Save viniceosm/cc4f8d0eba3aa8bc4b207f39f2e301dc to your computer and use it in GitHub Desktop.
in working....
<html>
<script>
var Pessoa = {
pesquisa: function (arg1, callback) {
callback([
{
nome: 'Vinícius'
},
{
nome: 'Amanda'
}
]);
}
};
function cbToPromise (fn, nameCallback = 'callback') {
// procurar os callback -> 'callback(result111)'.match(/callback\(.*\)/g)
}
// Chamando a função com callback
Pessoa.pesquisa(null, (pessoas) => {
console.log('Pessoas:', pessoas);
});
// cbToPromise(Pessoa.pesquisa(null)).then();
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment