Skip to content

Commit

Permalink
fix: dont defer return of non-async val in async fn
Browse files Browse the repository at this point in the history
Doesn't appear to be necessary as the fn doesn't take a callback and the
result can only be accessed via `then()` method or `await` (the fn has
to be awaited either way in order to access the return value, regardless
of whether the function finishes immediately or not).
  • Loading branch information
tmillr committed Nov 22, 2022
1 parent 2238c73 commit b4e9b26
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export function getOctokit(

return async function (repoOwner, repoName, number, which) {
const x = `${repoOwner} ${repoName} ${number} ${which}`;
if (x in cache) return await defer(cache[x]);

if ({}.constructor.prototype.hasOwnProperty.call(cache, x))
return cache[x];

return (cache[x] = (
await this.graphql(
Expand Down Expand Up @@ -102,14 +104,6 @@ export function getOctokit(
return octokit;
}

export function defer(val) {
return new Promise((resolve, reject) => {
queueMicrotask(() => {
resolve(val);
});
});
}

export function inputWasProvided(input) {
return input !== "";
}

0 comments on commit b4e9b26

Please sign in to comment.