Comparing version 1.1.0 to 1.1.1
{ | ||
"name": "flast", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Flatten JS AST", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -191,2 +191,4 @@ # flAST - FLat Abstract Syntax Tree | ||
## Changes | ||
### v1.1.1 | ||
- Improve getParentKey to include parsing the name of grouped nodes such as 'arguments' or 'body'. | ||
### v1.1.0 | ||
@@ -193,0 +195,0 @@ - Added parentKey property. |
@@ -43,2 +43,7 @@ // noinspection JSUnusedGlobalSymbols | ||
if (parent[key]?.nodeId === targetChildNodeId) return key; | ||
else if (Array.isArray(parent[key])) { | ||
for (const item of parent[key]) { | ||
if (item.nodeId === targetChildNodeId) return key; | ||
} | ||
} | ||
} | ||
@@ -45,0 +50,0 @@ } |
@@ -67,3 +67,3 @@ const assert = require('assert'); | ||
{nodeId: 0, type: 'Program', start: 0, end: 3, src: 'a=3', parentNode: null, parentKey: null}, | ||
{nodeId: 1, type: 'ExpressionStatement', start: 0, end: 3, src: 'a=3', parentKey: null}, | ||
{nodeId: 1, type: 'ExpressionStatement', start: 0, end: 3, src: 'a=3', parentKey: 'body'}, | ||
{nodeId: 2, type: 'AssignmentExpression', start: 0, end: 3, src: 'a=3', operator: '=', parentKey: 'expression'}, | ||
@@ -70,0 +70,0 @@ {nodeId: 3, type: 'Identifier', start: 0, end: 1, src: 'a', parentKey: 'left'}, |
30775
446
196