0.1.2 • Published 6 years ago
deep-shallow v0.1.2
deep-shallow
An object convert between shallow and deep.
Install
yarn add [-d] deep-shallow
Usage
import {toDeep, toShallow} from 'deep-shallow';
const deepObj = {
foo: {
a: 'a',
b: 'b',
c: 'c',
d: 'd',
},
bar: {
x: 'x',
y: 'y',
z: 'z',
},
arr: [1, 2, 3, 4],
};
const shallowObj = toShallow(deepObj);
// {
// 'foo.a': 'a'
// 'foo.b': 'b'
// 'foo.c': 'c'
// 'foo.d': 'd',
// 'bar.x': 'x',
// 'bar.y': 'y',
// 'bar.z': 'z'
// arr: [1, 2, 3, 4],
// }
toDeep(shallowObj);
// {
// foo: {
// a: 'a',
// b: 'b',
// c: 'c',
// d: 'd',
// },
// bar: {
// x: 'x',
// y: 'y',
// z: 'z',
// },
// arr: [1, 2, 3, 4],
// };