/*</jdists> 
突出显示错误的代码行

@param {Array} buffer 从开始位置到错误位置的代码行
@param {number} count 样本行数
172866
function lightcode(buffer, count) {
    var len = buffer.length.toString().length;
    var lines = buffer.slice(-count);
    for (var i = lines.length - 1; i >= 0; i--) {
      var l = (buffer.length + i - lines.length + 1).toString();
      l = (new Array(len - l.length + 1)).join(' ') + l; // 前面补空格
      lines[i] = l + (i === lines.length - 1 ? ' > ' : '   ') + '| ' + lines[i];
    }
    console.log(lines.join('\n'));
  }
346454
function count(req, res) {
  var list = getList.call(this);
  return res.send(null, list.length);
}
1051970
function(job, done) {
                var MAX_COUNT = 5;
                var count = 0;
                
                Async.whilst(
                    // Loop for N times
                    function() { return MAX_COUNT > count; },
                    // Every second, ask for preview results
                    function(iterationDone) {
                        Async.sleep(1000, function() {
                            job.preview({}, function(err, results) {
                                if (err) {
                                    iterationDone(err);
                                    return;
                                }
                                
                                // Only do something if we have results
                                if (results && results.rows) {
                                    // Up the iteration counter
                                    count++;
                                    
                                    console.log("========== Iteration " + count + " ==========");
                                    var sourcetypeIndex = results.fields.indexOf("sourcetype");
                                    var countIndex = results.fields.indexOf("count");
                                    
                                    for(var i = 0; i < results.rows.length; i++) {
                                        var row = results.rows[i];
                                        
                                        // This is a hacky "padding" solution
                                        var stat = ("  " + row[sourcetypeIndex] + "                         ").slice(0, 30);
                                        
                                        // Print out the sourcetype and the count of the sourcetype so far
                                        console.log(stat + row[countIndex]);   
                                    }
                                    
                                    console.log("=================================");
                                }
                                    
                                // And we're done with this iteration
                                iterationDone();
                            });
                        });
                    },
                    // When we're done looping, just cancel the job
                    function(err) {
                        job.cancel(done);
                    }
                );
            }
1162906
function(count) {
                var _count = count;
                var ctxArgs = Array.prototype.slice.call(arguments, 1);

                // If the step count is zero, resolve immediately.
                if (_count === 0) {
                    deferredObject.resolve.apply(null, ctxArgs);
                }

                return {
                    /*
                     * Indicates that a specific step was completed. The
                     * promise will be treated as resolved if this method
                     * is invoked a given number of times.
                     */
                    stepComplete: function() {
                        var ca
                        _count--;
                        if (_count === 0) {
                            var args = Array.prototype.slice.call(arguments, 0);
                            deferredObject.resolve.apply(null,
                                ctxArgs.concat(args));
                        }
                    },

                    /*
                     * Rejects the deferred object without waiting for any
                     * further processing.
                     */
                    reject: function() {
                        var args = Array.prototype.slice.call(arguments, 0);
                        deferredObject.reject.apply(null, ctxArgs.concat(args));
                    }
                }
            }
924772
function(regex) {
  var self = this; var re = new RegExp(regex);
  var keys = {};
  self.init = function() { keys = {}; };
  self.accumulate = function(line) {
    var m = re.exec(line);
    if (m == null) return;
    var k = m[1]; // use 1st group as key
    var v = keys[k];
    if (v) keys[k] = v+1; else keys[k] = 1; // count by key
  };
  self.compensate = function(line) {
    var m = re.exec(line);
    if (m == null) return;
    var k = m[1]; // use 1st group as key
    var v = keys[k];
    if (v) keys[k] = v-1; else keys[k] = 1;
  };
  self.emit = function() {
    return keys;
  };
  self.make = function() { return new WideFinderFunction(regex); };
}
1010650
function(count, direction) {
      return direction ? this.concat(this.splice(0, count)) : this.splice(this.length - count).concat(this);
    }
681430
function Delete (count, position) {
    if (!this || this.constructor !== SimpleTextOperation) {
      return new Delete(count, position);
    }
    this.count = count;
    this.position = position;
  }
