• Flatten an object with nested objects to a flat structure in which nested objects can be accessed directly using a key separator. I.e:

    flattenNestedObject({ foo: { bar: 'test' } }); // { 'foo.bar': 'test' }
    

    Creates a new object and does not alter the existing structure

    Type Parameters

    • T extends object

    Parameters

    • values: T

      Object to flatten

    • Optional flattenPredicate: ((obj) => any)

      when this predicate returns false the object will not be flattened otherwise; if not set all objects will be flattened

        • (obj): any
        • Parameters

          • obj: any

          Returns any

    • separator: string = '.'

      optional separator

    • Optional keyPrefix: string

      key which will prefixes the new keys

    Returns T