Socket
Socket
Sign inDemoInstall

ast-kit

Package Overview
Dependencies
3
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.6 to 0.6.7

19

./dist/index.js

@@ -29,3 +29,3 @@ // src/check.ts

// src/lang.ts
import pathe from "pathe";
import { extname } from "pathe";
var REGEX_DTS = /\.d\.[cm]?ts$/;

@@ -37,3 +37,3 @@ var REGEX_LANG_TS = /^[cm]?tsx?$/;

return "dts";
return pathe.extname(filename).replace(/^\./, "");
return extname(filename).replace(/^\./, "");
}

@@ -142,2 +142,16 @@ function isDts(filename) {

}
function resolveObjectKey(node, raw = false) {
const { key, computed } = node;
switch (key.type) {
case "StringLiteral":
case "NumericLiteral":
return raw ? key.extra.raw : key.value;
case "Identifier":
if (!computed)
return raw ? `"${key.name}"` : key.name;
throw "Cannot resolve computed Identifier";
default:
throw new SyntaxError(`Unexpected node type: ${key.type}`);
}
}

@@ -485,2 +499,3 @@ // src/scope.ts

resolveLiteral,
resolveObjectKey,
resolveString,

@@ -487,0 +502,0 @@ resolveTemplateLiteral,

16

dist/index.d.ts

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

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

@@ -26,6 +27,9 @@ import { AttachedScope } from '@rollup/pluginutils';

declare function resolveString(node: string | Identifier | Literal | PrivateName | ThisExpression | Super, computed?: boolean): string;
declare function resolveLiteral(node: Literal): string | number | boolean | null | RegExp | bigint;
declare function resolveTemplateLiteral(node: TemplateLiteral): string;
declare function resolveIdentifier(node: Identifier | PrivateName | MemberExpression | ThisExpression | Super): string[];
declare function resolveString(node: string | t.Identifier | t.Literal | t.PrivateName | t.ThisExpression | t.Super, computed?: boolean): string;
declare function resolveLiteral(node: t.Literal): string | number | boolean | null | RegExp | bigint;
declare function resolveTemplateLiteral(node: t.TemplateLiteral): string;
declare function resolveIdentifier(node: t.Identifier | t.PrivateName | t.MemberExpression | t.ThisExpression | t.Super): string[];
type ObjectPropertyLike = t.ObjectMethod | t.ObjectProperty | t.TSMethodSignature | t.TSPropertySignature;
declare function resolveObjectKey(node: ObjectPropertyLike, raw?: false): string | number;
declare function resolveObjectKey(node: ObjectPropertyLike, raw: true): string;

@@ -67,2 +71,2 @@ declare const attachScopes: <T>(ast: T, propertyName?: string) => AttachedScope;

export { GetNode, ImportBinding, LiteralUnion, 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, walkASTAsync, walkImportDeclaration };
export { GetNode, ImportBinding, LiteralUnion, ObjectPropertyLike, 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, resolveObjectKey, resolveString, resolveTemplateLiteral, unwrapTSNode, walkAST, walkASTAsync, walkImportDeclaration };

@@ -29,3 +29,3 @@ // src/check.ts

// src/lang.ts
import pathe from "pathe";
import { extname } from "pathe";
var REGEX_DTS = /\.d\.[cm]?ts$/;

@@ -37,3 +37,3 @@ var REGEX_LANG_TS = /^[cm]?tsx?$/;

return "dts";
return pathe.extname(filename).replace(/^\./, "");
return extname(filename).replace(/^\./, "");
}

@@ -142,2 +142,16 @@ function isDts(filename) {

}
function resolveObjectKey(node, raw = false) {
const { key, computed } = node;
switch (key.type) {
case "StringLiteral":
case "NumericLiteral":
return raw ? key.extra.raw : key.value;
case "Identifier":
if (!computed)
return raw ? `"${key.name}"` : key.name;
throw "Cannot resolve computed Identifier";
default:
throw new SyntaxError(`Unexpected node type: ${key.type}`);
}
}

@@ -485,2 +499,3 @@ // src/scope.ts

resolveLiteral,
resolveObjectKey,
resolveString,

@@ -487,0 +502,0 @@ resolveTemplateLiteral,

{
"name": "ast-kit",
"version": "0.6.6",
"version": "0.6.7",
"packageManager": "pnpm@8.6.0",

@@ -45,4 +45,4 @@ "description": "AST Toolkit.",

"@sxzz/prettier-config": "^1.0.3",
"@types/node": "^20.4.0",
"@vitest/coverage-c8": "^0.33.0",
"@types/node": "^20.4.1",
"@vitest/coverage-v8": "^0.33.0",
"@vitest/ui": "^0.33.0",

@@ -49,0 +49,0 @@ "bumpp": "^9.1.1",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc