Optiopus
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.
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 ] } } *******/