Skip to content

Commit

Permalink
[degenerator] Use util.types.isRegExp() (#164)
Browse files Browse the repository at this point in the history
`util.isRegExp()` is marked as deprecated.
  • Loading branch information
TooTallNate committed May 9, 2023
1 parent f173f80 commit 9326064
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/slimy-pillows-do.md
@@ -0,0 +1,5 @@
---
'degenerator': patch
---

Use `util.types.isRegExp()` to fix deprecation warning
8 changes: 4 additions & 4 deletions packages/degenerator/src/index.ts
@@ -1,4 +1,4 @@
import { isRegExp } from 'util';
import { types } from 'util';
import { generate } from 'escodegen';
import { parseScript } from 'esprima';
import { visit, namedTypes as n, builders as b } from 'ast-types';
Expand Down Expand Up @@ -92,13 +92,13 @@ export function degenerator(code: string, _names: DegeneratorNames): string {
});
} while (lastNamesLength !== names.length);

// Second pass is for adding `await`/`yield` statements to any function
// Second pass is for adding `await` statements to any function
// invocations that match the given `names` array.
visit(ast, {
visitCallExpression(path) {
if (checkNames(path.node, names)) {
// A "function invocation" expression,
// we need to inject a `AwaitExpression`/`YieldExpression`
// we need to inject an `AwaitExpression`
const delegate = false;
const {
name,
Expand Down Expand Up @@ -203,7 +203,7 @@ function checkName(name: string, names: DegeneratorNames): boolean {
// now that we have the `name`, check if any entries match in the `names` array
for (let i = 0; i < names.length; i++) {
const n = names[i];
if (isRegExp(n)) {
if (types.isRegExp(n)) {
if (n.test(name)) {
return true;
}
Expand Down

1 comment on commit 9326064

@vercel
Copy link

@vercel vercel bot commented on 9326064 May 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

proxy-agents – ./

proxy-agents.vercel.app
proxy-agents-tootallnate.vercel.app
proxy-agents-git-main-tootallnate.vercel.app

Please sign in to comment.