src/spider.js
function addUrl(when, feed) {
  if (!types.check(feed, 'feed') && !types.check(feed, ['feed']))
    throw Error('sandcrawler.spider.url(s): wrong argument.');

  var a = !(feed instanceof Array) ? [feed] : feed,
      c = !this.state.running ? this.initialBuffer.length : this.index,
      job,
      i,
      l;

  for (i = 0, l = a.length; i < l; i++) {
    job = createJob(a[i]);

    // Don't add if already at limit
    if (this.options.limit && c >= this.options.limit)
      break;

    if (!this.state.running) {
      this.initialBuffer[when === 'later' ? 'push' : 'unshift'](job);
    }
    else {
      this.queue[when === 'later' ? 'push' : 'unshift'](job);
      this.emit('job:add', job);
    }
  }

  return this;
}
function addUrl(when, feed) {
  if (!types.check(feed, 'feed') && !types.check(feed, ['feed']))
    throw Error('sandcrawler.spider.url(s): wrong argument.');

  var a = !(feed instanceof Array) ? [feed] : feed,
      c = !this.state.running ? this.initialBuffer.length : this.index,
      job,
      i,
      l;

  for (i = 0, l = a.length; i < l; i++) {
    job = createJob(a[i]);

    // Don't add if already at limit
    if (this.options.limit && c >= this.options.limit)
      break;

    if (!this.state.running) {
      this.initialBuffer[when === 'later' ? 'push' : 'unshift'](job);
    }
    else {
      this.queue[when === 'later' ? 'push' : 'unshift'](job);
      this.emit('job:add', job);
    }
  }

  return this;
}
function addUrl ( when , feed ) { if ( ! types . check ( feed , 'feed' ) && ! types . check ( feed , [ 'feed' ] ) ) throw Error ( 'sandcrawler.spider.url(s): wrong argument.' ) ; var a = ! ( feed instanceof Array ) ? [ feed ] : feed , c = ! this . state . running ? this . initialBuffer . length : this . index , job , i , l ; for ( i = 0 , l = a . length ; i < l ; i ++ ) { job = createJob ( a [ i ] ) ; // Don't add if already at limit if ( this . options . limit && c >= this . options . limit ) break ; if ( ! this . state . running ) { this . initialBuffer [ when === 'later' ? 'push' : 'unshift' ] ( job ) ; } else { this . queue [ when === 'later' ? 'push' : 'unshift' ] ( job ) ; this . emit ( 'job:add' , job ) ; } } return this ; }
Feeding the spider
Feeding the spider