Package Exports
- @codemodsquad/asyncify
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@codemodsquad/asyncify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@codemodsquad/asyncify
Transforms promise chains into async
/await
. I wrote this to refactor the 5000+ .then
/.catch
/.finally
calls in the
sequelize
codebase. This is slightly inspired by async-await-codemod,
but written from scratch to guarantee the same behavior and tidy code as best as I can manage.
Usage
git clone https://github.com/codemodsquad/asyncify
npx jscodeshift -t asyncify/index.js path/to/your/project/**/*.js
Support table
asyncify |
|
---|---|
Converts .then |
✅ |
Converts .catch |
✅ |
Converts .finally |
✅ |
Renames identifiers in handlers that would conflict | ✅ |
Converts promise chains that aren't returned/awaited into IIAAFs | ✅ |
Converts return Promise.resolve() /return Promise.reject() |
✅ |
Removes unnecessary Promise.resolve() wrappers |
✅ |
Warns when the original function could return/throw a non-promise | Planned |
Refactoring/inlining handlers that contain conditional returns | |
All but one if/else/switch branch return | ✅ |
All branches return, even nested ones | ✅ |
All but one nested if/else/switch branch return | 🚫 |
More than one if/else/switch branch doesn't return | 🚫 |
Return inside loop | 🚫 |