New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

combine-config

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

combine-config

combine config

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

combine-config

Combine config object

Install

npm install combine-config

Usage

var combine_config = require("combine-config");
var prototype_stringify = require("prototype-stringify");   //tool for debug

var base_config = {
	ip: "127.0.0.1",	//Items will be untouched if not existed in sub config.
	port: 8080,
	param: [1, 2, 3, 4],
	date1: new Date(2000, 1, 1),
	func1: function () { },

	mine: {
		"html": "text/html",	//Items will be untouched if not existed in sub config.
		"jpg": "image/jpg",
	},
	mine2: {
		"html": "text/html",
		"jpg": "image/jpg",
	},

};

var sub_config = {
	port: 8081,		//Items will be replaced, except simple objects.
	param: [3, 4],
	date1: null,
	func1: undefined,

	mine: {				//simple objects will be deep-copied.
		"txt": "text/plain",
		"jpg": "application/octet-stream",
	},
	"!mine2": {			//To stop deep-copy, prefix name with "!".
		"txt": "text/plain",
	},

	param2: "new param",	//Add new item
};

var new_config = combine_config(base_config, sub_config, "test");		//A new config object is created

//change somethig
new_config.mine["css"] = "text/css";		//The base config is isolated by prototype chain

base_config.ip2 = "127.0.0.2";			//Change to base config will be seen in the new config
base_config.mine["js"] = "text/javascript";
base_config.mine["html"] = "text";

console.log(new_config);
prototype_stringify(new_config, "\t");

/*
var expect_config = {
	ip: "127.0.0.1",
	ip2: "127.0.0.2",
	port: 8081,
	param: [3, 4],
	date1: null,
	func1: undefined,

	mine: {
		"html": "text",
		"txt": "text/plain",
		"jpg": "application/octet-stream",
		"js": "text/javascript",
		"css": "text/css",
	},
	mine2: {
		"txt": "text/plain",
	},
	param2: "new param",
};
*/

Keywords

combine

FAQs

Package last updated on 22 Oct 2021

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