MCPcopy Create free account
hub / github.com/nodejs/node / allValidUsages

Function allValidUsages

test/fixtures/wpt/WebCryptoAPI/util/helpers.js:237–262  ·  view source on GitHub ↗
(validUsages, emptyIsValid, mandatoryUsages)

Source from the content-addressed store, hash-verified

235// it should be an array containing those usages of which one must be
236// included.
237function 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
264function unique(names) {
265 return [...new Set(names)];

Callers 11

invalidUsagesFunction · 0.85
run_testFunction · 0.85
run_testFunction · 0.85
runTestsFunction · 0.85
invalidUsagesFunction · 0.85
run_testFunction · 0.85
runTestsFunction · 0.85
runTestsFunction · 0.85
runTestsFunction · 0.85

Calls 5

allNonemptySubsetsOfFunction · 0.85
includesMethod · 0.80
concatMethod · 0.80
forEachMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected