Cascade Props

Build Status JavaScript Style Guide

Synopsis

Helper for merging props use different variants

NPM

How to use

npm install cascade-props --save
const cascadeProps = require('cascade-props')
// example props
const props = {
  app:{
    port: {
      dev: 3030,
      prod: 80,
    }
  }
}
// setup default variants
const variants = [{env: 'prod'}]
// create instance of CascadeProps
const cp = cascadeProps({props, variants})
// get props by env variant ('prod')
const port = cp.node('app.port') // 80 if env=prod and 3030 if env=dev

API reference

node

Get props by path (xpath syntax) (for example 'app.port')

variant

Set new variant or change existed variant value

remove

Remove variant

© Alexander Pokhodyun (Karbunkul) 2018