332719
function(queueCount) {
    var self = this;
    this.queueCount = queueCount;
    this.emitter = new EventEmitter();
    this.processedCount = 0;

    // we assume the queue count is 1
    // if developer pass no `queueCount`
    // param
    if(undefined === queueCount) {
        this.queueCount = 1;
    }

    // The listener of task done
    this.emitter.on("done", function(queueId, debugStr) {
        queueId = parseInt(queueId);
        if(isNaN(queueId)) return;
        if(queueId >= self.queueCount || queueId < 0) return;

        if(debugStr) {
            var logStr = "( Done: ";
            for(var i = 0; i < self.queue.length; i++) {
                if(i !== 0) logStr += ", ";
                logStr += "[" + self.queue[i].length + "]";
            }
            logStr += " )";
            console.log(logStr);
        }

        nextTick(function() {
            self._runTask(queueId);
        });
    });

    // initialize the tast queue into a
    // two-dimensional array
    this.queue = [];
    this.running = [];
    for(var i = 0; i < this.queueCount; i++) {
        this.queue.push([]);
        this.running.push(false);
    }

    // after finish
    this.afterFinishCount = -1;
    this.afterFinishLoop = false;
    this.afterFinishProcessor = undefined;
}
1095885
private void _advance(int count) {
        if (buf != null) {
            bufPos += count;
            if (bufPos == buf.length) {
                buf = null;
            }
        } else {
            pos.setIndex(pos.getIndex() + count);
            if (pos.getIndex() > text.length()) {
                pos.setIndex(text.length());
            }
        }
    }
126501
function countLines (str) {
  if (str) {
    let lines = str.match(/\n/g);
    if (lines) {
      return lines.length;
    }
  }
  return 0;
}
1017476
function qParallel(funcs, count) {
    var length = funcs.length;
    if (!length) {
        return q([]);
    }

    if (count == null) {
        count = Infinity;
    }

    count = Math.max(count, 1);
    count = Math.min(count, funcs.length);

    var promises = [];
    var values = [];
    for (var i = 0; i < count; ++i) {
        var promise = funcs[i]();
        promise = promise.then(next(i));
        promises.push(promise);
    }

    return q.all(promises).then(function () {
        return values;
    });

    function next(i) {
        return function (value) {
            if (i == null) {
                i = count++;
            }

            if (i < length) {
                values[i] = value;
            }

            if (count < length) {
                return funcs[count]().then(next())
            }
        }
    }
}
194886
function fold(count, buf)
{
  if(!count || buf.length % 2) return buf;
  var ret = buf.slice(0,buf.length/2);
  for(i = 0; i < ret.length; i++) ret[i] = ret[i] ^ buf[i+ret.length];
  return fold(count-1,ret);
}
402547
function processBuffer(buffer) {
      if (!outputJSON.buffers) {
        outputJSON.buffers = [{ byteLength: 0 }];
      }

      // All buffers are merged before export.
      buffers.push(buffer);

      return 0;
    }
616766
public ScanParams count(final Integer count) {
    params.put(COUNT, ByteBuffer.wrap(Protocol.toByteArray(count)));
    return this;
  }
382147
function buffer_array_loop_firstSubRule (buf, str) {
	// Common properties
	this.idx = -1
	this.length = 1
	this.next = lastSubRule
	// Specific properties
	this.buf = buf
	this.str = str
}
450035
function List(runner) {
  Base.call(this, runner);

  var self = this
    , stats = this.stats
    , total = runner.total;

  runner.on('start', function(){
    console.log(JSON.stringify(['start', { total: total }]));
  });

  runner.on('pass', function(test){
    console.log(JSON.stringify(['pass', clean(test)]));
  });

  runner.on('fail', function(test, err){
    console.log(JSON.stringify(['fail', clean(test)]));
  });

  runner.on('end', function(){
    process.stdout.write(JSON.stringify(['end', self.stats]));
  });
}
49572
function after(count, callback) {
    var countdown = count;

    return function shim(err) {
        if (typeof callback !== 'function') return;

        if (err) {
            callback(err);
            callback = null;
            return;
        }

        if (--countdown === 0) {
            callback();
            callback = null;
        }
    };
}