From c86635b4ce90a261e6aca183ee47831738a546f5 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Fri, 11 Apr 2014 02:32:43 -0400 Subject: [PATCH] making changes for compatibility with 9d405812cb7fa5368c55b8632dff070b2bcabbcc --- src/database/level/sorted.js | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/database/level/sorted.js b/src/database/level/sorted.js index 443644bcfc..cf99182286 100644 --- a/src/database/level/sorted.js +++ b/src/database/level/sorted.js @@ -55,35 +55,25 @@ module.exports = function(db, module) { }); }; - module.getSortedSetRangeByScore = function(args, callback) { - var key = args[0], - max = (args[1] === '+inf') ? Number.MAX_VALUE : args[1], - min = (args[2] === '-inf') ? Number.MIN_VALUE : args[2], - start = args[4], - count = args[5]; - - + module.getSortedSetRangeByScore = function(key, start, count, min, max, callback) { module.getListRange(key, 0, -1, function(err, list) { - list.filter(function(a) { - return a.score >= min && a.score <= max; // to check: greater or and equal? - }); + if (min && max) { + list.filter(function(a) { + return a.score >= min && a.score <= max; // to check: greater or and equal? + }); + } flattenSortedSet(list.slice(start ? start : 0, count ? count : list.length), callback); }); }; - module.getSortedSetRevRangeByScore = function(args, callback) { - var key = args[0], - max = (args[1] === '+inf') ? Number.MAX_VALUE : args[1], - min = (args[2] === '-inf') ? Number.MIN_VALUE : args[2], - start = args[4], - count = args[5]; - - + module.getSortedSetRevRangeByScore = function(key, start, count, max, min, callback) { module.getListRange(key, 0, -1, function(err, list) { - list.filter(function(a) { - return a.score >= min && a.score <= max; // to check: greater or and equal? - }); + if (min && max) { + list.filter(function(a) { + return a.score >= min && a.score <= max; // to check: greater or and equal? + }); + } flattenSortedSet(list.slice(start ? start : 0, count ? count : list.length).reverse(), callback); });