Skip to content

Commit

Permalink
Remove unnecessary Promise.resolve and Promise.reject
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Oct 6, 2021
1 parent bfc354e commit fcdeaf9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/execution/execute.ts
Expand Up @@ -368,7 +368,7 @@ function executeOperation(
if (isPromise(result)) {
return result.then(undefined, (error) => {
exeContext.errors.push(error);
return Promise.resolve(null);
return null;
});
}
return result;
Expand Down
7 changes: 4 additions & 3 deletions src/subscription/mapAsyncIterator.ts
Expand Up @@ -43,9 +43,10 @@ export function mapAsyncIterator<T, U, R = undefined>(
: { value: undefined as any, done: true };
},
async throw(error?: unknown) {
return typeof iterator.throw === 'function'
? mapResult(await iterator.throw(error))
: Promise.reject(error);
if (typeof iterator.throw === 'function') {
return mapResult(await iterator.throw(error));
}
throw error;
},
[Symbol.asyncIterator]() {
return this;
Expand Down

0 comments on commit fcdeaf9

Please sign in to comment.