Skip to main content
Module

x/freshlate/freshlate/util.ts>flattenObject

A translation plugin for Deno Fresh
Go to Latest
variable flattenObject
import { flattenObject } from "https://deno.land/x/freshlate@0.4.0/freshlate/util.ts";

Flatten an object into a single level using dot notation

Examples

flattenObject({a: {b: {c: 'd'}}}) // {a.b.c: 'd'}

flattenObject({a: [{b: 'c'}]}) // {a.0.b: 'c'}

flattenObject({a: [{b: {c: 'd'}}, 'e']}) // {a.0.b.c: 'd', a.1: 'e'}

type

(obj: Record<string, unknown>, cur_key?) => Record<string, string>