Skip to content

Commit 007e5cb

Browse files
committed
improve comment
1 parent 4c2ae50 commit 007e5cb

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/index.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,15 @@ class DataLoader<K, V, C = K> {
227227
// which occur during the flushing of the "PromiseJobs" JobQueue after that
228228
// same execution frame.
229229
//
230-
// In Node.js we can use `process.nextTick` that is run
231-
// immediately after the "PromiseJobs" is empty.
230+
// In Node.js we wrap `nextTick`in a Promise handler itself, to ensure the
231+
// flushing of "PromiseJobs" has started, otherwise the dispatch would happen
232+
// before the Promise handlers are called.
232233
//
233-
// Browsers do not have an equivalent mechanism, therefore
234-
// we use `setImmediate` or `setTimeout` which is always run after all Promise
235-
// jobs. This might be less efficient that `nextTick`, which is ensured to
234+
// Browsers do not have an equivalent mechanism to `nextTick`, therefore
235+
// we use `setImmediate` or `setTimeout`, which is always run after all Promise
236+
// jobs. This might be less efficient than `nextTick`, which is ensured to
236237
// run directly after the all Promise jobs are done.
237238
//
238-
// In either environment we wrap `nextTick`, `setImmediate` or `setTimeout`
239-
// in a Promise handler itself, to ensure the flushing of "PromiseJobs" has
240-
// started.
241239
const enqueuePostPromiseJob =
242240
typeof process === 'object' && typeof process.nextTick === 'function'
243241
? function (fn) {

0 commit comments

Comments
 (0)