Skip to content

Instantly share code, notes, and snippets.

@Vannevelj
Created November 23, 2015 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vannevelj/c8901ad12f223bbde40d to your computer and use it in GitHub Desktop.
Save Vannevelj/c8901ad12f223bbde40d to your computer and use it in GitHub Desktop.
function doReplacePromise() {
const input = 'haha';
const result = input.replace(/a/g, function() {
let result;
myPromiseFunc()
.then(function(data) {
result = data;
});
return result;
});
console.log(result);
};
function myPromiseFunc(cb) {
return new Promise(function(resolve, reject) {
resolve('e');
});
}
doReplacePromise();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment