diff --git a/app/js/filters/list-filters.js b/app/js/filters/list-filters.js index 28db718..5ef0c7e 100644 --- a/app/js/filters/list-filters.js +++ b/app/js/filters/list-filters.js @@ -3,36 +3,64 @@ var filtersModule = require('./_index.js'); var split = function(input, delim) { + if (typeof input === 'undefined' || input === null) { + return []; + } + delim = delim || ','; return input.split(delim); }; var join = function(input, delim) { + if (typeof input === 'undefined' || input === null) { + return ''; + } + delim = delim || ', '; return input.join(delim); }; var pick = function(input, index) { + if (typeof input === 'undefined' || input === null) { + return ''; + } + return input[index]; }; var pickRight = function(input, index) { + if (typeof input === 'undefined' || input === null) { + return ''; + } + return input[input.length - index]; }; var slice = function(input, begin, end) { + if (typeof input === 'undefined' || input === null) { + return []; + } + return input.slice(begin, end); }; var first = function(input, length) { + if (typeof input === 'undefined' || input === null) { + return ''; + } + length = length || 1; return input.slice(0, input.length - length); }; var last = function(input, length) { + if (typeof input === 'undefined' || input === null) { + return ''; + } + length = length || 1; return input.slice(input.length - length, input.length);