0.1.3 • Published 9 years ago

optree v0.1.3

Weekly downloads
3
License
-
Repository
github
Last release
9 years ago

Optree

Build Status Coverage Status Climate Status Issues Open Issue Resolution

Version Node Downloads Slack Status License

Optree is a function thats provide a plain object with the tree path of properties and their own values.

Motivation

Sometimes, you need simplify a complex JSON structure to compare objects or iterate several times, so this method provides a flatten object to make easier the access to values. it's really usefull when you want compare two objects without nested child.

NPM GRID

Installation

Install with npm install optree --save.

Usage

To use, add the require node module:

    const optree = require('optree');

    const json = {
        'foo': [
            'apple',
            'pear'
        ],
        'bar': {
            'apple': 0,
            'pear': 1
        },
        'first': {
            'second': {
                'third': 'last'
            }
        }
    };
    const foo = optree(json),
          bar = optree(json, true);

    console.log(foo);

    /******
    {
      "foo": ['apple', 'pear'],
      "bar.apple": '0',
      "bar.pear": '1',
      "first.second.third": 'last'
    }
    *******/

    console.log(bar);
    
    /******
    {
      "foo.0": 'apple',
      "foo.1": 'pear',
      "bar.apple": '0',
      "bar.pear": '1',
      "first.second.third": 'last'
    }
    *******/

WTF

0.1.3

9 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.0

10 years ago