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

maybe-config

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

maybe-config

A safe object traversal method, used for easy configuration grabbing.

  • 1.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

maybe-config

Easy, safe configuration traversal.

maybe-config is a package designed to safely traverse configuration objects, allowing deep trawling without fear of errors from incorrect keys, undefineds, and all the goodness that usually comes out of working with Javascript.

maybe-config uses the concept of the Maybe monad to allow for safe traversal. The final usage for interface by default provides plain values, but also provides Safe variants that instead return the Maybe instance for further safe processing.

Usage

// my-config.js
// Create a passthrough module that will set the context for your Config object
const Config = require('maybe-config');

module.exports = Config(window.myConfig);
// Import your passthrough module to have a ready to use config object
const Config = require('./my-config');

// Grab a single value from the root.
const setting1 = Config.get('setting1');

// Grab a value from a path
const setting2 = Config.getIn('setting1', 'setting2');

// (client specific) grab a value starting at the 'settings' root key.
const clientSetting = Config.getClientSetting('clientSetting');

// Get a flag from the 'flags' root key as a bool.
const hasHeader = Config.getFlag('hasHeader');

// simply add Safe to the end of any method name to get a Maybe instance
const clientNameUpper = Config.getSafe('name').map(name => name.toUpperCase()).value();

FAQs

Package last updated on 15 May 2019

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