Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@putout/engine-runner

Package Overview
Dependencies
Maintainers
1
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@putout/engine-runner - npm Package Compare versions

Comparing version 11.6.0 to 12.0.0

13

lib/merge-visitors.js

@@ -9,3 +9,7 @@ 'use strict';

const maybeArray = require('./maybe-array');
const {listStore, mapStore} = require('./store');
const {
listStore,
mapStore,
upStore,
} = require('./store');

@@ -20,3 +24,3 @@ const shouldSkip = (a) => !a.parent;

if (plugin[name])
list.push(...plugin[name]());
list.push(...maybeArray(plugin[name]()));

@@ -38,2 +42,3 @@ if (options[name])

store,
upstore,
listStore,

@@ -54,2 +59,3 @@ } = getStore(plugin, {

listStore,
upstore,
generate,

@@ -89,2 +95,3 @@ options,

const list = listStore();
const upstore = upStore();
const placesStore = listStore();

@@ -112,2 +119,3 @@

list.clear();
upstore.clear();
return placesStore.clear();

@@ -121,4 +129,5 @@ };

listStore: list,
upstore,
};
}

60

lib/store.js

@@ -8,3 +8,2 @@ 'use strict';

} = Object;
const isObject = (a) => typeof a === 'object';

@@ -31,31 +30,40 @@ module.exports.listStore = (list = []) => {

module.exports.mapStore = (map = {}) => {
const fn = (...args) => {
if (!args.length)
return values(map);
module.exports.mapStore = createStore({
set(map, name, data) {
map[name] = data;
},
});
module.exports.upStore = createStore({
set(map, name, data) {
map[name] = map[name] || {};
assign(map[name], data);
},
});
function createStore({set}) {
return (map = {}) => {
const fn = (...args) => {
if (!args.length)
return values(map);
const [name, data] = args;
if (args.length === 1)
return map[name];
set(map, name, data);
};
const [name, data] = args;
fn.clear = () => {
map = {};
};
if (args.length === 1)
return map[name];
fn.entries = () => {
return entries(map);
};
if (isObject(data)) {
map[name] = map[name] || {};
assign(map[name], data);
return;
}
map[name] = data;
return fn;
};
fn.clear = () => {
map = {};
};
fn.entries = () => {
return entries(map);
};
return fn;
};
}

@@ -27,3 +27,3 @@ 'use strict';

const exclude = ({rule, tmpl, fn, nodesExclude}) => {
if (!nodesExclude.length)
if (!isFn(fn) || !nodesExclude.length)
return {

@@ -30,0 +30,0 @@ [tmpl]: fn,

{
"name": "@putout/engine-runner",
"version": "11.6.0",
"version": "12.0.0",
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
"description": "run putout plugins",
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/engine-runner",
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/engine-runner#readme",
"main": "lib/index.js",

@@ -52,2 +52,3 @@ "release": false,

"madrun": "^8.0.1",
"mock-require": "^3.0.3",
"montag": "^1.0.0",

@@ -54,0 +55,0 @@ "nodemon": "^2.0.1",

@@ -196,3 +196,3 @@ # @putout/engine-runner [![NPM version][NPMIMGURL]][NPMURL]

`store` is preferred way of keeping array elements, because of caching of `putout`, `traverse` init function called only once, and any other way
`store` is preferred way of keeping data, because of caching 🐊`putout`, `traverse` init function called only once, and any other way
of handling variables will most likely will lead to bugs.

@@ -229,2 +229,57 @@

#### Upstore
When you need to update already saved values, use `upstore`
```js
module.exports.traverse = ({push, store}) => ({
TSTypeAliasDeclaration(path) {
if (path.parentPath.isExportNamedDeclaration())
return;
store(path.node.id.name, {
path,
});
},
ObjectProperty(path) {
const {value} = path.node;
const {name} = value;
store(name, {
used: true,
});
},
Program: {
exit() {
for (const {path, used} of store()) {
if (used)
continue;
push(path);
}
},
},
});
```
#### ListStore
When you need to track list of elements, use `listStore`:
```
module.exports.traverse = ({push, listStore}) => ({
ImportDeclaration(path) {
listStore(path);
},
Program: {
exit: () => {
processImports(push, listStore());
},
},
});
```
### Finder

@@ -231,0 +286,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc