0.1.2 • Published 6 years ago

deep-shallow v0.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

deep-shallow

An object convert between shallow and deep.

npm: deep-shallow CircleCI Coverage Status tested with jest code style: prettier license: mit

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],
// };