Skip to content

opt: opt judgment code of cancel#4587

Merged
jasonsaayman merged 2 commits intoaxios:masterfrom
zh-lx:opt-cancel-code
May 3, 2022
Merged

opt: opt judgment code of cancel#4587
jasonsaayman merged 2 commits intoaxios:masterfrom
zh-lx:opt-cancel-code

Conversation

@zh-lx
Copy link
Copy Markdown
Contributor

@zh-lx zh-lx commented Apr 6, 2022

If !cancel is false, it means cancel is not false. So it can be optimized as follows:

reject(!cancel || cancel.type ? new CanceledError() : cancel);

close #4588

Copy link
Copy Markdown
Member

@jasonsaayman jasonsaayman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good :)

@jasonsaayman jasonsaayman merged commit e52af17 into axios:master May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

optimazition of code

2 participants