New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

flast

Package Overview
Dependencies
Maintainers
0
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flast - npm Package Compare versions

Comparing version 2.0.3 to 2.1.0

6

package.json
{
"name": "flast",
"version": "2.0.3",
"version": "2.1.0",
"description": "Flatten JS AST",

@@ -30,3 +30,3 @@ "main": "src/index.js",

"escodegen": "npm:@javascript-obfuscator/escodegen",
"eslint-scope": "^8.1.0",
"eslint-scope": "^8.2.0",
"espree": "^10.3.0",

@@ -36,5 +36,5 @@ "estraverse": "^5.3.0"

"devDependencies": {
"eslint": "^9.12.0",
"eslint": "^9.14.0",
"husky": "^9.1.6"
}
}

@@ -44,2 +44,3 @@ # flAST - FLat Abstract Syntax Tree

- Adds a unique id to each node to simplify tracking and understanding relations between nodes.
- Maps the types to the nodes for easier access.
- <u>Arborist</u> - marks nodes for replacement or deletion and applies all changes in a single iteration over the tree.

@@ -46,0 +47,0 @@

@@ -22,3 +22,3 @@ import {parse} from 'espree';

'type', 'start', 'end', 'range', 'sourceType', 'comments', 'srcClosure', 'nodeId',
'childNodes', 'parentNode', 'parentKey', 'scope',
'childNodes', 'parentNode', 'parentKey', 'scope', 'typeMap', 'lineage', 'allScopes',
];

@@ -127,2 +127,3 @@

let nodeId = 0;
const typeMap = {};

@@ -138,2 +139,4 @@ // noinspection JSUnusedGlobalSymbols

node.nodeId = nodeId++;
if (!typeMap[node.type]) typeMap[node.type] = [node];
else typeMap[node.type].push(node);
node.childNodes = [];

@@ -152,2 +155,3 @@ node.parentNode = parentNode;

});
if (tree?.length) tree[0].typeMap = typeMap;
return tree;

@@ -154,0 +158,0 @@ }

@@ -76,2 +76,3 @@ import {Scope} from 'eslint-scope';

* @property {Object[]} [trailingComments]
* @property {Object} [typeMap]
* @property {ASTNode} [update]

@@ -78,0 +79,0 @@ * @property {ASTNode|string|number|boolean} [value]

@@ -58,2 +58,20 @@ import assert from 'node:assert';

});
it(`Verify the type map is generated accurately`, () => {
const code = `class a {
static b = 1;
#c = 2;
}`;
const ast = generateFlatAST(code);
const expected = {
Program: [ast[0]],
ClassDeclaration: [ast[1]],
Identifier: [ast[2], ast[5]],
ClassBody: [ast[3]],
PropertyDefinition: [ast[4], ast[7]],
Literal: [ast[6], ast[9]],
PrivateIdentifier: [ast[8]],
};
const result = ast[0].typeMap;
assert.deepEqual(result, expected);
});
});
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