(validUsages, emptyIsValid, mandatoryUsages)
| 235 | // it should be an array containing those usages of which one must be |
| 236 | // included. |
| 237 | function allValidUsages(validUsages, emptyIsValid, mandatoryUsages) { |
| 238 | if (typeof mandatoryUsages === "undefined") { |
| 239 | mandatoryUsages = []; |
| 240 | } |
| 241 | |
| 242 | var okaySubsets = []; |
| 243 | allNonemptySubsetsOf(validUsages).forEach(function(subset) { |
| 244 | if (mandatoryUsages.length === 0) { |
| 245 | okaySubsets.push(subset); |
| 246 | } else { |
| 247 | for (var i=0; i<mandatoryUsages.length; i++) { |
| 248 | if (subset.includes(mandatoryUsages[i])) { |
| 249 | okaySubsets.push(subset); |
| 250 | return; |
| 251 | } |
| 252 | } |
| 253 | } |
| 254 | }); |
| 255 | |
| 256 | if (emptyIsValid && validUsages.length !== 0) { |
| 257 | okaySubsets.push([]); |
| 258 | } |
| 259 | |
| 260 | okaySubsets.push(validUsages.concat(mandatoryUsages).concat(validUsages)); // Repeated values are allowed |
| 261 | return okaySubsets; |
| 262 | } |
| 263 | |
| 264 | function unique(names) { |
| 265 | return [...new Set(names)]; |
no test coverage detected