https://github.com/karbunkul/cascade-props
https://github.com/karbunkul/cascade-props
npm-package
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/karbunkul/cascade-props
- Owner: karbunkul
- Created: 2018-02-11T05:31:56.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-04-20T13:32:56.000Z (about 3 years ago)
- Last Synced: 2025-10-05T03:51:47.212Z (8 months ago)
- Topics: npm-package
- Language: JavaScript
- Size: 35.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Cascade Props
[](https://travis-ci.org/karbunkul/cascade-props)
[](https://standardjs.com)
- [Synopsis](#synopsis)
- [How to use](#how-to-use)
- [API reference](#api-reference)
- [node](#node)
- [variant](#variant)
## Synopsis
Helper for merging props use different variants
[](https://nodei.co/npm/cascade-props/)
## How to use
```bash
npm install cascade-props --save
```
```js
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