Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sensorfactdev/draconarius

Package Overview
Dependencies
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sensorfactdev/draconarius

Manage (feature)flags like a Roman soldier"

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

Draconarius

Build Status Coverage Status

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(); // => new

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);

// Update a signle flag
draconarius.updateFlag('foo', false);

// Update multiple flags and add one
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)) // true;

Other resources

FAQs

Package last updated on 15 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc