Socket
Book a DemoInstallSign in
Socket

rewrite-async

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rewrite-async

Rewrite async functions as generators; via RegExp

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

rewrite-async Build Status

Rewrite async functions as generators; via RegExp

Unlike async-to-gen, this does not register a runtime. Instead, the "transpiling" occurs only as needed.

Also, this is only executes a string conversion! You will have to look to other modules in order to execute the returned string.

Note: Although eval() will work, it's generally (and strongly) not recommended.

Built with Bluebird.coroutine in mind. :wink:

Install

$ npm install --save rewrite-async

Usage

const rewriteAsync = require('rewrite-async');

rewriteAsync('async function (one, two) {}');
//=> 'function* (one, two) {}'

rewriteAsync('var foo = async (req, res) => {}');
//=> 'var foo = function* (one, two) {}'

rewriteAsync('async one => await foo(one)');
//=> 'function* (one) {return yield foo(one)}'

API

rewriteAsync(input)

input

Type: string

A function's contents (via .toString()) or any utf-8 string that contains function definitions.

License

MIT © Luke Edwards

FAQs

Package last updated on 13 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts