Sha256: 3733df5d610298cf2b5bfe9f764723502be58a4870324147d452a59cd8265170

Contents?: true

Size: 685 Bytes

Versions: 180

Compression:

Stored size: 685 Bytes

Contents

module.exports = after

function after(count, callback, err_cb) {
    var bail = false
    err_cb = err_cb || noop
    proxy.count = count

    return (count === 0) ? callback() : proxy

    function proxy(err, result) {
        if (proxy.count <= 0) {
            throw new Error('after called too many times')
        }
        --proxy.count

        // after first error, rest are passed to err_cb
        if (err) {
            bail = true
            callback(err)
            // future error callbacks will go to error handler
            callback = err_cb
        } else if (proxy.count === 0 && !bail) {
            callback(null, result)
        }
    }
}

function noop() {}

Version data entries

180 entries across 92 versions & 4 rubygems

Version Path
flok-0.0.99 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/index.js
flok-0.0.99 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/after/index.js
flok-0.0.98 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/after/index.js
flok-0.0.98 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/index.js
flok-0.0.97 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/index.js
flok-0.0.97 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/after/index.js
flok-0.0.96 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/index.js
flok-0.0.96 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/after/index.js
flok-0.0.95 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/index.js
flok-0.0.95 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/after/index.js
flok-0.0.94 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/index.js
flok-0.0.94 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/after/index.js
flok-0.0.93 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/index.js
flok-0.0.93 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/after/index.js
flok-0.0.92 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/after/index.js
flok-0.0.92 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/index.js
flok-0.0.91 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/index.js
flok-0.0.91 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/after/index.js
flok-0.0.90 spec/iface/driver/assets/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/node_modules/after/index.js
flok-0.0.90 spec/iface/driver/assets/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/engine.io-parser/node_modules/after/index.js