augment-vir - v31.13.0
    Preparing search index...

    Function selectCollapsedFrom

    • The same as selectFrom except that the final output is collapsed until the first nested value that has more than 1 key or that is not an object.

      Type Parameters

      • Full extends AnyObject
      • const Selection extends any

      Parameters

      Returns KeyCount<
          ExcludeEmpty<
              NonNullable<
                  Full extends readonly Element[]
                      ? (
                          | Exclude<Element, AnyObject>
                          | (
                              Extract<Element, AnyObject> extends readonly Element[]
                                  ? (Exclude<(...), (...)> | ((...) extends (...) ? (...) : (...)))[]
                                  : MakeKeysOptional<
                                      Extract<Element, AnyObject>,
                                      {
                                          -readonly [Key in (...) | (...) | (...) as (...) extends (...)
                                              ? (...)
                                              : (...)]: any
                                      },
                                  >
                          )
                      )[]
                      : MakeKeysOptional<
                          Full,
                          {
                              -readonly [Key in string
                              | number
                              | symbol as Selection[Key] extends false ? never : any]: any
                          },
                      >,
              >,
          >,
      > extends 1
          ? Selection[keyof (
              Full extends readonly Element[]
                  ? (
                      | Exclude<Element, AnyObject>
                      | (
                          Extract<Element, AnyObject> extends readonly Element[]
                              ? (Exclude<(...), (...)> | ((...) extends (...) ? (...) : (...)))[]
                              : MakeKeysOptional<
                                  Extract<Element, AnyObject>,
                                  {
                                      -readonly [Key in (...) | (...) | (...) as (...) extends (...)
                                          ? (...)
                                          : (...)]: any
                                  },
                              >
                      )
                  )[]
                  : MakeKeysOptional<
                      Full,
                      {
                          -readonly [Key in string
                          | number
                          | symbol as Selection[Key] extends false ? never : any]: any
                      },
                  >
          )] extends GenericSelectionSet
              ? | (
                  KeyCount<
                      ExcludeEmpty<
                          NonNullable<
                              NonNullable<Full[keyof (...)]> extends readonly Element[]
                                  ? (Exclude<(...), (...)> | ((...) extends (...) ? (...) : (...)))[]
                                  : MakeKeysOptional<
                                      NonNullable<(...)[(...)]>,
                                      {
                                          -readonly [Key in (...) | (...) | (...) as (...) extends (...)
                                              ? (...)
                                              : (...)]: any
                                      },
                                  >,
                          >,
                      >,
                  > extends 1
                      ? any[any][keyof (
                          NonNullable<Full[keyof (...)]> extends readonly Element[]
                              ? (Exclude<(...), (...)> | ((...) extends (...) ? (...) : (...)))[]
                              : MakeKeysOptional<
                                  NonNullable<(...)[(...)]>,
                                  {
                                      -readonly [Key in (...) | (...) | (...) as (...) extends (...)
                                          ? (...)
                                          : (...)]: any
                                  },
                              >
                      )] extends GenericSelectionSet
                          ? | (
                              KeyCount<
                                  ExcludeEmpty<NonNullable<(...) extends (...) ? (...) : (...)>>,
                              > extends 1
                                  ? any[any][keyof ((...) extends (...) ? (...) : (...))] extends GenericSelectionSet
                                      ?
                                          | (
                                              KeyCount<(...)> extends 1
                                                  ? (...) extends (...) ? (...) : (...)
                                                  : any
                                          )
                                          | Extract<(...)[(...)], (...) | (...)>
                                      : any
                                  : any
                          )
                          | Extract<
                              NonNullable<Full[keyof (...)]>[keyof (
                                  NonNullable<(...)> extends readonly (...)[]
                                      ? (...)[]
                                      : MakeKeysOptional<(...), (...)>
                              )],
                              undefined | null,
                          >
                          : any
                      : any
              )
              | Extract<
                  Full[keyof (
                      Full extends readonly Element[]
                          ? (
                              | Exclude<Element, AnyObject>
                              | (
                                  Extract<(...), (...)> extends readonly (...)[]
                                      ? (...)[]
                                      : MakeKeysOptional<(...), (...)>
                              )
                          )[]
                          : MakeKeysOptional<
                              Full,
                              {
                                  -readonly [Key in string
                                  | number
                                  | symbol as (...)[(...)] extends false ? never : any]: any
                              },
                          >
                  )],
                  undefined
                  | null,
              >
              : any
          : any

      import {selectCollapsedFrom} from '@augment-vir/common';

      selectCollapsedFrom(
      [
      {
      child: {
      grandChild: 'hi',
      grandChild2: 3,
      grandChild3: /something/,
      },
      },
      {
      child: {
      grandChild: 'hi',
      grandChild2: 4,
      grandChild3: /something/,
      },
      },
      ],
      {
      child: {
      grandChild2: true,
      },
      },
      );
      // output is `[3, 4]`