Skip to content

Commit

Permalink
count()
Browse files Browse the repository at this point in the history
  • Loading branch information
balpha committed Feb 24, 2012
1 parent 28d537d commit cc89256
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lyfe.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@
Yield(arr[index]);
});
});
},
count: function () {
var result = 0;
this.forEach(function () { result++; });
return result;
}
}

Expand Down
7 changes: 7 additions & 0 deletions test.html
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,13 @@
good = good && Generator([-3, -7, 0]).all(function (x) { return x <= 0; });
return good;
});

test("count", function () {
var good = Generator(a).count() === 5 && Generator([]).count() === 0;
var withHole = [1,2,3,,4];
return good && Generator(withHole).count() === 4;
})

</script>


Expand Down

0 comments on commit cc89256

Please sign in to comment.