flattenObject es-toolkit
Converts a nested object into a flat object.
Usage
flattenObject(object, options?)
Use flattenObject when you want to flatten deeply nested objects or arrays using dot (.) notation for keys. Each nested property becomes a single-level object with keys connected by a delimiter.
It's useful for flattening configuration objects like this:
Using options.delimiter, you can flatten the object with custom characters like underscores (_) instead of dots (.).
Using the preserveArrays option, you can keep arrays as values instead of flattening them into index keys.
Empty objects and special cases are handled appropriately.
Parameters
The object to flatten.
Flattening options.
delimiter(string, optional): The delimiter to connect nested keys. Defaults to'.'.preserveArrays(boolean, optional): Iftrue, arrays are kept as values instead of being flattened. Defaults tofalse.
Returns
A new object with all nested properties flattened.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.