wrap-async

Wraps an async function so it can called synchronously

Usage no npm install needed!

<script type="module">
  import wrapAsync from 'https://cdn.skypack.dev/wrap-async';
</script>

README

wrap-async

Wraps an async function so it can called synchronously

Usage:

Import:

const wrap = require('wrap-async')

Express controller:

exports.getRequest = wrap(async function (req, res) {
  res.status(200)
})

Immediate invocation:

wrap(async function() {
  return await http()
})()