From f916e697173c4f4348c45f54bc20bb7c3f42996b Mon Sep 17 00:00:00 2001 From: Louis Chatriot Date: Sat, 9 Jan 2016 09:43:28 +0100 Subject: [PATCH] Use my style in getMatching --- lib/indexes.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/indexes.js b/lib/indexes.js index bb6119b..09952fb 100755 --- a/lib/indexes.js +++ b/lib/indexes.js @@ -236,14 +236,12 @@ Index.prototype.revertUpdate = function (oldDoc, newDoc) { * @return {Array of documents} */ Index.prototype.getMatching = function (value) { - var _res, res - , self = this; + var self = this; if (!util.isArray(value)) { - res = self.tree.search(value); + return self.tree.search(value); } else { - _res = {}; - res = []; + var _res = {}, res = []; value.forEach(function (v) { self.getMatching(v).forEach(function (doc) { @@ -254,8 +252,9 @@ Index.prototype.getMatching = function (value) { Object.keys(_res).forEach(function (_id) { res.push(_res[_id]); }); + + return res; } - return res; };