MCPcopy Create free account
hub / github.com/PrairieLearn/PrairieLearn / after

Function after

public/javascripts/socket.io.js:6285–6308  ·  view source on GitHub ↗
(count, callback, err_cb)

Source from the content-addressed store, hash-verified

6283 module.exports = after
6284
6285 function after(count, callback, err_cb) {
6286 var bail = false
6287 err_cb = err_cb || noop
6288 proxy.count = count
6289
6290 return (count === 0) ? callback() : proxy
6291
6292 function proxy(err, result) {
6293 if (proxy.count <= 0) {
6294 throw new Error('after called too many times')
6295 }
6296 --proxy.count
6297
6298 // after first error, rest are passed to err_cb
6299 if (err) {
6300 bail = true
6301 callback(err)
6302 // future error callbacks will go to error handler
6303 callback = err_cb
6304 } else if (proxy.count === 0 && !bail) {
6305 callback(null, result)
6306 }
6307 }
6308 }
6309
6310 function noop() {}
6311

Callers 15

mapFunction · 0.85
testFileEditor.jsFile · 0.85
testApi.jsFile · 0.85
index.jsFile · 0.85
testQuestions.jsFile · 0.85
testAccess.jsFile · 0.85
testExam.jsFile · 0.85

Calls 1

callbackFunction · 0.85

Tested by

no test coverage detected