2 * Utils used by RecentChanges Filters.
4 * @namespace rcfilters.utils
10 * @param {Node[]|Node} elements
13 addArrayElementsUnique: function ( arr, elements ) {
14 elements = Array.isArray( elements ) ? elements : [ elements ];
16 elements.forEach( ( element ) => {
17 if ( arr.indexOf( element ) === -1 ) {
25 * @param {string[]} givenOptions
26 * @param {string[]} legalOptions
27 * @param {boolean} [supportsAll] defaults to true.
30 normalizeParamOptions: function ( givenOptions, legalOptions, supportsAll ) {
32 supportsAll = supportsAll === undefined ? true : !!supportsAll;
34 if ( supportsAll && givenOptions.indexOf( 'all' ) > -1 ) {
35 // If anywhere in the values there's 'all', we
36 // treat it as if only 'all' was selected.
37 // Example: param=valid1,valid2,all
42 // Get rid of any dupe and invalid parameter, only output
44 // Example: param=valid1,valid2,invalid1,valid1
45 // Result: param=valid1,valid2
46 givenOptions.forEach( ( value ) => {
48 legalOptions.indexOf( value ) > -1 &&
49 result.indexOf( value ) === -1