Skip to content

Instantly share code, notes, and snippets.

@Vannevelj
Created November 23, 2015 11:39
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Vannevelj/83b1e4329ef95500f976 to your computer and use it in GitHub Desktop.
function doReplaceASync() {
const input = 'haha';
const result = input.replace(/a/g, function() {
let result;
myAsyncFunc(function(err, data) {
result = data;
});
return result;
});
console.log(result);
};
function myAsyncFunc(cb) {
let total = 5;
for(let i = 0; i < 1000000; i++){
total++;
}
cb(null, 'e');
}
doReplaceASync();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment