summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/controller/packages.js7
-rw-r--r--js/utils.js7
2 files changed, 11 insertions, 3 deletions
diff --git a/js/controller/packages.js b/js/controller/packages.js
index 89f01e9..d9e0839 100644
--- a/js/controller/packages.js
+++ b/js/controller/packages.js
@@ -61,9 +61,10 @@
};
controller.prototype.packageCount = function() {
- return this.pager().pages.reduce(function(memo, page) {
- return memo + page.length;
- }, 0);
+ return _.chain(this.pager().pages)
+ .pluck('length')
+ .reduce(guix.add, 0)
+ .value();
};
controller.prototype.doSearch = function() {
diff --git a/js/utils.js b/js/utils.js
index c44ee23..cfaa7fd 100644
--- a/js/utils.js
+++ b/js/utils.js
@@ -17,6 +17,13 @@
var guix = {};
+// Here is a perfect example of why Scheme is better than JavaScript:
+// + is an operator, not a function. So if I want to, say, compute
+// the sum of an array of numbers, I need to write a wrapper function.
+guix.add = function(x, y) {
+ return x + y;
+};
+
guix.clamp = function(n, min, max) {
return Math.max(Math.min(n, max), min);
};