Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "iter/key-permutations"

Index

Functions

Const keyPermutations

  • keyPermutations<T>(spec: T): IterableIterator<{}>
  • Similar to permutations, however takes an object with each key specifying an array of its possible values. Yields an iterable of objects of all value permutations.

    remarks

    The resulting object type will be derived from the value types in the given spec object.

    The order of resulting permutations is not guaranteed and depending on the VM's iteration behavior of Object.keys().

    example
    [...keyPermutations({ a: [1, 2], b: [true, false], c: ["X", "Y"] })]
    // [
    //   { a: 1, b: true, c: 'X' },
    //   { a: 1, b: true, c: 'Y' },
    //   { a: 1, b: false, c: 'X' },
    //   { a: 1, b: false, c: 'Y' },
    //   { a: 2, b: true, c: 'X' },
    //   { a: 2, b: true, c: 'Y' },
    //   { a: 2, b: false, c: 'X' },
    //   { a: 2, b: false, c: 'Y' }
    // ]

    Type parameters

    • T: IObjectOf<any[]>

    Parameters

    • spec: T

      permutation spec object

    Returns IterableIterator<{}>

Generated using TypeDoc