From 0d175d3eeb506e834e3b5653ff2d8d3552569988 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Mon, 19 Nov 2012 12:55:04 +0000 Subject: [PATCH] New utility method Surprising that this seems to be the recommended approach --- core/modules/utils/utils.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/modules/utils/utils.js b/core/modules/utils/utils.js index a529369c9..becb70e2d 100644 --- a/core/modules/utils/utils.js +++ b/core/modules/utils/utils.js @@ -12,6 +12,15 @@ Various static utility functions. /*global $tw: false */ "use strict"; +/* +Return the number of keys in an object +*/ +exports.count = function(object) { + var s = 0; + $tw.utils.each(object,function() {s++;}); + return s; +}; + /* Push entries onto an array, removing them first if they already exist in the array array: array to modify