UNPKG

879 BTypeScriptView Raw
1/// <reference types="node" />
2import { Context, RunningScriptOptions } from 'vm';
3/**
4 * Compiles sync JavaScript code into JavaScript with async Functions.
5 *
6 * @param {String} code JavaScript string to convert
7 * @param {Array} names Array of function names to add `await` operators to
8 * @return {String} Converted JavaScript string with async/await injected
9 * @api public
10 */
11declare function degenerator(code: string, _names: degenerator.DegeneratorNames): string;
12declare namespace degenerator {
13 type DegeneratorName = string | RegExp;
14 type DegeneratorNames = DegeneratorName[];
15 interface CompileOptions extends RunningScriptOptions {
16 sandbox?: Context;
17 }
18 function compile<R = any, A extends any[] = []>(code: string, returnName: string, names: DegeneratorNames, options?: CompileOptions): (...args: A) => Promise<R>;
19}
20export = degenerator;