src/includes/matchers.js
function sameParentChecker (preprocessFn) {
    return function (suggestions) {
        if (suggestions.length === 0) {
            return false;
        }
        if (suggestions.length === 1) {
            return true;
        }

        var parentValue = preprocessFn(suggestions[0].value),
            aliens = suggestions.filter(function (suggestion) {
                return preprocessFn(suggestion.value).indexOf(parentValue) !== 0;
            });

        return aliens.length === 0;
    }
}
function sameParentChecker (preprocessFn) {
    return function (suggestions) {
        if (suggestions.length === 0) {
            return false;
        }
        if (suggestions.length === 1) {
            return true;
        }

        var parentValue = preprocessFn(suggestions[0].value),
            aliens = suggestions.filter(function (suggestion) {
                return preprocessFn(suggestion.value).indexOf(parentValue) !== 0;
            });

        return aliens.length === 0;
    }
}
function sameParentChecker ( preprocessFn ) { return function ( suggestions ) { if ( suggestions . length === 0 ) { return false ; } if ( suggestions . length === 1 ) { return true ; } var parentValue = preprocessFn ( suggestions [ 0 ] . value ) , aliens = suggestions . filter ( function ( suggestion ) { return preprocessFn ( suggestion . value ) . indexOf ( parentValue ) !== 0 ; } ) ; return aliens . length === 0 ; } }
Factory to create same parent checker function
@param preprocessFn called on each value before comparison
@returns {Function} same parent checker function
Factory to create same parent checker function