Last active
March 7, 2017 08:25
-
-
Save toddzebert/95bcc9b50febad0bb9680d3eab897797 to your computer and use it in GitHub Desktop.
"simulates" an async function and passes either `res` directly or the result of `res()` to the callback function, see https://gist.github.com/toddzebert/cee6d8b0475275be0f48d7dfef142bd3
This file contains hidden or 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
// requires https://gist.github.com/toddzebert/b4465de41b0f8d317d7a685604983c36 | |
function asyncSim (res, data, onDone) { | |
var result = (typeof res === "function") ? res(data) : res; | |
setTimeout(function () { onDone(result); } | |
, randInt(400, 200)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment