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

figgy-pudding

Package Overview
Dependencies
Maintainers
5
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

figgy-pudding

Delicious, festive, cascading config/opts definitions

  • 3.5.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.6M
decreased by-45.78%
Maintainers
5
Weekly downloads
 
Created

What is figgy-pudding?

figgy-pudding is a utility for managing options and defaults in a structured way. It allows you to define a schema for your options and ensures that all required options are provided, while also allowing for default values and aliases.

What are figgy-pudding's main functionalities?

Schema Definition

This feature allows you to define a schema for your configuration options. You can specify default values and aliases for options, ensuring that your configuration is consistent and complete.

const figgyPudding = require('figgy-pudding');
const MyConfig = figgyPudding({
  optionA: {},
  optionB: { default: 'defaultValue' },
  optionC: { alias: 'optionD' }
});
const config = MyConfig({ optionA: 'valueA', optionD: 'valueD' });
console.log(config.optionA); // 'valueA'
console.log(config.optionB); // 'defaultValue'
console.log(config.optionC); // 'valueD'

Option Validation

This feature ensures that all required options are provided. If a required option is missing, an error is thrown, helping to prevent misconfigurations.

const figgyPudding = require('figgy-pudding');
const MyConfig = figgyPudding({
  requiredOption: { required: true }
});
try {
  const config = MyConfig({});
} catch (err) {
  console.error(err.message); // 'requiredOption is required'
}

Merging Configurations

This feature allows you to merge multiple configurations together. This is useful for combining default configurations with user-provided overrides.

const figgyPudding = require('figgy-pudding');
const MyConfig = figgyPudding({
  optionA: {},
  optionB: {}
});
const config1 = MyConfig({ optionA: 'valueA' });
const config2 = MyConfig({ optionB: 'valueB' });
const mergedConfig = MyConfig(config1, config2);
console.log(mergedConfig.optionA); // 'valueA'
console.log(mergedConfig.optionB); // 'valueB'

Other packages similar to figgy-pudding

Keywords

FAQs

Package last updated on 24 Mar 2020

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