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

Function allNonemptySubsetsOf

test/fixtures/wpt/WebCryptoAPI/util/helpers.js:48–67  ·  view source on GitHub ↗
(arr)

Source from the content-addressed store, hash-verified

46//
47// The order of members of the "subsets" is not guaranteed.
48function allNonemptySubsetsOf(arr) {
49 var results = [];
50 var firstElement;
51 var remainingElements;
52
53 for(var i=0; i<arr.length; i++) {
54 firstElement = arr[i];
55 remainingElements = arr.slice(i+1);
56 results.push([firstElement]);
57
58 if (remainingElements.length > 0) {
59 allNonemptySubsetsOf(remainingElements).forEach(function(combination) {
60 combination.push(firstElement);
61 results.push(combination);
62 });
63 }
64 }
65
66 return results;
67}
68
69
70// Create a string representation of keyGeneration parameters for

Callers 1

allValidUsagesFunction · 0.85

Calls 3

sliceMethod · 0.65
forEachMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected