From 0b45036bce3462ac1a4b0fa172bcb681ccc152c0 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 24 Sep 2014 13:15:45 +0100 Subject: [PATCH] flatten non-IO bound code --- controller/suggest.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/controller/suggest.js b/controller/suggest.js index 7907f462..e11608c3 100644 --- a/controller/suggest.js +++ b/controller/suggest.js @@ -29,15 +29,13 @@ function setup( backend, query ){ } // convert docs to geojson - geoJsonifyDocs( docs, function( geojson ){ + var geojson = geoJsonifyDocs( docs ); - // response envelope - geojson.date = new Date().getTime(); + // response envelope + geojson.date = new Date().getTime(); - // respond - return res.status(200).json( geojson ); - - }); + // respond + return res.status(200).json( geojson ); }); } @@ -45,7 +43,7 @@ function setup( backend, query ){ return controller; } -function geoJsonifyDocs( docs, cb ){ +function geoJsonifyDocs( docs ){ // emit a warning if the doc format is invalid // @note: if you see this error, fix it ASAP! @@ -82,7 +80,7 @@ function geoJsonifyDocs( docs, cb ){ }); // convert to geojson - GeoJSON.parse( geodata, { Point: ['lat', 'lng'] }, cb ); + return GeoJSON.parse( geodata, { Point: ['lat', 'lng'] } ); } module.exports = setup; \ No newline at end of file