cascade-props
v0.1.1
Published
Helper for merging props use different variants
Downloads
2
Readme
Cascade Props
Synopsis
Helper for merging props use different variants
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