JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q60156F
  • License MIT

transforms promise chains into async/await

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

CircleCI Coverage Status semantic-release Commitizen friendly npm version

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 async-await-codemod
Renames identifiers in handlers that would conflict 🚫
Converts promise chains that aren't returned/awaited into IIAAFs 🚫
Converts return Promise.resolve()/return Promise.reject() 🚫
Warns when the original function could return/throw a non-promise 🚫
Refactoring/inlining handlers that contain conditional returns
All but one if/else/switch branch return 🚫
All but one nested if/else/switch branch return 🚫
More than one if/else/switch branch doesn't return 🚫 🚫
Return inside loop 🚫 🚫