All files / src/count Iterator.count.js

100% Statements 7/7
100% Branches 2/2
100% Functions 1/1
100% Lines 7/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15      18x 14x 3x   11x 11x 25x   11x      
import Iterator from '../iterators/Iterator';
import '../where';
 
Iterator.prototype.count = function count(condition) {
  if (condition) {
    return this.where(condition).count();
  } else {
    let count = 0;
    for (let item of this) {
      count++;
    }
    return count;
  }
};