ast-monkey-traverse
Advanced tools
Comparing version 3.0.5 to 3.0.6
/** | ||
* @name ast-monkey-traverse | ||
* @fileoverview Utility library to traverse AST | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
* @author Roy Revelt, Codsen Ltd | ||
@@ -14,72 +14,62 @@ * @license MIT | ||
var version$1 = "3.0.5"; | ||
var version$1 = "3.0.6"; | ||
const version = version$1; | ||
function traverse(tree1, cb1) { | ||
const stop2 = { | ||
now: false | ||
}; | ||
function traverseInner(treeOriginal, callback, originalInnerObj, stop) { | ||
const tree = clone(treeOriginal); | ||
let res; | ||
const innerObj = { | ||
depth: -1, | ||
path: "", | ||
...originalInnerObj | ||
}; | ||
innerObj.depth += 1; | ||
if (Array.isArray(tree)) { | ||
for (let i = 0, len = tree.length; i < len; i++) { | ||
if (stop.now) { | ||
break; | ||
const stop2 = { now: false }; | ||
function traverseInner(treeOriginal, callback, originalInnerObj, stop) { | ||
const tree = clone(treeOriginal); | ||
let res; | ||
const innerObj = { depth: -1, path: "", ...originalInnerObj }; | ||
innerObj.depth += 1; | ||
if (Array.isArray(tree)) { | ||
for (let i = 0, len = tree.length; i < len; i++) { | ||
if (stop.now) { | ||
break; | ||
} | ||
const path = innerObj.path ? `${innerObj.path}.${i}` : `${i}`; | ||
if (tree[i] !== undefined) { | ||
innerObj.parent = clone(tree); | ||
innerObj.parentType = "array"; | ||
innerObj.parentKey = parent(path); | ||
res = traverseInner(callback(tree[i], undefined, { ...innerObj, path }, stop), callback, { ...innerObj, path }, stop); | ||
if (Number.isNaN(res) && i < tree.length) { | ||
tree.splice(i, 1); | ||
i -= 1; | ||
} | ||
else { | ||
tree[i] = res; | ||
} | ||
} | ||
else { | ||
tree.splice(i, 1); | ||
} | ||
} | ||
} | ||
const path = innerObj.path ? `${innerObj.path}.${i}` : `${i}`; | ||
if (tree[i] !== undefined) { | ||
innerObj.parent = clone(tree); | ||
innerObj.parentType = "array"; | ||
innerObj.parentKey = parent(path); | ||
res = traverseInner(callback(tree[i], undefined, { ...innerObj, | ||
path | ||
}, stop), callback, { ...innerObj, | ||
path | ||
}, stop); | ||
if (Number.isNaN(res) && i < tree.length) { | ||
tree.splice(i, 1); | ||
i -= 1; | ||
} else { | ||
tree[i] = res; | ||
} | ||
} else { | ||
tree.splice(i, 1); | ||
else if (isObj(tree)) { | ||
for (const key in tree) { | ||
if (stop.now && key != null) { | ||
break; | ||
} | ||
const path = innerObj.path ? `${innerObj.path}.${key}` : key; | ||
if (innerObj.depth === 0 && key != null) { | ||
innerObj.topmostKey = key; | ||
} | ||
innerObj.parent = clone(tree); | ||
innerObj.parentType = "object"; | ||
innerObj.parentKey = parent(path); | ||
res = traverseInner(callback(key, tree[key], { ...innerObj, path }, stop), callback, { ...innerObj, path }, stop); | ||
if (Number.isNaN(res)) { | ||
delete tree[key]; | ||
} | ||
else { | ||
tree[key] = res; | ||
} | ||
} | ||
} | ||
} | ||
} else if (isObj(tree)) { | ||
for (const key in tree) { | ||
if (stop.now && key != null) { | ||
break; | ||
} | ||
const path = innerObj.path ? `${innerObj.path}.${key}` : key; | ||
if (innerObj.depth === 0 && key != null) { | ||
innerObj.topmostKey = key; | ||
} | ||
innerObj.parent = clone(tree); | ||
innerObj.parentType = "object"; | ||
innerObj.parentKey = parent(path); | ||
res = traverseInner(callback(key, tree[key], { ...innerObj, | ||
path | ||
}, stop), callback, { ...innerObj, | ||
path | ||
}, stop); | ||
if (Number.isNaN(res)) { | ||
delete tree[key]; | ||
} else { | ||
tree[key] = res; | ||
} | ||
} | ||
return tree; | ||
} | ||
return tree; | ||
} | ||
return traverseInner(tree1, cb1, {}, stop2); | ||
return traverseInner(tree1, cb1, {}, stop2); | ||
} | ||
export { traverse, version }; |
/** | ||
* @name ast-monkey-traverse | ||
* @fileoverview Utility library to traverse AST | ||
* @version 3.0.5 | ||
* @version 3.0.6 | ||
* @author Roy Revelt, Codsen Ltd | ||
@@ -14,6 +14,6 @@ * @license MIT | ||
* @fileoverview Utility library of AST helper functions | ||
* @version 2.0.5 | ||
* @version 2.0.6 | ||
* @author Roy Revelt, Codsen Ltd | ||
* @license MIT | ||
* {@link https://codsen.com/os/ast-monkey-util/} | ||
*/function y(t){if(t.includes(".")){const e=t.lastIndexOf(".");if(!t.slice(0,e).includes("."))return t.slice(0,e);for(let r=e-1;r--;)if("."===t[r])return t.slice(r+1,e)}return null}t.traverse=function(t,e){return function t(e,r,o,c){const u=n(e);let a;const i={depth:-1,path:"",...o};if(i.depth+=1,Array.isArray(u))for(let e=0,o=u.length;e<o&&!c.now;e++){const o=i.path?`${i.path}.${e}`:`${e}`;void 0!==u[e]?(i.parent=n(u),i.parentType="array",i.parentKey=y(o),a=t(r(u[e],void 0,{...i,path:o},c),r,{...i,path:o},c),Number.isNaN(a)&&e<u.length?(u.splice(e,1),e-=1):u[e]=a):u.splice(e,1)}else if(p(u))for(const e in u){if(c.now&&null!=e)break;const o=i.path?`${i.path}.${e}`:e;0===i.depth&&null!=e&&(i.topmostKey=e),i.parent=n(u),i.parentType="object",i.parentKey=y(o),a=t(r(e,u[e],{...i,path:o},c),r,{...i,path:o},c),Number.isNaN(a)?delete u[e]:u[e]=a}return u}(t,e,{},{now:!1})},t.version="3.0.5",Object.defineProperty(t,"__esModule",{value:!0})})); | ||
*/function y(t){if(t.includes(".")){const e=t.lastIndexOf(".");if(!t.slice(0,e).includes("."))return t.slice(0,e);for(let r=e-1;r--;)if("."===t[r])return t.slice(r+1,e)}return null}t.traverse=function(t,e){return function t(e,r,o,c){const u=n(e);let a;const i={depth:-1,path:"",...o};if(i.depth+=1,Array.isArray(u))for(let e=0,o=u.length;e<o&&!c.now;e++){const o=i.path?`${i.path}.${e}`:`${e}`;void 0!==u[e]?(i.parent=n(u),i.parentType="array",i.parentKey=y(o),a=t(r(u[e],void 0,{...i,path:o},c),r,{...i,path:o},c),Number.isNaN(a)&&e<u.length?(u.splice(e,1),e-=1):u[e]=a):u.splice(e,1)}else if(p(u))for(const e in u){if(c.now&&null!=e)break;const o=i.path?`${i.path}.${e}`:e;0===i.depth&&null!=e&&(i.topmostKey=e),i.parent=n(u),i.parentType="object",i.parentKey=y(o),a=t(r(e,u[e],{...i,path:o},c),r,{...i,path:o},c),Number.isNaN(a)?delete u[e]:u[e]=a}return u}(t,e,{},{now:!1})},t.version="3.0.6",Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "ast-monkey-traverse", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"description": "Utility library to traverse AST", | ||
@@ -48,9 +48,8 @@ "keywords": [ | ||
"build": "rollup -c", | ||
"ci_test": "npm run build && npm run format && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov", | ||
"clean_cov": "../../scripts/leaveCoverageTotalOnly.js", | ||
"build:esbuild": "node '../../scripts/esbuild.js'", | ||
"build:esbuild:dev": "cross-env MODE=dev node '../../scripts/esbuild.js'", | ||
"ci_test": "npm run build && npm run format && tap --no-only --reporter=silent", | ||
"clean_types": "../../scripts/cleanTypes.js", | ||
"dev": "rollup -c --dev", | ||
"devunittest": "npm run dev && tap --only -R 'base'", | ||
"esbuild": "node '../../scripts/esbuild.js'", | ||
"esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'", | ||
"format": "npm run lect && npm run prettier && npm run lint", | ||
@@ -64,13 +63,10 @@ "lect": "lect", | ||
"pretest": "npm run build", | ||
"test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format", | ||
"test": "npm run test:ci && npm run perf", | ||
"test:ci": "npm run unittest && npm run test:examples && npm run format", | ||
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier", | ||
"tsc": "tsc", | ||
"unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf" | ||
"unittest": "tap --no-only --reporter=terse && tsc -p tsconfig.json --noEmit" | ||
}, | ||
"tap": { | ||
"check-coverage": false, | ||
"coverage-report": [ | ||
"json-summary", | ||
"text" | ||
], | ||
"node-arg": [ | ||
@@ -99,4 +95,4 @@ "--no-warnings", | ||
"dependencies": { | ||
"@babel/runtime": "^7.16.0", | ||
"ast-monkey-util": "^2.0.5", | ||
"@babel/runtime": "^7.16.3", | ||
"ast-monkey-util": "^2.0.6", | ||
"lodash.clonedeep": "^4.5.0", | ||
@@ -114,4 +110,4 @@ "lodash.isplainobject": "^4.0.6" | ||
"@babel/plugin-proposal-optional-chaining": "^7.16.0", | ||
"@babel/plugin-transform-runtime": "^7.16.0", | ||
"@babel/preset-env": "^7.16.0", | ||
"@babel/plugin-transform-runtime": "^7.16.4", | ||
"@babel/preset-env": "^7.16.4", | ||
"@babel/preset-typescript": "^7.16.0", | ||
@@ -128,13 +124,13 @@ "@babel/register": "^7.16.0", | ||
"@types/lodash.isplainobject": "^4.0.6", | ||
"@types/node": "^16.11.6", | ||
"@types/node": "^16.11.9", | ||
"@types/tap": "^15.0.5", | ||
"@typescript-eslint/eslint-plugin": "^5.3.0", | ||
"@typescript-eslint/parser": "^5.3.0", | ||
"@typescript-eslint/eslint-plugin": "^5.4.0", | ||
"@typescript-eslint/parser": "^5.4.0", | ||
"core-js": "^3.19.1", | ||
"cross-env": "^7.0.3", | ||
"eslint": "^8.2.0", | ||
"lect": "^0.18.5", | ||
"eslint": "^8.3.0", | ||
"lect": "^0.18.6", | ||
"lodash.isequal": "^4.5.0", | ||
"object-path": "^0.11.8", | ||
"rollup": "^2.59.0", | ||
"rollup": "^2.60.0", | ||
"rollup-plugin-ascii": "^0.0.3", | ||
@@ -145,9 +141,9 @@ "rollup-plugin-banner": "^0.2.1", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"tap": "^15.0.10", | ||
"tap": "^15.1.2", | ||
"tslib": "^2.3.1", | ||
"typescript": "^4.4.4" | ||
"typescript": "^4.5.2" | ||
}, | ||
"engines": { | ||
"node": ">=12" | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30913
224
Updated@babel/runtime@^7.16.3
Updatedast-monkey-util@^2.0.6