yuku-ast 0.8.6 → 0.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.d.ts +16 -2
- package/dist/index.js +10 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -106,6 +106,7 @@ import {
|
|
|
106
106
|
nameOf, // Identifier name or string Literal value
|
|
107
107
|
literalValue, // string | number | boolean | bigint | RegExp | null
|
|
108
108
|
unwrap, // strips parens and erased TS assertion wrappers
|
|
109
|
+
isWrapper, // true for the wrappers unwrap strips
|
|
109
110
|
isCallOf, // isCallOf(node, "require")
|
|
110
111
|
bindingIdentifiers, // every binding Identifier a pattern introduces
|
|
111
112
|
findAll, // findAll(program, "CallExpression")
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _yuku_toolchain_types0 from "@yuku-toolchain/types";
|
|
2
|
-
import { BigIntLiteral, BindingPattern, BooleanLiteral, CallExpression, ComputedMemberExpression, Directive, ExportAllDeclaration, ExportDefaultDeclaration, ExportNamedDeclaration, ExportSpecifier, Expression, Identifier, ImportDeclaration, ImportDeclarationSpecifier, ImportPhase, Node, NodeOfType, NodeType, NullLiteral, NumericLiteral, PrivateFieldExpression, Program, RegExpLiteral, StaticMemberExpression, StringLiteral } from "@yuku-toolchain/types";
|
|
2
|
+
import { BigIntLiteral, BindingPattern, BooleanLiteral, CallExpression, ComputedMemberExpression, Directive, ExportAllDeclaration, ExportDefaultDeclaration, ExportNamedDeclaration, ExportSpecifier, Expression, Identifier, ImportDeclaration, ImportDeclarationSpecifier, ImportPhase, Node, NodeOfType, NodeType, NullLiteral, NumericLiteral, ParenthesizedExpression, PrivateFieldExpression, Program, RegExpLiteral, StaticMemberExpression, StringLiteral, TSAsExpression, TSNonNullExpression, TSSatisfiesExpression, TSTypeAssertion } from "@yuku-toolchain/types";
|
|
3
3
|
|
|
4
4
|
//#region src/aliases.d.ts
|
|
5
5
|
declare const ALIAS_GROUPS: {
|
|
@@ -418,6 +418,20 @@ declare function nameOf(node: MaybeNode): string | null;
|
|
|
418
418
|
* non-literal nodes.
|
|
419
419
|
*/
|
|
420
420
|
declare function literalValue(node: MaybeNode): string | number | boolean | bigint | RegExp | null | undefined;
|
|
421
|
+
/**
|
|
422
|
+
* An expression that only wraps another one: parentheses and the
|
|
423
|
+
* TypeScript assertion forms erased on the way to JavaScript.
|
|
424
|
+
*/
|
|
425
|
+
type Wrapper = ParenthesizedExpression | TSAsExpression | TSSatisfiesExpression | TSNonNullExpression | TSTypeAssertion;
|
|
426
|
+
/**
|
|
427
|
+
* True when `node` is a {@link Wrapper}, the expressions {@link unwrap}
|
|
428
|
+
* strips to reach the one that carries the meaning. Its `expression` is
|
|
429
|
+
* the node underneath.
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* isWrapper(node) ? node.expression : node
|
|
433
|
+
*/
|
|
434
|
+
declare function isWrapper(node: MaybeNode): node is Wrapper;
|
|
421
435
|
/**
|
|
422
436
|
* The expression inside parentheses and erased TypeScript assertion
|
|
423
437
|
* wrappers: `((x as any))!` unwraps to `x`. Returns the node itself
|
|
@@ -490,4 +504,4 @@ type AsyncVisitors<S = unknown> = { [K in NodeType]?: AsyncWalkHandler<NodeOfTyp
|
|
|
490
504
|
declare function _walk(root: Node, visitors: Visitors<never> | AsyncVisitors<never>, state: unknown, ctx: WalkContext): void;
|
|
491
505
|
declare function _walkAsync(root: Node, visitors: AsyncVisitors<never>, state: unknown, ctx: WalkContext): Promise<void>;
|
|
492
506
|
//#endregion
|
|
493
|
-
export { ALIAS_GROUPS, ALIAS_NAMES, type AliasMap, type AliasName, type AsyncVisitors, type AsyncWalkHandler, type AsyncWalkHooks, CHILD_KEYS, type CollectedExport, type CollectedImport, NODE_TYPES, type Visitors, WalkContext, type WalkHandler, type WalkHooks, _walk, _walkAsync, b, bindingIdentifiers, collectExportDeclaration, collectExports, collectImportDeclaration, collectImports, findAll, is, isCallOf, isIdentifierChar, isIdentifierName, isIdentifierStart, isKeyword, isReservedWord, isStrictBindOnlyReservedWord, isStrictBindReservedWord, isStrictReservedWord, isValidIdentifier, literalValue, nameOf, unwrap, walk, walkAsync };
|
|
507
|
+
export { ALIAS_GROUPS, ALIAS_NAMES, type AliasMap, type AliasName, type AsyncVisitors, type AsyncWalkHandler, type AsyncWalkHooks, CHILD_KEYS, type CollectedExport, type CollectedImport, NODE_TYPES, type Visitors, WalkContext, type WalkHandler, type WalkHooks, type Wrapper, _walk, _walkAsync, b, bindingIdentifiers, collectExportDeclaration, collectExports, collectImportDeclaration, collectImports, findAll, is, isCallOf, isIdentifierChar, isIdentifierName, isIdentifierStart, isKeyword, isReservedWord, isStrictBindOnlyReservedWord, isStrictBindReservedWord, isStrictReservedWord, isValidIdentifier, isWrapper, literalValue, nameOf, unwrap, walk, walkAsync };
|
package/dist/index.js
CHANGED
|
@@ -1229,8 +1229,16 @@ const WRAPPERS = new Set([
|
|
|
1229
1229
|
"TSNonNullExpression",
|
|
1230
1230
|
"TSTypeAssertion"
|
|
1231
1231
|
]);
|
|
1232
|
+
/**
|
|
1233
|
+
* True when `node` is a {@link Wrapper}, the expressions {@link unwrap}
|
|
1234
|
+
* strips to reach the one that carries the meaning. Its `expression` is
|
|
1235
|
+
* the node underneath.
|
|
1236
|
+
*
|
|
1237
|
+
* @example
|
|
1238
|
+
* isWrapper(node) ? node.expression : node
|
|
1239
|
+
*/
|
|
1232
1240
|
function isWrapper(node) {
|
|
1233
|
-
return WRAPPERS.has(node.type);
|
|
1241
|
+
return node != null && WRAPPERS.has(node.type);
|
|
1234
1242
|
}
|
|
1235
1243
|
/**
|
|
1236
1244
|
* The expression inside parentheses and erased TypeScript assertion
|
|
@@ -1390,4 +1398,4 @@ function declaredNames(declaration) {
|
|
|
1390
1398
|
}
|
|
1391
1399
|
|
|
1392
1400
|
//#endregion
|
|
1393
|
-
export { ALIAS_GROUPS, ALIAS_NAMES, CHILD_KEYS, NODE_TYPES, WalkContext, _walk, _walkAsync, b, bindingIdentifiers, collectExportDeclaration, collectExports, collectImportDeclaration, collectImports, findAll, is, isCallOf, isIdentifierChar, isIdentifierName, isIdentifierStart, isKeyword, isReservedWord, isStrictBindOnlyReservedWord, isStrictBindReservedWord, isStrictReservedWord, isValidIdentifier, literalValue, nameOf, unwrap, walk, walkAsync };
|
|
1401
|
+
export { ALIAS_GROUPS, ALIAS_NAMES, CHILD_KEYS, NODE_TYPES, WalkContext, _walk, _walkAsync, b, bindingIdentifiers, collectExportDeclaration, collectExports, collectImportDeclaration, collectImports, findAll, is, isCallOf, isIdentifierChar, isIdentifierName, isIdentifierStart, isKeyword, isReservedWord, isStrictBindOnlyReservedWord, isStrictBindReservedWord, isStrictReservedWord, isValidIdentifier, isWrapper, literalValue, nameOf, unwrap, walk, walkAsync };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yuku-ast",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.7",
|
|
4
4
|
"description": "Typed AST toolkit for JavaScript and TypeScript ESTree trees: walker, builders, guards, and syntactic utilities",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"build": "tsdown"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@yuku-toolchain/types": "^0.8.
|
|
24
|
+
"@yuku-toolchain/types": "^0.8.7"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"tsdown": "^0.15.6"
|