How to use the js-combinatorics.permutationCombination function in js-combinatorics

To help you get started, we’ve selected a few js-combinatorics examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github namshi / mockserver / mockserver.js View on Github external
header = header.toLowerCase();
          if (req.headers[header]) {
            headers.push(
              '_' + normalizeHeader(header) + '=' + req.headers[header]
            );
          }
        });
      }

      // Now, permute the possible headers, and look for any matching files, prioritizing on
      // both # of headers and the original header order
      let matched,
        permutations = [[]];

      if (headers.length) {
        permutations = Combinatorics.permutationCombination(headers)
          .toArray()
          .sort(function(a, b) {
            return b.length - a.length;
          });
        permutations.push([]);
      }

      matched = getContentFromPermutations(
        path,
        method,
        body,
        query,
        permutations.slice(0)
      );

      if (!matched.content && (path = getWildcardPath(path))) {
github DefinitelyTyped / DefinitelyTyped / js-combinatorics / js-combinatorics-tests.ts View on Github external
combination.forEach((i:string[]) => console.log(i));
const combinationsLengths:number[] = combination.map((i:string[]) => i.length);
const filteredCombinations:string[][] = combination.filter((i:string[]) => i.length > 0);
const allCombinations:string[][] = combination.toArray();
const combinationsCount = combination.length;

const limitedPermutation = Combinatorics.permutation(["a", "b", "c"], 2);
const permutation = Combinatorics.permutation(["a", "b", "c"]);
const nextPermutation:string[] = permutation.next();
permutation.forEach((i:string[]) => console.log(i));
const permutationsLengths:number[] = permutation.map((i:string[]) => i.length);
const filteredPermutations:string[][] = permutation.filter((i:string[]) => i.length > 0);
const allPermutations:string[][] = permutation.toArray();
const permutationsCount = permutation.length;

const permutationCombination = Combinatorics.permutationCombination(["a", "b", "c"]);
const nextPermutationCombinations:string[] = permutationCombination.next();
permutationCombination.forEach((i:string[]) => console.log(i));
const permutationCombinationsLengths:number[] = permutationCombination.map((i:string[]) => i.length);
const filteredPermutationCombinationss:string[][] = permutationCombination.filter((i:string[]) => i.length > 0);
const allPermutationCombinationss:string[][] = permutationCombination.toArray();
const permutationCombinationsCount = permutationCombination.length;

const limitedBaseN = Combinatorics.baseN(["a", "b", "c"], 2);
const baseN = Combinatorics.baseN(["a", "b", "c"]);
const nextbaseN:string[] = baseN.next();
baseN.forEach((i:string[]) => console.log(i));
const baseNsLengths:number[] = baseN.map((i:string[]) => i.length);
const filteredbaseNs:string[][] = baseN.filter((i:string[]) => i.length > 0);
const allbaseNs:string[][] = baseN.toArray();
const baseNsCount = baseN.length;
const nthbaseN:string[] = baseN.nth(3);
github DefinitelyTyped / DefinitelyTyped / types / js-combinatorics / js-combinatorics-tests.ts View on Github external
bigCombination.forEach((i:string[]) => console.log(i));
const bigCombinationsLengths:number[] = bigCombination.map((i:string[]) => i.length);
const filteredBigCombinations:string[][] = bigCombination.filter((i:string[]) => i.length > 0);
const allBigCombinations:string[][] = bigCombination.toArray();
const bigCombinationsCount = bigCombination.length;

const limitedPermutation = Combinatorics.permutation(["a", "b", "c"], 2);
const permutation = Combinatorics.permutation(["a", "b", "c"]);
const nextPermutation:string[] = permutation.next();
permutation.forEach((i:string[]) => console.log(i));
const permutationsLengths:number[] = permutation.map((i:string[]) => i.length);
const filteredPermutations:string[][] = permutation.filter((i:string[]) => i.length > 0);
const allPermutations:string[][] = permutation.toArray();
const permutationsCount = permutation.length;

const permutationCombination = Combinatorics.permutationCombination(["a", "b", "c"]);
const nextPermutationCombinations:string[] = permutationCombination.next();
permutationCombination.forEach((i:string[]) => console.log(i));
const permutationCombinationsLengths:number[] = permutationCombination.map((i:string[]) => i.length);
const filteredPermutationCombinationss:string[][] = permutationCombination.filter((i:string[]) => i.length > 0);
const allPermutationCombinationss:string[][] = permutationCombination.toArray();
const permutationCombinationsCount = permutationCombination.length;

const limitedBaseN = Combinatorics.baseN(["a", "b", "c"], 2);
const baseN = Combinatorics.baseN(["a", "b", "c"]);
const nextbaseN:string[] = baseN.next();
baseN.forEach((i:string[]) => console.log(i));
const baseNsLengths:number[] = baseN.map((i:string[]) => i.length);
const filteredbaseNs:string[][] = baseN.filter((i:string[]) => i.length > 0);
const allbaseNs:string[][] = baseN.toArray();
const baseNsCount = baseN.length;
const nthbaseN:string[] = baseN.nth(3);
github avajs / eslint-plugin-ava / test / prefer-power-assert.js View on Github external
ruleTester.run('prefer-power-assert', rule, {
		valid: [
			{
				code: `import test from 'ava';\n test.${modifier}(t => { t.assert(foo); });`
			}
		],
		invalid: [
			{
				code: `import test from 'ava';\n test.${modifier}(t => { t.is(foo); });`,
				errors
			}
		]
	});
}

for (const modifiers of permutationCombination(['skip', 'only', 'cb', 'serial']).toArray()) {
	testWithModifier(modifiers.join('.'));
}

function testDeclaration(declaration) {
	ruleTester.run('prefer-power-assert', rule, {
		valid: [
			{
				code: `${declaration}\n test(t => { t.assert(foo); });`
			}
		],
		invalid: [
			{
				code: `${declaration}\n test(t => { t.is(foo); });`,
				errors
			}
		]
github dexteryy / Project-WebCube / packages / webcube / utils / helpers.js View on Github external
exports.getExcludeSplitChunks = (entries, entry) => {
  const otherEntries = exports.getExcludeNames(entries, entry);
  if (!otherEntries.length) {
    return [];
  }
  const combs = Combinatorics.permutationCombination(otherEntries);
  const otherPossibleVendors = combs.map(
    comb => `vendors${output.chunkDelimiter}${comb.join(output.chunkDelimiter)}`
  );
  const otherPossibleCommons = combs.map(
    comb => `commons${output.chunkDelimiter}${comb.join(output.chunkDelimiter)}`
  );
  return otherPossibleVendors.concat(otherPossibleCommons).concat(otherEntries);
};