Skip to content

Instantly share code, notes, and snippets.

@apaleslimghost
Created July 21, 2017 21:26
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 apaleslimghost/9259878a2b5417f38e6f46e393056e31 to your computer and use it in GitHub Desktop.
Save apaleslimghost/9259878a2b5417f38e6f46e393056e31 to your computer and use it in GitHub Desktop.
const nextTick = require('next-tick');
exports.alert = text => new Promise(resolve => nextTick(() => {
alert(text);
resolve();
}));
exports.confirm = text => new Promise(resolve => nextTick(() => {
resolve(confirm(text));
}));
exports.prompt = (text, fallback) => new Promise((resolve, reject) => nextTick(() => {
const result = prompt(text, fallback);
if(result !== null) {
resolve(result);
} else {
reject();
}
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment