0.1.1 • Published 6 years ago

cascade-props v0.1.1

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

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