Helper for merging props use different variants
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
Get props by path (xpath syntax) (for example 'app.port')
Set new variant or change existed variant value
Remove variant
© Alexander Pokhodyun (Karbunkul) 2018