wrap-await
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

wrap-await Build Status

Wraps code that contains await expressions in an async iife

Install

$ npm install wrap-await

Usage

const wrapAwait = require('wrap-await')
 
wrapAwait('await Promise.resolve(5)')
//=> '(async () {return await Promise.resolve(5)})()'

API

wrapAwait(input, [options])

Wrap JavaScript code in an async function, while also preserving the usual variable scoping rules. If the input code doesn't include a top level await expression - null is returned.

code

Type: string

Input code string.

License

MIT © nikersify

/wrap-await/

    Package Sidebar

    Install

    npm i wrap-await

    Weekly Downloads

    11

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    6.19 kB

    Total Files

    5

    Last publish

    Collaborators

    • nikersify