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.12.1 to 0.12.2

16

dist/index.d.ts

@@ -98,2 +98,10 @@ import * as t from '@babel/types';

/**
* Extract identifiers of the given node.
* @param node The node to extract.
* @param identifiers The array to store the extracted identifiers.
* @see https://github.com/vuejs/core/blob/1f6a1102aa09960f76a9af2872ef01e7da8538e3/packages/compiler-core/src/babelUtils.ts#L208
*/
declare function extractIdentifiers(node: t.Node, identifiers?: t.Identifier[]): t.Identifier[];
declare const REGEX_DTS: RegExp;

@@ -226,2 +234,5 @@ declare const REGEX_LANG_TS: RegExp;

/**
* A type that represents a literal union.
*/
type LiteralUnion<LiteralType, BaseType extends null | undefined | string | number | boolean | symbol | bigint = string> = LiteralType | (BaseType & Record<never, never>);

@@ -301,2 +312,5 @@

declare function walkImportDeclaration(imports: Record<string, ImportBinding>, node: t.ImportDeclaration): void;
/**
* Represents an export binding.
*/
interface ExportBinding {

@@ -317,2 +331,2 @@ local: string;

export { type AttachedScope, type ExportBinding, type GetNode, type ImportBinding, type LiteralUnion, type NodeType, type ObjectPropertyLike, type ParseResult, REGEX_DTS, REGEX_LANG_JSX, REGEX_LANG_TS, TS_NODE_TYPES, type WithScope, attachScopes, babelParse, babelParseExpression, createStringLiteral, createTSLiteralType, createTSUnionType, escapeKey, getLang, isCallOf, isDts, isExpressionType, isFunctionType, isIdentifierOf, isLiteralType, isReferenced, isTs, isTypeOf, locateTrailingComma, resolveIdentifier, resolveLiteral, resolveObjectKey, resolveString, resolveTemplateLiteral, unwrapTSNode, walkAST, walkASTAsync, walkASTSetup, walkExportDeclaration, walkImportDeclaration };
export { type AttachedScope, type ExportBinding, type GetNode, type ImportBinding, type LiteralUnion, type NodeType, type ObjectPropertyLike, type ParseResult, REGEX_DTS, REGEX_LANG_JSX, REGEX_LANG_TS, TS_NODE_TYPES, type WithScope, attachScopes, babelParse, babelParseExpression, createStringLiteral, createTSLiteralType, createTSUnionType, escapeKey, extractIdentifiers, getLang, isCallOf, isDts, isExpressionType, isFunctionType, isIdentifierOf, isLiteralType, isReferenced, isTs, isTypeOf, locateTrailingComma, resolveIdentifier, resolveLiteral, resolveObjectKey, resolveString, resolveTemplateLiteral, unwrapTSNode, walkAST, walkASTAsync, walkASTSetup, walkExportDeclaration, walkImportDeclaration };

@@ -156,2 +156,40 @@ // src/check.ts

// src/extract.ts
function extractIdentifiers(node, identifiers = []) {
switch (node.type) {
case "Identifier":
identifiers.push(node);
break;
case "MemberExpression": {
let object = node;
while (object.type === "MemberExpression") {
object = object.object;
}
identifiers.push(object);
break;
}
case "ObjectPattern":
for (const prop of node.properties) {
if (prop.type === "RestElement") {
extractIdentifiers(prop.argument, identifiers);
} else {
extractIdentifiers(prop.value, identifiers);
}
}
break;
case "ArrayPattern":
node.elements.forEach((element) => {
element && extractIdentifiers(element, identifiers);
});
break;
case "RestElement":
extractIdentifiers(node.argument, identifiers);
break;
case "AssignmentPattern":
extractIdentifiers(node.left, identifiers);
break;
}
return identifiers;
}
// src/lang.ts

@@ -897,2 +935,3 @@ import { extname } from "pathe";

escapeKey,
extractIdentifiers,
getLang,

@@ -899,0 +938,0 @@ isCallOf,

31

package.json
{
"name": "ast-kit",
"version": "0.12.1",
"packageManager": "pnpm@8.15.4",
"description": "A toolkit for easy AST generation and manipulation.",
"version": "0.12.2",
"description": "A toolkit for easy Babel AST generation and manipulation.",
"type": "module",

@@ -33,14 +32,14 @@ "license": "MIT",

"dependencies": {
"@babel/parser": "^7.23.9",
"@babel/parser": "^7.24.6",
"pathe": "^1.1.2"
},
"devDependencies": {
"@babel/types": "^7.23.9",
"@sxzz/eslint-config": "^3.8.0",
"@sxzz/prettier-config": "^2.0.0",
"@types/node": "^20.11.20",
"@vitest/coverage-v8": "^1.3.1",
"@vitest/ui": "^1.3.1",
"bumpp": "^9.3.0",
"eslint": "^8.57.0",
"@babel/types": "^7.24.6",
"@sxzz/eslint-config": "^3.11.0",
"@sxzz/prettier-config": "^2.0.2",
"@types/node": "^20.13.0",
"@vitest/coverage-v8": "^1.6.0",
"@vitest/ui": "^1.6.0",
"bumpp": "^9.4.1",
"eslint": "^9.3.0",
"estree-walker": "^3.0.3",

@@ -50,5 +49,5 @@ "fast-glob": "^3.3.2",

"tsup": "^8.0.2",
"tsx": "^4.7.1",
"typescript": "^5.3.3",
"vitest": "^1.3.1"
"tsx": "^4.11.0",
"typescript": "5.5.0-beta",
"vitest": "^1.6.0"
},

@@ -64,5 +63,5 @@ "engines": {

"test": "vitest",
"release": "bumpp package.json jsr.json && pnpm publish",
"release": "bumpp && pnpm publish",
"typecheck": "tsc --noEmit"
}
}

@@ -1,4 +0,4 @@

# ast-kit [![npm](https://img.shields.io/npm/v/ast-kit.svg)](https://npmjs.com/package/ast-kit) [![jsr](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fjsr-api.sxzz.moe%2Fversion%2F%40sxzz%2Fast-kit&query=version&prefix=v&label=jsr&color=%23faee4a)](https://jsr.io/@sxzz/ast-kit) [![Unit Test](https://github.com/sxzz/ast-kit/actions/workflows/unit-test.yml/badge.svg)](https://github.com/sxzz/ast-kit/actions/workflows/unit-test.yml) [![codecov](https://codecov.io/gh/sxzz/ast-kit/graph/badge.svg?token=MHTCPNMZAK)](https://codecov.io/gh/sxzz/ast-kit)
# ast-kit [![npm](https://img.shields.io/npm/v/ast-kit.svg)](https://npmjs.com/package/ast-kit) [![JSR](https://jsr.io/badges/@sxzz/ast-kit)](https://jsr.io/@sxzz/ast-kit) [![Unit Test](https://github.com/sxzz/ast-kit/actions/workflows/unit-test.yml/badge.svg)](https://github.com/sxzz/ast-kit/actions/workflows/unit-test.yml) [![codecov](https://codecov.io/gh/sxzz/ast-kit/graph/badge.svg?token=MHTCPNMZAK)](https://codecov.io/gh/sxzz/ast-kit)
A toolkit for easy AST generation and manipulation.
A toolkit for easy Babel AST generation and manipulation.

@@ -5,0 +5,0 @@ [API Reference](https://paka.dev/npm/ast-kit/api)

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc