ast-monkey-traverse 2.1.0 → 3.0.3

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 CHANGED
@@ -3,6 +3,36 @@
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
+ ## 3.0.3 (2021-11-02)
7
+
8
+ ### Bug Fixes
9
+
10
+ - bump TS and separate ESLint plugins away from this monorepo ([b1ebce1](https://github.com/codsen/codsen/commit/b1ebce1637d8c41c2d848fc24b0ba4058865bd5d))
11
+
12
+ ### Features
13
+
14
+ - migrate to ES Modules ([c579dff](https://github.com/codsen/codsen/commit/c579dff3b23205e383035ca10ddcec671e35d0fe))
15
+
16
+ ### BREAKING CHANGES
17
+
18
+ - programs now are in ES Modules and won't work with Common JS require()
19
+
20
+ ## 3.0.1 (2021-09-13)
21
+
22
+ ### Bug Fixes
23
+
24
+ - bump TS and separate ESLint plugins away from this monorepo ([2e07d42](https://github.com/codsen/codsen/commit/2e07d424222b6ffedf5fb45c83ad453627ec2904))
25
+
26
+ ## 3.0.0 (2021-09-09)
27
+
28
+ ### Features
29
+
30
+ - migrate to ES Modules ([8c9d95d](https://github.com/codsen/codsen/commit/8c9d95d5dea0b769c2f070397141918a4893d575))
31
+
32
+ ### BREAKING CHANGES
33
+
34
+ - programs now are in ES Modules and won't work with Common JS require()
35
+
6
36
  ## 2.1.0 (2021-05-24)
7
37
 
8
38
  ### Features
package/README.md CHANGED
@@ -26,10 +26,14 @@
26
26
 
27
27
  ## Install
28
28
 
29
+ This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required:
30
+
29
31
  ```bash
30
32
  npm i ast-monkey-traverse
31
33
  ```
32
34
 
35
+ If you need a legacy version which works with `require`, use version 2.1.0
36
+
33
37
  ## Quick Take
34
38
 
35
39
  ```js
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @name ast-monkey-traverse
3
3
  * @fileoverview Utility library to traverse AST
4
- * @version 2.1.0
4
+ * @version 3.0.3
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/ast-monkey-traverse/}
@@ -11,7 +11,7 @@ import clone from 'lodash.clonedeep';
11
11
  import isObj from 'lodash.isplainobject';
12
12
  import { parent } from 'ast-monkey-util';
13
13
 
14
- var version$1 = "2.1.0";
14
+ var version$1 = "3.0.3";
15
15
 
16
16
  const version = version$1;
17
17
  function traverse(tree1, cb1) {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @name ast-monkey-traverse
3
3
  * @fileoverview Utility library to traverse AST
4
- * @version 2.1.0
4
+ * @version 3.0.3
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/ast-monkey-traverse/}
@@ -11,8 +11,8 @@
11
11
  /**
12
12
  * @name ast-monkey-util
13
13
  * @fileoverview Utility library of AST helper functions
14
- * @version 1.4.0
14
+ * @version 2.0.3
15
15
  * @author Roy Revelt, Codsen Ltd
16
16
  * @license MIT
17
17
  * {@link https://codsen.com/os/ast-monkey-util/}
18
- */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="2.1.0",Object.defineProperty(t,"__esModule",{value:!0})}));
18
+ */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.3",Object.defineProperty(t,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ast-monkey-traverse",
3
- "version": "2.1.0",
3
+ "version": "3.0.3",
4
4
  "description": "Utility library to traverse AST",
5
5
  "keywords": [
6
6
  "ast",
@@ -37,17 +37,21 @@
37
37
  "email": "roy@codsen.com",
38
38
  "url": "https://codsen.com"
39
39
  },
40
- "main": "dist/ast-monkey-traverse.cjs.js",
41
- "module": "dist/ast-monkey-traverse.esm.js",
42
- "browser": "dist/ast-monkey-traverse.umd.js",
40
+ "type": "module",
41
+ "exports": {
42
+ "script": "./dist/ast-monkey-traverse.umd.js",
43
+ "default": "./dist/ast-monkey-traverse.esm.js"
44
+ },
43
45
  "types": "types/index.d.ts",
44
46
  "scripts": {
45
47
  "build": "rollup -c",
46
- "esbuild": "node '../../scripts/esbuild.js'",
47
- "esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
48
48
  "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov",
49
+ "clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
50
+ "clean_types": "../../scripts/cleanTypes.js",
49
51
  "dev": "rollup -c --dev",
50
52
  "devunittest": "npm run dev && tap --only -R 'base'",
53
+ "esbuild": "node '../../scripts/esbuild.js'",
54
+ "esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
51
55
  "format": "npm run lect && npm run prettier && npm run lint",
52
56
  "lect": "lect",
53
57
  "lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
@@ -55,22 +59,22 @@
55
59
  "prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
56
60
  "republish": "npm publish || :",
57
61
  "tap": "tap",
58
- "tsc": "tsc",
59
62
  "pretest": "npm run build",
60
63
  "test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
61
64
  "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
62
- "unittest": "./node_modules/.bin/tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf",
63
- "clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
64
- "clean_types": "../../scripts/cleanTypes.js"
65
+ "tsc": "tsc",
66
+ "unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf"
65
67
  },
66
68
  "tap": {
69
+ "check-coverage": false,
67
70
  "coverage-report": [
68
71
  "json-summary",
69
72
  "text"
70
73
  ],
71
- "nyc-arg": [
72
- "--exclude=**/*.cjs.js",
73
- "--exclude=**/*.umd.js"
74
+ "node-arg": [
75
+ "--no-warnings",
76
+ "--experimental-loader",
77
+ "@istanbuljs/esm-loader-hook"
74
78
  ],
75
79
  "timeout": 0
76
80
  },
@@ -90,50 +94,54 @@
90
94
  }
91
95
  },
92
96
  "dependencies": {
93
- "@babel/runtime": "^7.14.0",
94
- "ast-monkey-util": "^1.4.0",
97
+ "@babel/runtime": "^7.16.0",
98
+ "ast-monkey-util": "^2.0.3",
95
99
  "lodash.clonedeep": "^4.5.0",
96
100
  "lodash.isplainobject": "^4.0.6"
97
101
  },
98
102
  "devDependencies": {
99
- "@babel/cli": "^7.14.3",
100
- "@babel/core": "^7.14.3",
101
- "@babel/node": "^7.14.2",
102
- "@babel/plugin-external-helpers": "^7.12.13",
103
- "@babel/plugin-proposal-class-properties": "^7.13.0",
104
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.2",
105
- "@babel/plugin-proposal-object-rest-spread": "^7.14.2",
106
- "@babel/plugin-proposal-optional-chaining": "^7.14.2",
107
- "@babel/plugin-transform-runtime": "^7.14.3",
108
- "@babel/preset-env": "^7.14.2",
109
- "@babel/preset-typescript": "^7.13.0",
110
- "@babel/register": "^7.13.16",
103
+ "@babel/cli": "^7.16.0",
104
+ "@babel/core": "^7.16.0",
105
+ "@babel/node": "^7.16.0",
106
+ "@babel/plugin-external-helpers": "^7.16.0",
107
+ "@babel/plugin-proposal-class-properties": "^7.16.0",
108
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
109
+ "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
110
+ "@babel/plugin-proposal-optional-chaining": "^7.16.0",
111
+ "@babel/plugin-transform-runtime": "^7.16.0",
112
+ "@babel/preset-env": "^7.16.0",
113
+ "@babel/preset-typescript": "^7.16.0",
114
+ "@babel/register": "^7.16.0",
115
+ "@istanbuljs/esm-loader-hook": "^0.1.2",
111
116
  "@rollup/plugin-babel": "^5.3.0",
112
- "@rollup/plugin-commonjs": "^19.0.0",
117
+ "@rollup/plugin-commonjs": "^21.0.1",
113
118
  "@rollup/plugin-json": "^4.1.0",
114
- "@rollup/plugin-node-resolve": "^13.0.0",
115
- "@rollup/plugin-strip": "^2.0.1",
116
- "@rollup/plugin-typescript": "^8.2.1",
119
+ "@rollup/plugin-node-resolve": "^13.0.6",
120
+ "@rollup/plugin-strip": "^2.1.0",
121
+ "@rollup/plugin-typescript": "^8.3.0",
117
122
  "@types/lodash.clonedeep": "^4.5.6",
118
123
  "@types/lodash.isplainobject": "^4.0.6",
119
- "@types/node": "^15.6.0",
120
- "@types/tap": "^15.0.1",
121
- "@typescript-eslint/eslint-plugin": "^4.24.0",
122
- "@typescript-eslint/parser": "^4.24.0",
123
- "core-js": "^3.12.1",
124
+ "@types/node": "^16.11.6",
125
+ "@types/tap": "^15.0.5",
126
+ "@typescript-eslint/eslint-plugin": "^5.2.0",
127
+ "@typescript-eslint/parser": "^5.2.0",
128
+ "core-js": "^3.19.0",
124
129
  "cross-env": "^7.0.3",
125
- "eslint": "^7.27.0",
126
- "lect": "^0.17.0",
130
+ "eslint": "^8.1.0",
131
+ "lect": "^0.18.3",
127
132
  "lodash.isequal": "^4.5.0",
128
- "object-path": "^0.11.5",
129
- "rollup": "^2.49.0",
133
+ "object-path": "^0.11.8",
134
+ "rollup": "^2.59.0",
130
135
  "rollup-plugin-ascii": "^0.0.3",
131
136
  "rollup-plugin-banner": "^0.2.1",
132
137
  "rollup-plugin-cleanup": "^3.2.1",
133
- "rollup-plugin-dts": "^3.0.1",
138
+ "rollup-plugin-dts": "^4.0.0",
134
139
  "rollup-plugin-terser": "^7.0.2",
135
- "tap": "^14.11.0",
136
- "tslib": "^2.2.0",
137
- "typescript": "^4.2.4"
140
+ "tap": "^15.0.10",
141
+ "tslib": "^2.3.1",
142
+ "typescript": "^4.4.4"
143
+ },
144
+ "engines": {
145
+ "node": ">=12"
138
146
  }
139
147
  }
@@ -1,95 +0,0 @@
1
- /**
2
- * @name ast-monkey-traverse
3
- * @fileoverview Utility library to traverse AST
4
- * @version 2.1.0
5
- * @author Roy Revelt, Codsen Ltd
6
- * @license MIT
7
- * {@link https://codsen.com/os/ast-monkey-traverse/}
8
- */
9
-
10
- 'use strict';
11
-
12
- Object.defineProperty(exports, '__esModule', { value: true });
13
-
14
- var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
15
- var clone = require('lodash.clonedeep');
16
- var isObj = require('lodash.isplainobject');
17
- var astMonkeyUtil = require('ast-monkey-util');
18
-
19
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
-
21
- var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
22
- var clone__default = /*#__PURE__*/_interopDefaultLegacy(clone);
23
- var isObj__default = /*#__PURE__*/_interopDefaultLegacy(isObj);
24
-
25
- var version$1 = "2.1.0";
26
-
27
- var version = version$1;
28
- function traverse(tree1, cb1) {
29
- var stop2 = {
30
- now: false
31
- };
32
- function traverseInner(treeOriginal, callback, originalInnerObj, stop) {
33
- var tree = clone__default['default'](treeOriginal);
34
- var res;
35
- var innerObj = _objectSpread__default['default']({
36
- depth: -1,
37
- path: ""
38
- }, originalInnerObj);
39
- innerObj.depth += 1;
40
- if (Array.isArray(tree)) {
41
- for (var i = 0, len = tree.length; i < len; i++) {
42
- if (stop.now) {
43
- break;
44
- }
45
- var path = innerObj.path ? "".concat(innerObj.path, ".").concat(i) : "".concat(i);
46
- if (tree[i] !== undefined) {
47
- innerObj.parent = clone__default['default'](tree);
48
- innerObj.parentType = "array";
49
- innerObj.parentKey = astMonkeyUtil.parent(path);
50
- res = traverseInner(callback(tree[i], undefined, _objectSpread__default['default'](_objectSpread__default['default']({}, innerObj), {}, {
51
- path: path
52
- }), stop), callback, _objectSpread__default['default'](_objectSpread__default['default']({}, innerObj), {}, {
53
- path: path
54
- }), stop);
55
- if (Number.isNaN(res) && i < tree.length) {
56
- tree.splice(i, 1);
57
- i -= 1;
58
- } else {
59
- tree[i] = res;
60
- }
61
- } else {
62
- tree.splice(i, 1);
63
- }
64
- }
65
- } else if (isObj__default['default'](tree)) {
66
- for (var key in tree) {
67
- if (stop.now && key != null) {
68
- break;
69
- }
70
- var _path = innerObj.path ? "".concat(innerObj.path, ".").concat(key) : key;
71
- if (innerObj.depth === 0 && key != null) {
72
- innerObj.topmostKey = key;
73
- }
74
- innerObj.parent = clone__default['default'](tree);
75
- innerObj.parentType = "object";
76
- innerObj.parentKey = astMonkeyUtil.parent(_path);
77
- res = traverseInner(callback(key, tree[key], _objectSpread__default['default'](_objectSpread__default['default']({}, innerObj), {}, {
78
- path: _path
79
- }), stop), callback, _objectSpread__default['default'](_objectSpread__default['default']({}, innerObj), {}, {
80
- path: _path
81
- }), stop);
82
- if (Number.isNaN(res)) {
83
- delete tree[key];
84
- } else {
85
- tree[key] = res;
86
- }
87
- }
88
- }
89
- return tree;
90
- }
91
- return traverseInner(tree1, cb1, {}, stop2);
92
- }
93
-
94
- exports.traverse = traverse;
95
- exports.version = version;