Draconarius
Manage (feature)flags like a Roman soldier
Install
yarn add @sensorfactdev/draconarius
Basic usage
const { Draconarius } = require('@sensorfactdev/draconarius');
const flags = {
foo: true,
};
const draconarius = new Draconarius(flags);
const goodOldFn = () => console.log('old');
const newAmazingFn = () => console.log('new');
const operation = draconarius.isEnabled('foo')
? newAmazingFn
: goodOldFn;
operation();
Flags as functions
const { pathOr } = require('ramda');
const { Draconarius } = require('@sensorfactdev/draconarius');
const flags = {
hasOpenPayments: user => pathOr(false, ['metaData', 'hasOpenPayments'], user),
};
const draconarius = new Draconarius(flags);
const user = {
metaData: { hasOpenPayments: false },
};
const navigation = draconarius.isEnabled('hasOpenPayments', user)
? browserHistory.replace('/new-payment/832763877832');
: browserHistory.replace('/open-payment/98766789023')
Updating flags
const { Draconarius } = require('@sensorfactdev/draconarius');
const flags = {
foo: true,
bar: false
};
const draconarius = new Draconarius(flags);
draconarius.updateFlag('foo', false);
draconarius.updateFlag({ foo: true, bar: true, fizz: f => !f });
Getting all flags
const { Draconarius } = require('@sensorfactdev/draconarius');
const { equals } = require('ramda');
const flags = { foo: true, bar: false };
const draconarius = new Draconarius(flags);
console.log(equals(draconarius.getAllFlags(), flags))
Other resources