• Pick a deep subset of an object filtered by key paths of another object.

    Type Parameters

    • T extends object

    • Filter extends object

    Parameters

    • input: T

      Object to pick from.

    • subsetFilter: Filter

      Object to use as filter.

    • Optional options: {
          filterFlatOptions?: FlattenOptions;
          inputFlatOptions?: FlattenOptions;
          unflatOptions?: UnflattenOptions;
      }

      Flatten options.

      • Optional filterFlatOptions?: FlattenOptions
      • Optional inputFlatOptions?: FlattenOptions
      • Optional unflatOptions?: UnflattenOptions

    Returns Extract<T, Filter>

    Example

    // input (values will always come from input)
    const input = {
    randomValue: 'random',
    django: {
    allowedHosts: '*',
    csrfCookieSecure: false,
    },
    sentry: {
    traceExcludeUrls: ['one', 'two', 'three'],
    },
    }
    // filter only django values (only keys are looked at).
    const subsetFilter = {
    django: {
    allowedHosts: true,
    csrfCookieSecure: true,
    },
    }
    const result = pickSubsetDeep(input, subsetFilter)
    console.log(result)
    // {
    // django: {
    // allowedHosts: '*',
    // csrfCookieSecure: false,
    // },
    // }

Generated using TypeDoc