Skip to content
This repository was archived by the owner on May 5, 2023. It is now read-only.

Commit d56395c

Browse files
committed
Export supportsAsync
1 parent c0ed648 commit d56395c

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/index.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { parseScript } from 'esprima';
44
import { visit, namedTypes as n, builders as b } from 'ast-types';
55
import { Context, RunningScriptOptions, runInNewContext } from 'vm';
66

7-
import supportsAsync from './supports-async';
7+
import _supportsAsync from './supports-async';
88
import generatorToPromise from './generator-to-promise';
99

1010
/**
@@ -152,13 +152,14 @@ namespace degenerator {
152152
RunningScriptOptions {
153153
sandbox?: Context;
154154
}
155+
export const supportsAsync = _supportsAsync;
155156
export function compile<T extends Function>(
156157
code: string,
157158
returnName: string,
158159
names: DegeneratorNames,
159160
options: CompileOptions = {}
160161
): T {
161-
const output = supportsAsync ? 'async' : 'generator';
162+
const output = _supportsAsync ? 'async' : 'generator';
162163
const compiled = degenerator(code, names, { ...options, output });
163164
const fn = runInNewContext(
164165
`${compiled};${returnName}`,

test/test.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import fs from 'fs';
22
import path from 'path';
33
import assert from 'assert';
4-
import degenerator, { compile } from '../src';
4+
import degenerator, { compile, supportsAsync } from '../src';
55

66
describe('degenerator()', () => {
7+
describe('`supportsAsync`', () => {
8+
it('should export boolean `supportsAsync`', () => {
9+
assert.equal(typeof supportsAsync, 'boolean');
10+
});
11+
});
12+
713
describe('"async" output', () => {
814
it('should support "async" output functions', () => {
915
function aPlusB(a: () => string, b: () => string): string {

0 commit comments

Comments
 (0)