@putout/operate
Advanced tools
Comparing version 8.15.0 to 9.0.0
@@ -45,2 +45,1 @@ 'use strict'; | ||
} | ||
@@ -7,2 +7,3 @@ 'use strict'; | ||
} = require('@babel/types'); | ||
const isString = (a) => typeof a === 'string'; | ||
@@ -42,2 +43,1 @@ | ||
}; | ||
@@ -14,2 +14,1 @@ 'use strict'; | ||
}; | ||
@@ -20,6 +20,3 @@ 'use strict'; | ||
if (isOptionalMemberExpression(a)) | ||
return true; | ||
return false; | ||
return isOptionalMemberExpression(a); | ||
}; |
@@ -15,6 +15,3 @@ 'use strict'; | ||
const { | ||
getBinding, | ||
getBindingPath, | ||
} = require('./get-binding'); | ||
const {getBinding, getBindingPath} = require('./get-binding'); | ||
@@ -28,7 +25,5 @@ const {isSimple} = require('./is-simple'); | ||
const {renameProperty} = require('./rename-property'); | ||
const { | ||
getProperty, | ||
getProperties, | ||
} = require('./properties'); | ||
const {getProperty, getProperties} = require('./properties'); | ||
const {assign} = Object; | ||
@@ -69,6 +64,3 @@ | ||
const { | ||
comments, | ||
loc, | ||
} = path.node; | ||
const {comments, loc} = path.node; | ||
@@ -91,3 +83,5 @@ const {currentPath} = maybeBody(path, node); | ||
const newNodes = nodes.filter(Boolean).map(toExpression); | ||
const newNodes = nodes | ||
.filter(Boolean) | ||
.map(toExpression); | ||
@@ -107,2 +101,6 @@ const {currentPath} = maybeBody(path); | ||
const {comments} = path.node; | ||
if (path.node.trailingComments?.length && path.getNextSibling()?.node?.leadingComments) | ||
delete path.node.trailingComments; | ||
path.insertAfter(node); | ||
@@ -109,0 +107,0 @@ path.node.comments = comments; |
@@ -14,2 +14,3 @@ 'use strict'; | ||
const name = `${currentName}Path`; | ||
result[name] = propertyPath; | ||
@@ -36,2 +37,1 @@ continue; | ||
}; | ||
@@ -36,2 +36,3 @@ 'use strict'; | ||
}; | ||
const getComments = (path) => { | ||
@@ -58,2 +59,1 @@ const {comments} = path.node; | ||
}; | ||
@@ -21,2 +21,1 @@ 'use strict'; | ||
}; | ||
@@ -17,2 +17,1 @@ 'use strict'; | ||
}; | ||
{ | ||
"name": "@putout/operate", | ||
"version": "8.15.0", | ||
"version": "9.0.0", | ||
"type": "commonjs", | ||
@@ -39,6 +39,6 @@ "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)", | ||
"@putout/plugin-remove-unreferenced-variables": "*", | ||
"c8": "^7.5.0", | ||
"c8": "^8.0.0", | ||
"eslint": "^8.0.1", | ||
"eslint-plugin-n": "^16.0.0", | ||
"eslint-plugin-putout": "^17.0.0", | ||
"eslint-plugin-putout": "^18.0.0", | ||
"just-camel-case": "^4.0.2", | ||
@@ -48,3 +48,3 @@ "lerna": "^6.0.1", | ||
"montag": "^1.0.0", | ||
"nodemon": "^2.0.1", | ||
"nodemon": "^3.0.1", | ||
"putout": "*", | ||
@@ -51,0 +51,0 @@ "supertape": "^8.0.0", |
@@ -83,9 +83,10 @@ # Operate [![NPM version][NPMIMGURL]][NPMURL] [![Coverage Status][CoverageIMGURL]][CoverageURL] | ||
### `insertAfter(path, node)` | ||
Safe way to insert `node` after `path` without duplicating comments. | ||
### `replaceWith(path, node)` | ||
```js | ||
const { | ||
operator, | ||
types, | ||
} = require('putout'); | ||
const {operator, types} = require('putout'); | ||
@@ -101,6 +102,3 @@ const {replaceWith} = operator; | ||
```js | ||
const { | ||
operator, | ||
types, | ||
} = require('putout'); | ||
const {operator, types} = require('putout'); | ||
@@ -136,4 +134,3 @@ const {replaceWithMultiple} = operator; | ||
path.toString(); | ||
// returns const [, b] = c; | ||
path.toString(); // returns const [, b] = c; | ||
``` | ||
@@ -198,2 +195,3 @@ | ||
const [computed, value] = compute(path); | ||
// returns | ||
@@ -200,0 +198,0 @@ [true, `typeof __a === 'function'`]; |
20099
395
226