UNPKG

@aplus-frontend/ui

Version:

31 lines (30 loc) 691 B
import { isArray as i, isFunction as e, isPlainObject as m } from "lodash-unified"; function p(f, l, c) { if (f == null) return; let r = i(f) ? [] : {}; return Object.keys(f).forEach((n) => { const s = f[n], o = l?.[n], a = e(o) ? o : o?.transformer, u = e(o) ? !0 : o?.flat; if (e(a)) { const t = a( s, c ? { getFieldsValue: c } : void 0 ); u ? i(t) && i(r) ? r = [...r, ...t] : m(t) && m(r) ? r = { ...r, ...t } : r[n] = t : r[n] = t; } else if (m(s) || i(s)) { const t = p( s, o, c ); r[n] = t; } else r[n] = s; }), r; } export { p as transformValues };