diff --git a/core/modules/filters/x-listops.js b/core/modules/filters/x-listops.js index dc290a42e..ca04b0e2b 100644 --- a/core/modules/filters/x-listops.js +++ b/core/modules/filters/x-listops.js @@ -187,4 +187,19 @@ Extended filter operators to manipulate the current list. }, []); return set; }; + + /* + Toggles an item in the current list. + */ + exports.toggle = function(source, operator) { + var results = prepare_results(source), + index = results.indexOf(operator.operand); + if(index === -1) { + results.push(operator.operand); + } else { + results.splice(index, 1); + } + return results; + }; + })();