New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ricotta

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ricotta

Extend source objects according to a given fieldmap

  • 1.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

ricotta

Extend Source Objects According to a Given Field-map

Usage

Ricotta is useful for extending your hierarchical "config.json" file using ENV flat settings.

ricotta.extendByMapFactory(fieldMap)=>(sourceObj, extensionObj)=>sourceObj

Installation

This library is 100% ES5 compatible, no deps.

npm install ricotta

Example


    var ricotta = require('ricotta');

    // ricotta receives a field map, returns (sourceObj, extensionObj)=>sourceObj
    var extender = ricotta({
        "MY_ENV_KEY_1": "key1",
        "MY_ENV_KEY_2_1": "key2.key1",
        "MY_ENV_KEY_3": "key2.key3",
        "MY_ENV_KEY_4": "key2.key4.key5"
    });

    var env = process.env || {
        "MY_ENV_KEY_1": "This is the value of key1",
        "MY_ENV_KEY_2_1": "This is the value of key2.key1",
        "MY_ENV_KEY_3": "This will be mapped only if the destination exists (yes)",
        "MY_ENV_KEY_4": "This will be mapped only if the destination exists (no)",
    };

    var baseConfig = require('config.json') || {
        "key1": "My setting",
        "key2": {
            "key1": "My first nested setting",
            "key2": "My second nested setting",
            "key3": {}
        }
    };

    extender(baseConfig, env);
    console.log(baseConfig);

	//    	{
	//			key1: 'This is the value of key1',
	//			key2:
	//		   		{
	//					key1: 'This is the value of key2.key1',
	//     				key2: 'My second nested setting',
	//     				key3: 'This will be mapped only if the destination exists (yes)'
	//				}
	//		}

FAQs

Package last updated on 01 Dec 2016

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