GuobaGuoba Utils

crush

@guoba-ai/utils / object / crush

Function: crush()

function crush<T>(obj): Record<string, unknown>;

Defined in: object.ts:349

Flatten a deeply nested object into a single-level object with dot-path keys. Arrays are treated as leaf values and are not flattened.

Type Parameters

T

T extends object

Parameters

obj

T

The object to flatten

Returns

Record<string, unknown>

A flat object with dot-path keys

Example

crush({ a: { b: 1, c: { d: 2 } } })
// { 'a.b': 1, 'a.c.d': 2 }

On this page