'use strict';

angular.module('app')
	.filter('filterStringsByStartsWith', function($log) {
		return function(stringArray, keyword) {
			if (!stringArray) {
				return [];
			}
			if (!keyword || keyword === '') {
				return stringArray;
			}
			return stringArray.filter(function(el) {
				if (!el.name) {
					$log.warn('There is a tag without name field');
				}
				return el.name && el.name.indexOf(keyword) === 0;
			});
		};
	});