Skip to content

Instantly share code, notes, and snippets.

@toddzebert
Last active March 7, 2017 08:25
Show Gist options
  • Save toddzebert/95bcc9b50febad0bb9680d3eab897797 to your computer and use it in GitHub Desktop.
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
// 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