@putout/engine-runner
Advanced tools
Comparing version 13.7.0 to 14.0.0
@@ -14,2 +14,3 @@ 'use strict'; | ||
upListStore, | ||
pathStore, | ||
} = require('./store'); | ||
@@ -44,2 +45,3 @@ | ||
listStore, | ||
pathStore, | ||
uplist, | ||
@@ -60,2 +62,3 @@ } = getStore(plugin, { | ||
listStore, | ||
pathStore, | ||
upstore, | ||
@@ -100,2 +103,3 @@ uplist, | ||
const uplist = upListStore(); | ||
const paths = pathStore(); | ||
@@ -124,2 +128,3 @@ const push = (path) => { | ||
uplist.clear(); | ||
paths.clear(); | ||
@@ -136,4 +141,5 @@ return placesStore.clear(); | ||
uplist, | ||
pathStore: paths, | ||
}; | ||
} | ||
@@ -10,23 +10,8 @@ 'use strict'; | ||
const toArray = (a) => Array.from(a); | ||
const isNotRemoved = (a) => a.node; | ||
const notRemoved = (a) => toArray(a).filter(isNotRemoved); | ||
const id = (a) => a; | ||
module.exports.listStore = (list = new Set()) => { | ||
const fn = (...args) => { | ||
if (!args.length) | ||
return Array.from(list); | ||
const [a] = args; | ||
list.add(a); | ||
return Array.from(list); | ||
}; | ||
fn.clear = () => { | ||
const a = list; | ||
list = new Set(); | ||
return Array.from(a); | ||
}; | ||
return fn; | ||
}; | ||
module.exports.listStore = createListStore(); | ||
module.exports.pathStore = createListStore(notRemoved); | ||
@@ -86,1 +71,21 @@ module.exports.mapStore = createStore({ | ||
function createListStore(returns = id) { | ||
return (list = new Set()) => { | ||
const fn = (...args) => { | ||
if (!args.length) | ||
return returns(toArray(list)); | ||
const [a] = args; | ||
list.add(a); | ||
}; | ||
fn.clear = () => { | ||
const a = list; | ||
list = new Set(); | ||
return returns(toArray(a)); | ||
}; | ||
return fn; | ||
}; | ||
} |
{ | ||
"name": "@putout/engine-runner", | ||
"version": "13.7.0", | ||
"version": "14.0.0", | ||
"type": "commonjs", | ||
@@ -47,4 +47,4 @@ "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)", | ||
"eslint": "^8.0.1", | ||
"eslint-plugin-node": "^11.0.0", | ||
"eslint-plugin-putout": "^15.0.0", | ||
"eslint-plugin-n": "^15.2.4", | ||
"eslint-plugin-putout": "^16.0.0", | ||
"just-camel-case": "^4.0.2", | ||
@@ -51,0 +51,0 @@ "lerna": "^5.0.0", |
@@ -240,2 +240,3 @@ # @putout/engine-runner [![NPM version][NPMIMGURL]][NPMURL] | ||
- ✅`listStore`; | ||
- ✅`pathStore`; | ||
- ✅`store`; | ||
@@ -279,2 +280,30 @@ - ✅`upstore`; | ||
### `pathStore` | ||
When you want additional check that `path` not removed. | ||
```js | ||
debugger; | ||
const hello = ''; | ||
``` | ||
Let's process it! | ||
```js | ||
module.exports.traverse = ({pathStore}) => ({ | ||
'debugger'(path) { | ||
pathStore(path); | ||
path.remove(); | ||
}, | ||
Program: { | ||
exit() { | ||
console.log(listStore()); | ||
// returns | ||
[]; | ||
}, | ||
}, | ||
}); | ||
``` | ||
### `store` | ||
@@ -281,0 +310,0 @@ |
33300
764
423