function compareDirFiles(parentId, old_children, descendants){
    var changes = [],
        not_found = object.extend({}, old_children);
    
    for(var id in descendants) {
        if(descendants[id].ancestors[ descendants[id].ancestors.length-1 ] === parentId) { // compare only direct children
            
            if(!old_children[id]) { // not found in current children - created
                changes.push({ event:'created', file:descendants[id] });
                old_children[id] = descendants[id];
            }
            else if(old_children[id].modifiedDT < descendants[id].modifiedDT) { // found and updated
                changes.push({ event:'updated', file:descendants[id] });
                old_children[id] = descendants[id];
                delete not_found[id];
            }
            else { // file found, not not updated
                delete not_found[id];
            }
        }
    }
    
    // removed files
    for(var id in not_found) {
        changes.push({ event:'removed', file:not_found[id] });
        delete old_children[id];
    }
    
    return changes;
}
function compareDirFiles(parentId, old_children, descendants){
    var changes = [],
        not_found = object.extend({}, old_children);
    
    for(var id in descendants) {
        if(descendants[id].ancestors[ descendants[id].ancestors.length-1 ] === parentId) { 
            
            if(!old_children[id]) { 
                changes.push({ event:'created', file:descendants[id] });
                old_children[id] = descendants[id];
            }
            else if(old_children[id].modifiedDT < descendants[id].modifiedDT) { 
                changes.push({ event:'updated', file:descendants[id] });
                old_children[id] = descendants[id];
                delete not_found[id];
            }
            else { 
                delete not_found[id];
            }
        }
    }
    
    
    for(var id in not_found) {
        changes.push({ event:'removed', file:not_found[id] });
        delete old_children[id];
    }
    
    return changes;
}
function compareDirFiles ( parentId , old_children , descendants ) { var changes = [ ] , not_found = object . extend ( { } , old_children ) ; for ( var id in descendants ) { if ( descendants [ id ] . ancestors [ descendants [ id ] . ancestors . length - 1 ] === parentId ) { // compare only direct children if ( ! old_children [ id ] ) { // not found in current children - created changes . push ( { event : 'created' , file : descendants [ id ] } ) ; old_children [ id ] = descendants [ id ] ; } else if ( old_children [ id ] . modifiedDT < descendants [ id ] . modifiedDT ) { // found and updated changes . push ( { event : 'updated' , file : descendants [ id ] } ) ; old_children [ id ] = descendants [ id ] ; delete not_found [ id ] ; } else { // file found, not not updated delete not_found [ id ] ; } } } // removed files for ( var id in not_found ) { changes . push ( { event : 'removed' , file : not_found [ id ] } ) ; delete old_children [ id ] ; } return changes ; }
comparing old dir children and new dir children - executed on change event
@param {String} parentId directory id
@param {Object} old_children old directory children
@param {Object} descendants directory descendants
@returns {Array}  recognized changes
comparing old dir children and new dir children - executed on change event