Skip to content

Commit 9326064

Browse files
authored
[degenerator] Use util.types.isRegExp() (#164)
`util.isRegExp()` is marked as deprecated.
1 parent f173f80 commit 9326064

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

.changeset/slimy-pillows-do.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'degenerator': patch
3+
---
4+
5+
Use `util.types.isRegExp()` to fix deprecation warning

packages/degenerator/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isRegExp } from 'util';
1+
import { types } from 'util';
22
import { generate } from 'escodegen';
33
import { parseScript } from 'esprima';
44
import { visit, namedTypes as n, builders as b } from 'ast-types';
@@ -92,13 +92,13 @@ export function degenerator(code: string, _names: DegeneratorNames): string {
9292
});
9393
} while (lastNamesLength !== names.length);
9494

95-
// Second pass is for adding `await`/`yield` statements to any function
95+
// Second pass is for adding `await` statements to any function
9696
// invocations that match the given `names` array.
9797
visit(ast, {
9898
visitCallExpression(path) {
9999
if (checkNames(path.node, names)) {
100100
// A "function invocation" expression,
101-
// we need to inject a `AwaitExpression`/`YieldExpression`
101+
// we need to inject an `AwaitExpression`
102102
const delegate = false;
103103
const {
104104
name,
@@ -203,7 +203,7 @@ function checkName(name: string, names: DegeneratorNames): boolean {
203203
// now that we have the `name`, check if any entries match in the `names` array
204204
for (let i = 0; i < names.length; i++) {
205205
const n = names[i];
206-
if (isRegExp(n)) {
206+
if (types.isRegExp(n)) {
207207
if (n.test(name)) {
208208
return true;
209209
}

0 commit comments

Comments
 (0)