MCPcopy
hub / github.com/mongodb/node-mongodb-native / makeExecuteDeferred

Function makeExecuteDeferred

test/tools/runner/plugins/deferred.js:8–24  ·  view source on GitHub ↗
(test)

Source from the content-addressed store, hash-verified

6const { Context } = mocha;
7
8function makeExecuteDeferred(test) {
9 return async function () {
10 /** @type {Array<() => Promise<void>>} */
11 const deferredActions = test[kDeferred];
12
13 // process actions LIFO
14 const actions = Array.from(deferredActions).reverse();
15
16 try {
17 for (const fn of actions) {
18 await fn();
19 }
20 } finally {
21 test[kDeferred].length = 0;
22 }
23 };
24}
25
26Context.prototype.defer = function defer(fn) {
27 const test = this.test;

Callers 1

deferred.jsFile · 0.85

Calls 1

fnFunction · 0.50

Tested by

no test coverage detected