Imagine that we define a function that can do a unit of work some time later called doSomeAsyncWork
.
You pass it how long you want to wait before doing the work and a 'work' function which receives both
resolve and reject...
var doSomeAsyncWork = function (timeMs, work) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
work(resolve, reject);
}, timeMs);