Enables simple feature flagging, feature gating and co. by incorporating different stages to toggle features.
npm install flgspackage.json branching.
package.json
flgs.json
package > file > cli > global > constructor.
true or false based on an own strategy:
true, "true", 1, "1", "on", "yes", "enable" will be interpreted as set
function or an object as a value for a flag, even if the are empty, will be interpreted as set
null will be interpreted as unset
unset
sh
$ npm install --save ffm
`
Second, import the package and instantiate FFM.
`js
const Flgs = require('flgs')
let flgs = new Flgs()
`
Third, use it in a simple if clause:
`js
if (flgs.isSet('bluecolors')) {
// new behaviour
}
else {
// old behaviour
}
`
An example for package.json located in the root of the importing project:
`json
{
"featureflags": {
"bluecolors": true,
"redcolors": false,
"greencolors": false,
"violetcolors": {},
"orangecolors": [
"a",
"b"
]
}
}
`
An example for flgs.json located in the root of the importing project:
`json
{
"greencolors": false,
"redcolors": true,
"bluecolors": true,
"violetcolors": false,
"orangecolors": false
}
`
An example for the command line interface, provided via scripts of package.json in the root of the importing project. The cli argument must start with FFM_:
`json
{
"scripts": {
"flagging": "node index.js FFM_BLUECOLORS"
}
}
`
An example for a global array:
`js
const _FMM = {
"bluecolors": true
}
`
An example for a default configuration:
`js
let flgs = new Flgs({
"bluecolors": true
})
``