Skip to content

Commit

Permalink
fix: return early if no req
Browse files Browse the repository at this point in the history
  • Loading branch information
shanejonas committed May 21, 2019
1 parent efd0f61 commit 5e2dab2
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/RequestManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,16 @@ class RequestManager {
return;
}
const req = this.requests[parsedData.id];
// call request callback for id
if (req) {
if (parsedData.error) {
req.reject(parsedData.error);
} else {
req.resolve(parsedData.result);
}
delete this.requests[parsedData.id];
if (req === undefined) {
return;
}
// resolve promise for id
if (parsedData.error) {
req.reject(parsedData.error);
} else {
req.resolve(parsedData.result);
}
delete this.requests[parsedData.id];
}
}

Expand Down

0 comments on commit 5e2dab2

Please sign in to comment.