Wrap an async function and ensure it calls its callback on a later tick of the event loop. Based on async#ensureAsync as module.
npm install ensure-async --save
If you want to use in the browser (powered by Browserify):
bower install ensure-async --save
and later link in your HTML:
<script src="bower_components/ensure-async/dist/ensure-async.js"></script>
var ensureAsync = require('ensure-async');
MIT © Kiko Beats