Skip to content

Commit

Permalink
chore: more golf
Browse files Browse the repository at this point in the history
  • Loading branch information
maraisr committed Jul 9, 2023
1 parent 16d1d9b commit d998768
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/index.ts
Expand Up @@ -20,18 +20,20 @@ export function load<T, K = string>(
// Once we know we have a fresh batch, we schedule this batch to run after
// all currently queued microtasks.
queueMicrotask(function () {
let tmp;
let i = 0;

// As soon as we start processing this batch, we need to delete this
// batch from our container. This is because we want to ensure that
// any new requests for this batch will be added to a new batch.
batchContainer.delete(loadFn);

let tmp, i;
loadFn(keys).then(function (values) {
if (values.length !== tasks.length)
return reject(new Error('loader value length mismatch'));

for (
i = 0;
;
(tmp = values[i++]), i <= values.length;
tmp instanceof Error
? tasks[i - 1].r(tmp)
Expand All @@ -40,7 +42,7 @@ export function load<T, K = string>(
}, reject);

function reject(error: Error) {
for (i = 0; (tmp = tasks[i++]); tmp.r(error));
for (; (tmp = tasks[i++]); tmp.r(error));
}
});
}
Expand Down

0 comments on commit d998768

Please sign in to comment.