index.js
function removeTargets(self, userId, channel, targets, callback) {
    // dereference the original array,
    // because that may not be trustworthy
    targets = cloneArray(targets)

    var pending = targets.length,
        errors  = []

    if (pending)
        targets.forEach(function (target) {
            self.remove(userId, channel, target, function (err) {
                // something went wrong
                if (err) {
                    // decorate errors with debug info
                    if (typeof err === 'object') {
                        err.userId  = userId
                        err.channel = channel
                        err.target  = target
                    }

                    // collect errors to pass back later to the caller
                    errors.push(err)
                }

                // count pending operations and then pass back the control to the caller
                --pending || process.nextTick(callback, errors.length ? errors : null)
            })
        })
    else {
        // no targets found, so
        // there is nothing to do here
        process.nextTick(callback, null)
    }
}
function removeTargets(self, userId, channel, targets, callback) {
    // dereference the original array,
    // because that may not be trustworthy
    targets = cloneArray(targets)

    var pending = targets.length,
        errors  = []

    if (pending)
        targets.forEach(function (target) {
            self.remove(userId, channel, target, function (err) {
                // something went wrong
                if (err) {
                    // decorate errors with debug info
                    if (typeof err === 'object') {
                        err.userId  = userId
                        err.channel = channel
                        err.target  = target
                    }

                    // collect errors to pass back later to the caller
                    errors.push(err)
                }

                // count pending operations and then pass back the control to the caller
                --pending || process.nextTick(callback, errors.length ? errors : null)
            })
        })
    else {
        // no targets found, so
        // there is nothing to do here
        process.nextTick(callback, null)
    }
}
function removeTargets ( self , userId , channel , targets , callback ) { // dereference the original array, // because that may not be trustworthy targets = cloneArray ( targets ) var pending = targets . length , errors = [ ] if ( pending ) targets . forEach ( function ( target ) { self . remove ( userId , channel , target , function ( err ) { // something went wrong if ( err ) { // decorate errors with debug info if ( typeof err === 'object' ) { err . userId = userId err . channel = channel err . target = target } // collect errors to pass back later to the caller errors . push ( err ) } // count pending operations and then pass back the control to the caller -- pending || process . nextTick ( callback , errors . length ? errors : null ) } ) } ) else { // no targets found, so // there is nothing to do here process . nextTick ( callback , null ) } }
Internal func to remove the provided targets. Same as `unregisterTargets` but it assumes that `targets` is an array.

@param {Handover} self - Handover instance to work on.
@param {*} userId
@param {string} channel
@param {*[]} targets
@param {function} callback
Internal func to remove the provided targets . Same as unregisterTargets but it assumes that targets is an array .