Given obj in which the values are themselves POJOs, restructures the object so that the first level keys become the second level keys and vice versa.
obj
All objects that are values of obj must have the same set of keys.
import * as P from "flurp/pojo";const nested = { x: {a: 1, b: 2}, y: {a: 3, b: 4}, z: {a: 5, b: 6},};P.regroup(nested); // { a: {x: 1, y: 3, z: 5}, b: {x: 2, y: 4, z: 6} }
Given
obj
in which the values are themselves POJOs, restructures the object so that the first level keys become the second level keys and vice versa.Remarks
All objects that are values of
obj
must have the same set of keys.Example