@putout/operate
Advanced tools
Comparing version 13.0.0 to 13.1.0
@@ -15,2 +15,3 @@ 'use strict'; | ||
const {getPathAfterRequires} = require('./get-path-after-requires'); | ||
const {addParens, removeParens} = require('./parens'); | ||
@@ -52,2 +53,5 @@ const { | ||
module.exports.addParens = addParens; | ||
module.exports.removeParens = removeParens; | ||
module.exports.getProperty = getProperty; | ||
@@ -54,0 +58,0 @@ module.exports.getProperties = getProperties; |
@@ -6,6 +6,3 @@ 'use strict'; | ||
const { | ||
isObjectExpression, | ||
isCallExpression, | ||
} = types; | ||
const {isObjectExpression} = types; | ||
@@ -18,5 +15,2 @@ const nodeOrPath = (path) => path.node || path; | ||
if (isCallExpression(path.parentPath)) | ||
return path.parentPath.node; | ||
return { | ||
@@ -23,0 +17,0 @@ type: 'ExpressionStatement', |
@@ -6,13 +6,4 @@ 'use strict'; | ||
const parseNode = (a) => { | ||
a = extractMark(a); | ||
if (a.node) | ||
return a.node; | ||
return a; | ||
}; | ||
module.exports.replaceWith = (path, node) => { | ||
node = parseNode(node); | ||
node = extractMark(node); | ||
@@ -19,0 +10,0 @@ if (path?.parentPath?.isExpressionStatement() && !path.parentPath.isProgram()) { |
{ | ||
"name": "@putout/operate", | ||
"version": "13.0.0", | ||
"version": "13.1.0", | ||
"type": "commonjs", | ||
@@ -5,0 +5,0 @@ "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)", |
@@ -257,4 +257,26 @@ # Operate [![NPM version][NPMIMGURL]][NPMURL] [![Coverage Status][CoverageIMGURL]][CoverageURL] | ||
### `addParens(path: Path)` | ||
Add parens around expression depending on used `printer`: | ||
- ✅ set `node.extra.parenthesized: true` when `@putout/printer` used; | ||
- ✅ set add `ParenthesizedExpression` or `TSParenthesizedType` when `babel` used; | ||
```js | ||
addParens(path); | ||
``` | ||
### `removeParens(path: Path)` | ||
Remove parens around expression depending on used `printer`: | ||
- ✅ set `node.extra.parenthesized: false` when `@putout/printer` used; | ||
- ✅ remove `ParenthesizedExpression` or `TSParenthesizedType` when `babel` used; | ||
```js | ||
removeParens(path); | ||
``` | ||
## License | ||
MIT |
30322
27
690
282