src/resource/index.js
/**
 * Check resource on presence or absence of specified tags.
 * 
 * @param {Object} resource
 *      Represents data about a resource that should be checked.
 * @param {Array} tagList
 *      List of tags (in lower case) that should be checked on presence or absence in resource tags.
 *      Tag in form "name" (without quotes; a positive tag) means that resource should be checked on presence of "name" tag.
 *      Tag in form "-name" (without quotes; a negative tag) means that resource should be checked on absence of "name" tag.
 * @param {Boolean} [checkAllTags]
 *      Whether all tags specified in <code>tagList</code> should be checked on presence/absence in resource tags.
 *      When parameter has <code>true</code> value it means that resource should have all positive tags 
 *      and should not have any negative tag.
 *      When parameter has <code>false</code> value (by default) it means that resource should have one of positive tags 
 *      and should not have one of negative tags.
 * @return {Boolean}
 *      <code>true</code> if resource tags satisfy to specified tags (depending on <code>checkAllTags</code> value),
 *      <code>false</code> otherwise.
 * @alias module:resource.checkResourceTags
 */
Check resource on presence or absence of specified tags.

@param {Object} resource
Represents data about a resource that should be checked.
@param {Array} tagList
List of tags (in lower case) that should be checked on presence or absence in resource tags.
Tag in form "name" (without quotes; a positive tag) means that resource should be checked on presence of "name" tag.
Tag in form "-name" (without quotes; a negative tag) means that resource should be checked on absence of "name" tag.
@param {Boolean} [checkAllTags]
Whether all tags specified in tagList should be checked on presence/absence in resource tags.
When parameter has true value it means that resource should have all positive tags
and should not have any negative tag.
When parameter has false value (by default) it means that resource should have one of positive tags
and should not have one of negative tags.
@return {Boolean}
true if resource tags satisfy to specified tags (depending on checkAllTags value),
false otherwise.
Check resource on presence or absence of specified tags . @param { Object } resource Represents data about a resource that should be checked . @param { Array } tagList List of tags ( in lower case ) that should be checked on presence or absence in resource tags . Tag in form " name " ( without quotes ; a positive tag ) means that resource should be checked on presence of " name " tag . Tag in form " - name " ( without quotes ; a negative tag ) means that resource should be checked on absence of " name " tag . @param { Boolean } [ checkAllTags ] Whether all tags specified in tagList should be checked on presence / absence in resource tags . When parameter has true value it means that resource should have all positive tags and should not have any negative tag . When parameter has false value ( by default ) it means that resource should have one of positive tags and should not have one of negative tags . @return { Boolean } true if resource tags satisfy to specified tags ( depending on checkAllTags value ) false otherwise .
function checkResourceTags(resource, tagList, checkAllTags) {
    var resTags = resource.tag,
        nL = tagList.length,
        nAbsent = 0,
        nAbsentMatch = 0,
        nPresent = 0,
        nPresentMatch = 0,
        nI, sTag;
    for (nI = 0; nI < nL; nI++) {
        sTag = tagList[nI];
        if (sTag.charAt(0) === "-") {
            nAbsent++;
            sTag = sTag.substring(1);
            if (resTags.indexOf(sTag) === -1) {
                nAbsentMatch++;
            }
        }
        else {
            nPresent++;
            if (resTags.indexOf(sTag) > -1) {
                nPresentMatch++;
            }
        }
        if (! checkAllTags && nPresentMatch && nAbsentMatch) {
            return true;
        }
    }
    return checkAllTags
            ? (nPresent === nPresentMatch && nAbsent === nAbsentMatch)
            : Boolean((! nPresent || nPresentMatch) && (! nAbsent || nAbsentMatch));
}
function checkResourceTags ( resource , tagList , checkAllTags ) { var resTags = resource . tag , nL = tagList . length , nAbsent = 0 , nAbsentMatch = 0 , nPresent = 0 , nPresentMatch = 0 , nI , sTag ; for ( nI = 0 ; nI < nL ; nI ++ ) { sTag = tagList [ nI ] ; if ( sTag . charAt ( 0 ) === "-" ) { nAbsent ++ ; sTag = sTag . substring ( 1 ) ; if ( resTags . indexOf ( sTag ) === - 1 ) { nAbsentMatch ++ ; } } else { nPresent ++ ; if ( resTags . indexOf ( sTag ) > - 1 ) { nPresentMatch ++ ; } } if ( ! checkAllTags && nPresentMatch && nAbsentMatch ) { return true ; } } return checkAllTags ? ( nPresent === nPresentMatch && nAbsent === nAbsentMatch ) : Boolean ( ( ! nPresent || nPresentMatch ) && ( ! nAbsent || nAbsentMatch ) ) ; }
Check resource on presence or absence of specified tags.
Check resource on presence or absence of specified tags .
/*jshint laxbreak:true*/