cleanup...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-05-13 01:09:58 +03:00
parent d960b02466
commit 5d9bbcd713

View File

@ -35,17 +35,11 @@ var INDEX_DIR = '.ImageGrid'
/*********************************************************************/
// Queue
//
// Task
//
/*********************************************************************/ /*********************************************************************/
// helpers... // helpers...
// Skip nested indexes from tree...
//
var skipNested = function(paths, index_dir, logger){ var skipNested = function(paths, index_dir, logger){
paths = paths paths = paths
.map(function(p){ return p.split(index_dir).shift() }) .map(function(p){ return p.split(index_dir).shift() })
@ -91,14 +85,17 @@ function(glob){ return guaranteeEvents('match end', glob) }
var gGlob = var gGlob =
module.gGlob = function(){ module.gGlob = function(){
return guaranteeGlobEvents(glob.apply(null, arguments)) return guaranteeGlobEvents(glob.apply(null, arguments)) }
}
/*********************************************************************/ /*********************************************************************/
// Reader... // Reader...
// XXX would be nice to find a way to stop searching a sub tree as soon
// as a match is found.
// ...this would be allot faster than getting the whole tree and
// then pruning through like it is done now...
var listIndexes = var listIndexes =
module.listIndexes = module.listIndexes =
function(base, index_dir){ function(base, index_dir){
@ -116,6 +113,9 @@ function(base, index_dir, logger){
.on('error', function(err){ .on('error', function(err){
reject(err) reject(err)
}) })
.on('match', function(path){
logger && logger.emit('found', path)
})
.on('end', function(paths){ .on('end', function(paths){
// skip nested indexes... // skip nested indexes...
resolve(skipNested(paths, index_dir, logger)) resolve(skipNested(paths, index_dir, logger))
@ -677,7 +677,6 @@ function(){
} }
// Build a data and images objects from the json returned by loadIndex(..) // Build a data and images objects from the json returned by loadIndex(..)
// //
// Contrary to loadIndex(..) this expects a specific format of data: // Contrary to loadIndex(..) this expects a specific format of data:
@ -937,7 +936,6 @@ function(json, path, date, filename_tpl, logger){
/********************************************************************** /**********************************************************************
* vim:set ts=4 sw=4 : */ * vim:set ts=4 sw=4 : */
return module }) return module })