Created
July 21, 2017 21:26
-
-
Save apaleslimghost/9259878a2b5417f38e6f46e393056e31 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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