@putout/engine-runner 13.3.1 → 13.4.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/README.md +3 -3
- package/lib/index.js +2 -0
- package/lib/store.js +6 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -245,7 +245,7 @@ Let's talk about each of them.
|
|
|
245
245
|
|
|
246
246
|
### `listStore`
|
|
247
247
|
|
|
248
|
-
To save things as a list use `listStore`.
|
|
248
|
+
To save things as a list without duplicates use `listStore`.
|
|
249
249
|
Let's suppose you have such code:
|
|
250
250
|
|
|
251
251
|
```js
|
|
@@ -260,14 +260,14 @@ Let's process it!
|
|
|
260
260
|
```js
|
|
261
261
|
module.exports.traverse = ({listStore}) => ({
|
|
262
262
|
'debugger'(path) {
|
|
263
|
-
listStore(
|
|
263
|
+
listStore(path);
|
|
264
264
|
},
|
|
265
265
|
|
|
266
266
|
Program: {
|
|
267
267
|
exit() {
|
|
268
268
|
console.log(listStore());
|
|
269
269
|
// returns
|
|
270
|
-
['
|
|
270
|
+
[{type: 'DebuggerStatement'}, {type: 'DebuggerStatement'}];
|
|
271
271
|
// for code
|
|
272
272
|
'debugger; debugger';
|
|
273
273
|
},
|
package/lib/index.js
CHANGED
|
@@ -65,8 +65,10 @@ function runWithMerge({ast, fix, shebang, template, pluginsTraverse, merge}) {
|
|
|
65
65
|
traverse(ast, visitor);
|
|
66
66
|
|
|
67
67
|
const places = [];
|
|
68
|
+
|
|
68
69
|
for (const [rule, pull] of entries) {
|
|
69
70
|
const items = pull();
|
|
71
|
+
|
|
70
72
|
for (const {message, position} of items) {
|
|
71
73
|
places.push({
|
|
72
74
|
rule,
|
package/lib/store.js
CHANGED
|
@@ -8,21 +8,21 @@ const {
|
|
|
8
8
|
|
|
9
9
|
const toArray = (a) => Array.from(a);
|
|
10
10
|
|
|
11
|
-
module.exports.listStore = (list =
|
|
11
|
+
module.exports.listStore = (list = new Set()) => {
|
|
12
12
|
const fn = (...args) => {
|
|
13
13
|
if (!args.length)
|
|
14
|
-
return list;
|
|
14
|
+
return Array.from(list);
|
|
15
15
|
|
|
16
16
|
const [a] = args;
|
|
17
|
-
list.
|
|
17
|
+
list.add(a);
|
|
18
18
|
|
|
19
|
-
return list;
|
|
19
|
+
return Array.from(list);
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
fn.clear = () => {
|
|
23
23
|
const a = list;
|
|
24
|
-
list =
|
|
25
|
-
return a;
|
|
24
|
+
list = new Set();
|
|
25
|
+
return Array.from(a);
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
return fn;
|