src/conrad.js
function _killJob(v1) {
    var i,
        l,
        k,
        a,
        job,
        found = false;

    // Array of job ids:
    if (Array.isArray(v1))
      for (i = 0, l = v1.length; i < l; i++)
        _killJob(v1[i]);

    // One job's id:
    else if (typeof v1 === 'string') {
      a = [_runningJobs, _waitingJobs, _jobs];

      // Remove the job from the hashes:
      for (i = 0, l = a.length; i < l; i++)
        if (v1 in a[i]) {
          job = a[i][v1];

          if (_parameters.history) {
            job.status = 'done';
            _doneJobs.push(job);
          }

          _dispatch('jobEnded', __clone(job));
          delete a[i][v1];

          if (typeof job.end === 'function')
            job.end();

          found = true;
        }

      // Remove the priorities array:
      a = _sortedByPriorityJobs;
      for (i = 0, l = a.length; i < l; i++)
        if (a[i].id === v1) {
          a.splice(i, 1);
          break;
        }

      if (!found)
        throw new Error('[conrad.killJob] Job "' + v1 + '" not found.');

    // If none of those cases, throw an error:
    } else
      throw new Error('[conrad.killJob] Wrong arguments.');

    return this;
  }
function _killJob(v1) {
    var i,
        l,
        k,
        a,
        job,
        found = false;

    // Array of job ids:
    if (Array.isArray(v1))
      for (i = 0, l = v1.length; i < l; i++)
        _killJob(v1[i]);

    // One job's id:
    else if (typeof v1 === 'string') {
      a = [_runningJobs, _waitingJobs, _jobs];

      // Remove the job from the hashes:
      for (i = 0, l = a.length; i < l; i++)
        if (v1 in a[i]) {
          job = a[i][v1];

          if (_parameters.history) {
            job.status = 'done';
            _doneJobs.push(job);
          }

          _dispatch('jobEnded', __clone(job));
          delete a[i][v1];

          if (typeof job.end === 'function')
            job.end();

          found = true;
        }

      // Remove the priorities array:
      a = _sortedByPriorityJobs;
      for (i = 0, l = a.length; i < l; i++)
        if (a[i].id === v1) {
          a.splice(i, 1);
          break;
        }

      if (!found)
        throw new Error('[conrad.killJob] Job "' + v1 + '" not found.');

    // If none of those cases, throw an error:
    } else
      throw new Error('[conrad.killJob] Wrong arguments.');

    return this;
  }
function _killJob ( v1 ) { var i , l , k , a , job , found = false ; // Array of job ids: if ( Array . isArray ( v1 ) ) for ( i = 0 , l = v1 . length ; i < l ; i ++ ) _killJob ( v1 [ i ] ) ; // One job's id: else if ( typeof v1 === 'string' ) { a = [ _runningJobs , _waitingJobs , _jobs ] ; // Remove the job from the hashes: for ( i = 0 , l = a . length ; i < l ; i ++ ) if ( v1 in a [ i ] ) { job = a [ i ] [ v1 ] ; if ( _parameters . history ) { job . status = 'done' ; _doneJobs . push ( job ) ; } _dispatch ( 'jobEnded' , __clone ( job ) ) ; delete a [ i ] [ v1 ] ; if ( typeof job . end === 'function' ) job . end ( ) ; found = true ; } // Remove the priorities array: a = _sortedByPriorityJobs ; for ( i = 0 , l = a . length ; i < l ; i ++ ) if ( a [ i ] . id === v1 ) { a . splice ( i , 1 ) ; break ; } if ( ! found ) throw new Error ( '[conrad.killJob] Job "' + v1 + '" not found.' ) ; // If none of those cases, throw an error: } else throw new Error ( '[conrad.killJob] Wrong arguments.' ) ; return this ; }
Kills one or more jobs, indicated by their ids. It is only possible to
kill running jobs or waiting jobs. If you try to kill a job that does not
exist or that is already killed, a warning will be thrown.

@param  {Array|String} v1 A string job id or an array of job ids.
@return {Object}       Returns conrad.
Kills one or more jobs indicated by their ids . It is only possible to kill running jobs or waiting jobs . If you try to kill a job that does not exist or that is already killed a warning will be thrown .