diff --git a/lib/handlers/run.js b/lib/handlers/run.js index 1e0306d..ede7f0b 100644 --- a/lib/handlers/run.js +++ b/lib/handlers/run.js @@ -66,7 +66,7 @@ function run(req, res, next, options) { // now that we've got the set of keys/blocks we want to run, use vasync // to coordinate running each block. - vasync.forEachPipeline({ + return vasync.forEachPipeline({ func: function runHandlerBlock(blockKey, blockCb) { // use a logger if present, otherwise fall back on default logger. diff --git a/lib/helpers.js b/lib/helpers.js index a66a412..8097ef1 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -18,7 +18,7 @@ function sortNumericalKeys(obj) { }) .value() .sort(function(a, b) { - return a > b; + return a - b; }); } diff --git a/lib/index.js b/lib/index.js index b4eef21..a5f01a7 100644 --- a/lib/index.js +++ b/lib/index.js @@ -64,7 +64,7 @@ function installConductor(method, opts, server, conductor) { applyArgs = [opts].concat(handlers); // now install the route - server[method].apply(server, applyArgs); + return server[method].apply(server, applyArgs); } diff --git a/test/ConductorSpec.js b/test/ConductorSpec.js index 0169194..c6abeea 100644 --- a/test/ConductorSpec.js +++ b/test/ConductorSpec.js @@ -372,11 +372,14 @@ describe('Restify Conductor', function() { b: 2 }, numbers: [4, 5, 6] - }, function mergeCustomizer(a, b) { + }, + /* eslint-disable consistent-return */ + function mergeCustomizer(a, b) { if (_.isArray(a)) { return a.concat(b); } }); + /* eslint-enable consistent-return */ } }); diff --git a/test/HelperSpec.js b/test/HelperSpec.js index 131e52f..c852ed8 100644 --- a/test/HelperSpec.js +++ b/test/HelperSpec.js @@ -73,4 +73,25 @@ describe('Helpers', function() { var sorted = h.sortNumericalKeys(obj); assert.deepEqual(sorted, [1, 5, 15, 20]); }); + + it('should sort keys of arrays of object', function() { + var obj = { + 10: [], + 20: [], + 30: [], + 40: [], + 50: [], + 51: [], + 53: [], + 60: [], + 65: [], + 70: [], + 100: [] + }; + var sorted = h.sortNumericalKeys(obj); + assert.deepEqual( + sorted, + [10, 20, 30, 40, 50, 51, 53, 60, 65, 70, 100] + ); + }); });