https://github.com/alwarg/converge-obj-destructring
https://github.com/alwarg/converge-obj-destructring
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/alwarg/converge-obj-destructring
- Owner: AlwarG
- License: mit
- Created: 2020-04-27T13:49:34.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T04:28:51.000Z (over 3 years ago)
- Last Synced: 2025-04-03T03:30:05.094Z (about 1 year ago)
- Language: JavaScript
- Size: 1.47 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# converge-obj-destructuring
A collection of codemod's for converge-obj-destructuring.
## Usage
To run a specific codemod from this project, you would run the following:
```
npx converge-obj-destructuring path/of/files/ or/some**/*glob.js
# or
yarn global add converge-obj-destructuring
converge-obj-destructuring path/of/files/ or/some**/*glob.js
```
## Transforms
```
let { prop1 } = obj;
let { prop2 } = obj;
```
into this
```
let {
prop1,
prop2
} = obj;
```
in the same block
**Note:**
if the cases like below
```
let obj = {
prop1: 'property1',
prop2: 'property2'
}
function updateProp2() {
obj.prop2 = 'prop2';
}
function printProps() {
let { prop1 } = obj;
updateProp2();
let { prop2 } = obj;
console.log(prop1, prop2); // property1, prop2
}
```
After running this codemod printProps function will become
```
function printProps() {
let {
prop1,
prop2
} = obj;
updateProp2();
console.log(prop1, prop2); // property1, property2
}
```
It will print `property1, property2` instead of `property1, prop2` because we are reading the prop2 value before updateProp2 function call. Kindly be aware before running this codemod.
## Contributing
### Installation
* clone the repo
* change into the repo directory
* `yarn`
### Running tests
* `yarn test`
### Update Documentation
* `yarn update-docs`