ast-monkey-traverse 4.1.3 → 4.2.0
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/CHANGELOG.md +14 -2
- package/LICENSE +1 -1
- package/README.md +3 -2
- package/dist/ast-monkey-traverse.esm.js +2 -2
- package/dist/ast-monkey-traverse.umd.js +3 -11
- package/package.json +25 -25
- package/types/index.d.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,11 +3,23 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## 4.
|
|
6
|
+
## 4.2.0 (2026-08-19)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- preserve traversal inputs and validate callbacks ([661d6cb](https://github.com/codsen/codsen/commit/661d6cbb644ce0d58a697a3e04753a2175494094))
|
|
11
|
+
- resolve review findings REV-004 through REV-007 ([b60e9ee](https://github.com/codsen/codsen/commit/b60e9eeb499af94685cfb87b4970fe025be1fc10))
|
|
12
|
+
- retire direct publish aliases ([f98e31e](https://github.com/codsen/codsen/commit/f98e31eb89bc185471225664e610b55f34fbf648))
|
|
7
13
|
|
|
8
14
|
### Features
|
|
9
15
|
|
|
10
|
-
-
|
|
16
|
+
- add codsen-glob and migrate glob consumers ([5595a2b](https://github.com/codsen/codsen/commit/5595a2b267eaa6cb60072d037aef00b7a28edd42))
|
|
17
|
+
- refresh the tooling and generate with the latest dependencies ([781f802](https://github.com/codsen/codsen/commit/781f802911066a82a4533b0e5a3fcbd742d0dd83))
|
|
18
|
+
|
|
19
|
+
### Reverts
|
|
20
|
+
|
|
21
|
+
- Revert "Merge pull request #128 from codsen/release/npm-32198404552-1" ([5baeeaa](https://github.com/codsen/codsen/commit/5baeeaaa677b86f1eaa6396cadf3aea32b06416e)), closes [#128](https://github.com/codsen/codsen/issues/128)
|
|
22
|
+
- Revert "Merge pull request #127 from codsen/release/npm-32194020886-1" ([5f1e94d](https://github.com/codsen/codsen/commit/5f1e94deef910ce735266b16aeee08a76de7a862)), closes [#127](https://github.com/codsen/codsen/issues/127)
|
|
11
23
|
|
|
12
24
|
## 4.0.0 (2022-12-01)
|
|
13
25
|
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright © 2010-
|
|
3
|
+
Copyright © 2010-2026 Roy Revelt and other contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ npm i ast-monkey-traverse
|
|
|
32
32
|
## Quick Take
|
|
33
33
|
|
|
34
34
|
```js
|
|
35
|
-
import { strict as assert } from "assert";
|
|
35
|
+
import { strict as assert } from "node:assert";
|
|
36
36
|
|
|
37
37
|
import { traverse } from "ast-monkey-traverse";
|
|
38
38
|
|
|
@@ -74,6 +74,7 @@ traverse(source, (key, val, innerObj) => {
|
|
|
74
74
|
assert.deepEqual(paths, ["a.foo", "a.foo.bar.0.foo", "a.foo.d.e.foo"]);
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
+
|
|
77
78
|
## Documentation
|
|
78
79
|
|
|
79
80
|
Please [visit codsen.com](https://codsen.com/os/ast-monkey-traverse/) for a full description of the API. If you’re looking for the **Changelog**, it’s [here](https://github.com/codsen/codsen/blob/main/packages/ast-monkey-traverse/CHANGELOG.md).
|
|
@@ -86,6 +87,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
86
87
|
|
|
87
88
|
MIT License
|
|
88
89
|
|
|
89
|
-
Copyright © 2010-
|
|
90
|
+
Copyright © 2010-2026 Roy Revelt and other contributors
|
|
90
91
|
|
|
91
92
|
<p align="center"><img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center"></p>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name ast-monkey-traverse
|
|
3
3
|
* @fileoverview Utility library to traverse AST
|
|
4
|
-
* @version 4.
|
|
4
|
+
* @version 4.2.0
|
|
5
5
|
* @author Roy Revelt
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/ast-monkey-traverse/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import
|
|
10
|
+
import{deepClone as i,isPlainObject as g}from"codsen-utils";var b="4.2.0";var O=b;function E(d,c){if(typeof c!="function")throw new TypeError(`ast-monkey-traverse/traverse(): [THROW_ID_01] The second argument must be a callback function. It was ${typeof c}.`);let y={now:!1};function u($,a,h,r){let n=$,s,e={depth:-1,path:"",...h};if(e.depth+=1,Array.isArray(n))for(let t=0,p=n.length;t<p&&!r.now;t++){let l=e.path?`${e.path}.${t}`:`${t}`;if(n[t]!==void 0){e.parent=i(n),e.parentType="array",e.parentKey=e.path?e.path.slice(e.path.lastIndexOf(".")+1):null;let o=n[t],m=a(o,void 0,{...e,path:l},r);s=u(m===o?m:i(m),a,{...e,path:l},r),Number.isNaN(s)&&t<n.length?(n.splice(t,1),t-=1):n[t]=s}else n.splice(t,1)}else if(g(n))for(let t in n){if(r.now&&t!=null)break;let p=e.path?`${e.path}.${t}`:t;e.depth===0&&t!=null&&(e.topmostKey=t),e.parent=i(n),e.parentType="object",e.parentKey=e.path?e.path.slice(e.path.lastIndexOf(".")+1):null;let l=n[t],o=a(t,l,{...e,path:p},r);s=u(o===l?o:i(o),a,{...e,path:p},r),Number.isNaN(s)?delete n[t]:n[t]=s}return n}return u(i(d),c,{},y)}export{E as traverse,O as version};
|
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name ast-monkey-traverse
|
|
3
3
|
* @fileoverview Utility library to traverse AST
|
|
4
|
-
* @version 4.
|
|
4
|
+
* @version 4.2.0
|
|
5
5
|
* @author Roy Revelt
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/ast-monkey-traverse/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
"use strict";var astMonkeyTraverse=(()=>{var
|
|
10
|
+
"use strict";var astMonkeyTraverse=(()=>{var $=Object.defineProperty,D=Object.defineProperties,E=Object.getOwnPropertyDescriptor,I=Object.getOwnPropertyDescriptors,W=Object.getOwnPropertyNames,k=Object.getOwnPropertySymbols;var S=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var w=(e,t,r)=>t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,h=(e,t)=>{for(var r in t||(t={}))S.call(t,r)&&w(e,r,t[r]);if(k)for(var r of k(t))R.call(t,r)&&w(e,r,t[r]);return e},y=(e,t)=>D(e,I(t));var T=(e,t)=>{for(var r in t)$(e,r,{get:t[r],enumerable:!0})},M=(e,t,r,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of W(t))!S.call(e,o)&&o!==r&&$(e,o,{get:()=>t[o],enumerable:!(u=E(t,o))||u.enumerable});return e};var N=e=>M($({},"__esModule",{value:!0}),e);var b=(e,t,r)=>w(e,typeof t!="symbol"?t+"":t,r);var F={};T(F,{traverse:()=>P,version:()=>U});var J=new Set([..."\u060B$\u20BC\u17DB\xA5\u20A1\u20B1\xA3\u20AC\xA2\u20B9\uFDFC\u20AA\u20A9\u20AD\u20A8\u20AE\u20A6\u20BD\u20AB\u0E3F\u20A9\u20BA\u20B4","$U","$b","B/.","BZ$","Br","Bs","C$","CHF","Ft","Gs","J$","KM","K\u010D","L","MT","NT$","P","Q","R","R$","RD$","RM","Rp","S","S/.","TT$","Z$","kn","kr","lei","z\u0142","\u0192","\u0414\u0438\u043D.","\u0434\u0435\u043D","\u043B\u0432","\u062F.\u0625","Lek"]);var B=class{constructor(){b(this,"hasRepeatedReferences",!1);b(this,"clones",[]);b(this,"index");b(this,"sources",[])}get(e){if(this.index){let r=this.index.get(e);return r!==void 0&&(this.hasRepeatedReferences=!0),r}let t=this.sources.indexOf(e);if(t!==-1)return this.hasRepeatedReferences=!0,this.clones[t]}set(e,t){if(this.index){this.index.set(e,t);return}if(this.sources.push(e),this.clones.push(t),this.sources.length===32){this.index=new WeakMap;for(let r=0;r<this.sources.length;r++)this.index.set(this.sources[r],this.clones[r]);this.sources=[],this.clones=[]}}};function j(e,t){let r=t.get(e);if(r!==void 0)return r;let u=e.slice(0);return t.set(e,u),u}function V(e,t){if(typeof Buffer<"u"&&Buffer.isBuffer(e)){let n=Buffer.from(e);return t.set(e,n),n}let r=j(e.buffer,t);if(e instanceof DataView){let n=new DataView(r,e.byteOffset,e.byteLength);return t.set(e,n),n}let u=e.constructor,o=new u(r,e.byteOffset,e.length);return t.set(e,o),o}function O(e,t,r,u){for(let o of r){let n=t[o];e[o]=typeof n!="object"||n===null?n:d(n,u)}}function d(e,t){if(typeof e!="object"||e===null)return e;let r=t.get(e);if(r!==void 0)return r;if(Array.isArray(e)){let n=e.length,p=new Array(n);t.set(e,p);let a=e,s=Object.keys(e);if(s.length===n&&(n===0||s[n-1]==="".concat(n-1)))for(let f=0;f<n;f++){let i=a[f];p[f]=typeof i!="object"||i===null?i:d(i,t)}else O(p,a,s,t);return p}let u=Object.getPrototypeOf(e);if(u===Object.prototype||u===null){let n={};return t.set(e,n),O(n,e,Object.keys(e),t),n}if(e instanceof Date){let n=new Date(e.getTime());return t.set(e,n),n}if(ArrayBuffer.isView(e))return V(e,t);if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return j(e,t);if(e instanceof Map){let n=new Map;t.set(e,n);for(let[p,a]of e)n.set(d(p,t),d(a,t));return n}if(e instanceof Set){let n=new Set;t.set(e,n);for(let p of e)n.add(d(p,t));return n}let o={};return t.set(e,o),O(o,e,Object.keys(e),t),o}function g(e){return d(e,new B)}function x(e){if(e==null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}var C="4.2.0";var U=C;function P(e,t){if(typeof t!="function")throw new TypeError("ast-monkey-traverse/traverse(): [THROW_ID_01] The second argument must be a callback function. It was ".concat(typeof t,"."));let r={now:!1};function u(o,n,p,a){let s=o,f,i=h({depth:-1,path:""},p);if(i.depth+=1,Array.isArray(s))for(let l=0,v=s.length;l<v&&!a.now;l++){let m=i.path?"".concat(i.path,".").concat(l):"".concat(l);if(s[l]!==void 0){i.parent=g(s),i.parentType="array",i.parentKey=i.path?i.path.slice(i.path.lastIndexOf(".")+1):null;let c=s[l],A=n(c,void 0,y(h({},i),{path:m}),a);f=u(A===c?A:g(A),n,y(h({},i),{path:m}),a),Number.isNaN(f)&&l<s.length?(s.splice(l,1),l-=1):s[l]=f}else s.splice(l,1)}else if(x(s))for(let l in s){if(a.now&&l!=null)break;let v=i.path?"".concat(i.path,".").concat(l):l;i.depth===0&&l!=null&&(i.topmostKey=l),i.parent=g(s),i.parentType="object",i.parentKey=i.path?i.path.slice(i.path.lastIndexOf(".")+1):null;let m=s[l],c=n(l,m,y(h({},i),{path:v}),a);f=u(c===m?c:g(c),n,y(h({},i),{path:v}),a),Number.isNaN(f)?delete s[l]:s[l]=f}return s}return u(g(e),t,{},r)}return N(F);})();
|
|
11
11
|
/**
|
|
12
12
|
* @name codsen-utils
|
|
13
13
|
* @fileoverview Various utility functions
|
|
14
|
-
* @version 1.
|
|
14
|
+
* @version 1.8.0
|
|
15
15
|
* @author Roy Revelt
|
|
16
16
|
* @license MIT
|
|
17
17
|
* {@link https://codsen.com/os/codsen-utils/}
|
|
18
18
|
*/
|
|
19
|
-
/**
|
|
20
|
-
* @name ast-monkey-util
|
|
21
|
-
* @fileoverview Utility library of AST helper functions
|
|
22
|
-
* @version 3.1.3
|
|
23
|
-
* @author Roy Revelt
|
|
24
|
-
* @license MIT
|
|
25
|
-
* {@link https://codsen.com/os/ast-monkey-util/}
|
|
26
|
-
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ast-monkey-traverse",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Utility library to traverse AST",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ast",
|
|
@@ -45,49 +45,49 @@
|
|
|
45
45
|
},
|
|
46
46
|
"types": "types/index.d.ts",
|
|
47
47
|
"scripts": {
|
|
48
|
-
"build": "node
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && npm run dts",
|
|
48
|
+
"build": "node ../../ops/scripts/esbuild.js && npm run dts",
|
|
49
|
+
"coverage": "c8 uvu test",
|
|
50
|
+
"dev": "node ../../ops/scripts/esbuild.js --dev && npm run dts",
|
|
52
51
|
"devtest": "c8 npm run unit && npm run examples && npm run lint",
|
|
53
|
-
"dts": "rollup -c &&
|
|
52
|
+
"dts": "rollup -c && biome format --write --config-path=../../biome.json --vcs-enabled=false --use-editorconfig=false types/index.d.ts",
|
|
54
53
|
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
55
|
-
"lect": "node '../../ops/lect/lect.js'
|
|
56
|
-
"
|
|
57
|
-
"lint": "
|
|
54
|
+
"lect": "node '../../ops/lect/lect.js'",
|
|
55
|
+
"lect:check": "node '../../ops/lect/lect.js' --check",
|
|
56
|
+
"lint": "biome lint --error-on-warnings . && npm run typecheck",
|
|
57
|
+
"lint:fix": "biome lint --write --error-on-warnings . && npm run typecheck",
|
|
58
58
|
"perf": "node perf/check.js",
|
|
59
59
|
"prep": "echo 'ready'",
|
|
60
|
-
"prettier": "
|
|
61
|
-
"prettier:format": "
|
|
62
|
-
"pretest": "npm run lect && npm run build",
|
|
60
|
+
"prettier": "biome format",
|
|
61
|
+
"prettier:format": "biome format --write .",
|
|
62
|
+
"pretest": "npm run lect:check && npm run build",
|
|
63
63
|
"test": "npm run devtest",
|
|
64
|
+
"typecheck": "tsc --noEmit --pretty false --project tsconfig.json",
|
|
64
65
|
"unit": "uvu test"
|
|
65
66
|
},
|
|
66
|
-
"engines": {
|
|
67
|
-
"node": ">=14.18.0"
|
|
68
|
-
},
|
|
69
67
|
"c8": {
|
|
68
|
+
"all": true,
|
|
69
|
+
"branches": 100,
|
|
70
70
|
"check-coverage": true,
|
|
71
|
-
"exclude": [
|
|
72
|
-
|
|
73
|
-
],
|
|
74
|
-
"lines": 100
|
|
71
|
+
"exclude": ["**/test/**/*.*"],
|
|
72
|
+
"functions": 100,
|
|
73
|
+
"include": ["dist/*.esm.js"],
|
|
74
|
+
"lines": 100,
|
|
75
|
+
"statements": 100
|
|
75
76
|
},
|
|
76
77
|
"lect": {
|
|
77
78
|
"licence": {
|
|
78
|
-
"extras": [
|
|
79
|
-
""
|
|
80
|
-
]
|
|
79
|
+
"extras": [""]
|
|
81
80
|
}
|
|
82
81
|
},
|
|
83
82
|
"dependencies": {
|
|
84
|
-
"
|
|
85
|
-
"codsen-utils": "^1.7.3",
|
|
86
|
-
"rfdc": "^1.4.1"
|
|
83
|
+
"codsen-utils": "^1.8.0"
|
|
87
84
|
},
|
|
88
85
|
"devDependencies": {
|
|
89
86
|
"deep-equal": "^2.2.3"
|
|
90
87
|
},
|
|
88
|
+
"engines": {
|
|
89
|
+
"node": ">=18.20.8"
|
|
90
|
+
},
|
|
91
91
|
"publishConfig": {
|
|
92
92
|
"registry": "https://registry.npmjs.org/"
|
|
93
93
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -5,12 +5,12 @@ interface Stop {
|
|
|
5
5
|
interface InnerObj {
|
|
6
6
|
depth: number;
|
|
7
7
|
path: string;
|
|
8
|
-
topmostKey
|
|
8
|
+
topmostKey?: string;
|
|
9
9
|
parent: any;
|
|
10
10
|
parentType: string;
|
|
11
11
|
parentKey: string | null;
|
|
12
12
|
}
|
|
13
|
-
type Callback = (key:
|
|
13
|
+
type Callback = (key: any, val: any, innerObj: InnerObj, stop: Stop) => any;
|
|
14
14
|
/**
|
|
15
15
|
* Utility library to traverse AST
|
|
16
16
|
*/
|