1.0.1 • Published 7 years ago

unflatten-recursive v1.0.1

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

unflatten-recursive CircleCI

Unflattens object recursively while preserving arrays. Contents of arrays are unflattened.

Note: UNLIKE OTHER OPEN SOURCE LIB such as flat, this lib also loops through arrays and unflattens the array members recursively.

Input:

  {
     'key.nestedKey': 'value',
     'key.arr': [{a : 'a'}, 1, {'arrKey.nestedArrKey': 'arrValue'}]
  }

Output:

  {
    key: {
      nestedKey: 'value',
      arr: [{a: 'a'}, 1, {arrKey: {nestedArrKey: 'arrValue'}}]
    }
  }

For more examples see test/spec.js

Installation

npm install --save unflatten-recursive

Usage

import unflattenRecursive from 'unflatten-recursive';

unflattenRecursive({
  'a.b.c': 'something'
}); // {a: {b: {c: 'something'}}}
unflattenRecursive({
  'a.b': [
    {'c.d': 'nested'}
  ]
}); // {a: {b: [{c: {d: 'nested'}}]}}
1.0.1

7 years ago

1.0.0

7 years ago