From 88b428cb4d328ff6aa9c7586c9f91d07cddcf42b Mon Sep 17 00:00:00 2001 From: rxi Date: Sat, 5 Apr 2014 12:21:36 +0100 Subject: [PATCH] Added lume.count() to README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index b195215..4239ffc 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,14 @@ Returns the value and key of the value in table `t` which returns true when lume.match({1, 5, 8, 7}, function(x) return x % 2 == 0 end) -- Returns 8, 3 ``` +### lume.count(t [, fn]) +Counts the number of values in the table `t`. If a `fn` function is supplied it +is called on each value, the number of times it returns true is counted. +```lua +lume.count({a = 2, b = 3, c = 4, d = 5}) -- Returns 4 +lume.count({1, 2, 4, 6}, function(x) return x % 2 == 0 end) -- Returns 3 +``` + ### lume.slice(t [, i [, j]]) Mimics the behaviour of Lua's `string.sub`, but operates on an array rather than a string. Creates and returns a new array of the given slice.