optiopus

1.0.5 • Public • Published

Optiopus

Build Status Coverage Status Climate Status Issues Open Issue Resolution

Version Node Downloads Slack Status License

Optiopus 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 optiopus --save.

Usage

To use, add the require node module:

 
    const optiopus = require('optiopus');
 
    const defs = optiopus({
              'color': '#EFEFEF',
              'font': {
                  'size': '10px',
                  'family': 'Arial'
              },
              'background': {
                  'color': ['rgba', 0, 0, 0, 1]
              }
          }),
          opts = defs.options({
              'color': '#FF0000'
          });
 
          opts.option('font.size', '11px');
          
          opts.options({
            'font.family': 'Monaco' ,
            'background.color'
          });
 
    console.log(opts.options);
 
    /******
    {
      "color": '#FF0000',
      "font": {
          "size": '11px',
          "family": 'Arial'
      },
      "background": {
          "color": [ 'rgba', 0, 0, 0, 1 ]
      }
    }
    *******/
 

WTF

Readme

Keywords

none

Package Sidebar

Install

npm i optiopus

Weekly Downloads

2

Version

1.0.5

License

none

Last publish

Collaborators

  • rubeniskov