Skip to content

toolmark-monorepo / @toolmark/core / flatten

Function: flatten() ​

flatten(obj, opts?): Record<string, unknown>

Defined in: packages/core/src/forms/paths.ts:208

Flattens a plain object into leaf dot paths ({ a: { b: 1 } } → { 'a.b': 1 }). Arrays are leaves unless arraysAsLeaves: false; non-plain objects (e.g. Date, File) are always leaves; empty objects produce no path. Keys that are __proto__, prototype or constructor (at any depth, including inside array leaves), cycles and values nested deeper than 64 levels are never emitted. At most 10000 nodes are visited (shared references count each time they are reached); the rest of a larger value is not emitted. Only own properties are read.

Parameters ​

obj ​

unknown

The value to flatten (non-objects yield {}).

opts? ​

FlattenOptions

See FlattenOptions; arrays are leaves by default.

Returns ​

Record<string, unknown>

A record keyed by dot path.