// Filter advanced topics, services, parameters by checking the beginning capital letter
angular.module('roscc')
    .factory('Domains', function() {
        return {
            filterAdvanced: function(entry, advanced) {
                if (advanced) {
                    return true;
                }

                var split = entry.split('/');
                if (split.length < 1) {
                    return false;
                }

                return (split[split.length - 1][0] == split[split.length - 1][0].toUpperCase());
            },
            getDomains: function(array) {
                var result = [];
                array.forEach(function(entry) {
                    var split = entry.name.split('/');
                    if (split.length > 1) {
                        result.push(split[1]);
                    }
                });
                return _.uniq(result).sort();
            },
            getGlobalParameters: function(array) {
                var result = [];
                array.forEach(function(entry) {
                    var split = entry.name.split('/');
                    if (split.length == 2) {
                        entry.abbr = split[split.length - 1];
                        result.push(entry);
                    }
                });
                return result;
            },
            getDataForDomain: function(array, domainName) {
                var result = [];
                array.forEach(function(entry) {
                    var split = entry.name.split('/');
                    if (split.length > 1) {
                        if (split[1] == domainName) {
                            entry.abbr = split.slice(2).join(' ');
                            result.push(entry);
                        }
                    }
                });
                return result;
            },
        };
    });
// Filter advanced topics, services, parameters by checking the beginning capital letter
angular.module('roscc')
    .factory('Domains', function() {
        return {
            filterAdvanced: function(entry, advanced) {
                if (advanced) {
                    return true;
                }

                var split = entry.split('/');
                if (_.isEmpty(split)) {
                    return false;
                }

                return (_.last(split)[0] == _.last(split)[0].toUpperCase());
            },
            getDomains: function(array) {
                var result = _.filter(array, function(entry) {
                    return (entry.name.split('/').length > 1);
                });
                return _.uniq(result).sort();
            },
            getGlobalParameters: function(array) {
                return _.filter(array, function(entry) {
                    var split = entry.name.split('/');
                    entry.abbr = _.last(split);
                    return (split.length == 2);
                });
            },
            getDataForDomain: function(array, domainName) {
                return _.filter(array, function(entry) {
                    var split = entry.name.split('/');
                    entry.abbr = split.slice(2).join(' ');
                    return (split.length > 1 && split[1] == domainName);
                });
            },
        };
    });
make usage of underscore