Socket
Socket
Sign inDemoInstall

ast-kit

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ast-kit - npm Package Compare versions

Comparing version 0.6.2 to 0.6.3

24

./dist/index.js

@@ -46,4 +46,7 @@ // src/check.ts

// src/parse.ts
import { parse } from "@babel/parser";
function babelParse(code, lang, options = {}) {
import {
parse,
parseExpression
} from "@babel/parser";
function getParserOptions(lang, options = {}) {
const plugins = [...options.plugins || []];

@@ -59,9 +62,15 @@ if (isTs(lang)) {

}
const { program } = parse(code, {
return {
sourceType: "module",
...options,
plugins
});
return program;
};
}
function babelParse(code, lang, options = {}) {
const { program, errors } = parse(code, getParserOptions(lang, options));
return { ...program, errors };
}
function babelParseExpression(code, lang, options = {}) {
return parseExpression(code, getParserOptions(lang, options));
}

@@ -141,3 +150,3 @@ // src/resolve.ts

// src/utils.ts
import { parseExpression } from "@babel/parser";
import { parseExpression as parseExpression2 } from "@babel/parser";
var TS_NODE_TYPES = [

@@ -166,3 +175,3 @@ "TSAsExpression",

try {
const node = parseExpression(`({${rawKey}: 1})`);
const node = parseExpression2(`({${rawKey}: 1})`);
if (node.properties[0].key.type === "Identifier")

@@ -356,2 +365,3 @@ return rawKey;

babelParse,
babelParseExpression,
escapeKey,

@@ -358,0 +368,0 @@ getLang,

@@ -1,3 +0,3 @@

import { Function, Literal, Node, CallExpression, Identifier, Program, PrivateName, ThisExpression, Super, TemplateLiteral, MemberExpression, ImportSpecifier, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportDeclaration } from '@babel/types';
import { ParserOptions } from '@babel/parser';
import { Function, Literal, Node, CallExpression, Identifier, Program, Expression, PrivateName, ThisExpression, Super, TemplateLiteral, MemberExpression, ImportSpecifier, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportDeclaration } from '@babel/types';
import { ParserOptions, ParseResult } from '@babel/parser';
import { AttachedScope } from '@rollup/pluginutils';

@@ -23,3 +23,4 @@ export { AttachedScope } from '@rollup/pluginutils';

declare function babelParse(code: string, lang?: string, options?: ParserOptions): Program;
declare function babelParse(code: string, lang?: string, options?: ParserOptions): ParseResult<Program>;
declare function babelParseExpression(code: string, lang?: string, options?: ParserOptions): ParseResult<Expression>;

@@ -61,2 +62,2 @@ declare function resolveString(node: string | Identifier | Literal | PrivateName | ThisExpression | Super, computed?: boolean): string;

export { GetNode, ImportBinding, REGEX_DTS, REGEX_LANG_JSX, REGEX_LANG_TS, TS_NODE_TYPES, WithScope, attachScopes, babelParse, escapeKey, getLang, isCallOf, isDts, isFunctionType, isIdentifierOf, isLiteralType, isTs, isTypeOf, resolveIdentifier, resolveLiteral, resolveString, resolveTemplateLiteral, unwrapTSNode, walkAST, walkImportDeclaration };
export { GetNode, ImportBinding, REGEX_DTS, REGEX_LANG_JSX, REGEX_LANG_TS, TS_NODE_TYPES, WithScope, attachScopes, babelParse, babelParseExpression, escapeKey, getLang, isCallOf, isDts, isFunctionType, isIdentifierOf, isLiteralType, isTs, isTypeOf, resolveIdentifier, resolveLiteral, resolveString, resolveTemplateLiteral, unwrapTSNode, walkAST, walkImportDeclaration };

@@ -46,4 +46,7 @@ // src/check.ts

// src/parse.ts
import { parse } from "@babel/parser";
function babelParse(code, lang, options = {}) {
import {
parse,
parseExpression
} from "@babel/parser";
function getParserOptions(lang, options = {}) {
const plugins = [...options.plugins || []];

@@ -59,9 +62,15 @@ if (isTs(lang)) {

}
const { program } = parse(code, {
return {
sourceType: "module",
...options,
plugins
});
return program;
};
}
function babelParse(code, lang, options = {}) {
const { program, errors } = parse(code, getParserOptions(lang, options));
return { ...program, errors };
}
function babelParseExpression(code, lang, options = {}) {
return parseExpression(code, getParserOptions(lang, options));
}

@@ -141,3 +150,3 @@ // src/resolve.ts

// src/utils.ts
import { parseExpression } from "@babel/parser";
import { parseExpression as parseExpression2 } from "@babel/parser";
var TS_NODE_TYPES = [

@@ -166,3 +175,3 @@ "TSAsExpression",

try {
const node = parseExpression(`({${rawKey}: 1})`);
const node = parseExpression2(`({${rawKey}: 1})`);
if (node.properties[0].key.type === "Identifier")

@@ -356,2 +365,3 @@ return rawKey;

babelParse,
babelParseExpression,
escapeKey,

@@ -358,0 +368,0 @@ getLang,

{
"name": "ast-kit",
"version": "0.6.2",
"version": "0.6.3",
"packageManager": "pnpm@8.6.0",

@@ -43,2 +43,3 @@ "description": "AST Toolkit.",

"@vitest/coverage-c8": "^0.31.4",
"@vitest/ui": "^0.32.0",
"bumpp": "^9.1.0",

@@ -45,0 +46,0 @@ "eslint": "^8.41.0",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc