mirror: A tiny/fast dataloader implementation
0

Configure Feed

Select the types of activity you want to include in your feed.

chore: more golf

Marais Rossouw (Jul 9, 2023, 8:34 PM +1000) d9987680 16d1d9b7

+5 -3
+5 -3
src/index.ts
··· 20 20 // Once we know we have a fresh batch, we schedule this batch to run after 21 21 // all currently queued microtasks. 22 22 queueMicrotask(function () { 23 + let tmp; 24 + let i = 0; 25 + 23 26 // As soon as we start processing this batch, we need to delete this 24 27 // batch from our container. This is because we want to ensure that 25 28 // any new requests for this batch will be added to a new batch. 26 29 batchContainer.delete(loadFn); 27 30 28 - let tmp, i; 29 31 loadFn(keys).then(function (values) { 30 32 if (values.length !== tasks.length) 31 33 return reject(new Error('loader value length mismatch')); 32 34 33 35 for ( 34 - i = 0; 36 + ; 35 37 (tmp = values[i++]), i <= values.length; 36 38 tmp instanceof Error 37 39 ? tasks[i - 1].r(tmp) ··· 40 42 }, reject); 41 43 42 44 function reject(error: Error) { 43 - for (i = 0; (tmp = tasks[i++]); tmp.r(error)); 45 + for (; (tmp = tasks[i++]); tmp.r(error)); 44 46 } 45 47 }); 46 48 }