UNPKG

@stryke/helpers

Version:

A package containing miscellaneous helper functions that are used across many different Storm Software projects.

20 lines (19 loc) 584 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.flattenObject = flattenObject; var _isPlainObject = require("@stryke/type-checks/is-plain-object"); function flattenObject(t) { return T(t); } function T(t, s = "") { const c = {}, b = Object.keys(t); for (const n of b) { const e = t[n], y = s ? `${s}.${n}` : n; if ((0, _isPlainObject.isPlainObject)(e) && Object.keys(e).length > 0) Object.assign(c, T(e, y));else if (Array.isArray(e)) for (const [j, O] of e.entries()) c[`${y}.${j}`] = O;else c[y] = e; } return c; }