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

cz

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cz - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

config.json

34

index.js

@@ -48,3 +48,14 @@ 'use strict';

set: function(prop, value, save) {
config[prop] = value;
let schema = config; // a moving reference to internal objects within obj
let pList = prop.split(':');
let len = pList.length;
for(let i = 0; i < len-1; i++) {
let elem = pList[i];
if(!schema[elem]){
schema[elem] = {};
}
schema = schema[elem];
}
schema[pList[len-1]] = value;
if(!save && saveToDisk){

@@ -58,3 +69,3 @@ fs.writeFileSync(currentPath, JSON.stringify(config, null, 4) + '\n', 'utf8');

let tempConfig = {};
for(let prop in data){
for(let prop in data){ // jshint ignore:line
if (data.hasOwnProperty(prop)) {

@@ -64,7 +75,16 @@ tempConfig[prop] = data[prop];

}
tempConfig[prop] = value;
let schema = tempConfig; // a moving reference to internal objects within obj
let pList = prop.split(':');
let len = pList.length;
for(let i = 0; i < len-1; i++) {
let elem = pList[i];
if(!schema[elem]){
schema[elem] = {};
}
schema = schema[elem];
}
schema[pList[len-1]] = value;
fs.writeFileSync(currentPath, JSON.stringify(tempConfig, null, 4) + '\n', 'utf8');
}
}
config[prop] = value;
},

@@ -83,3 +103,9 @@ joinGets: function(gets, joins){

return finalResult;
},
args: function(save){
process.argv.slice(2).forEach(function(val) {
val = val.slice(2).split('='); // Gets us ['db:host', 'localhost'] from '--db:host=localhost'
module.exports.set(val[0], val[1], save);
});
}
};

2

package.json
{
"name": "cz",
"version": "1.1.0",
"version": "1.2.0",
"description": "A simple config utility for nodejs",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -23,4 +23,4 @@ # cz

// Below are two ways of getting objects, the bottom one is the prefered way as it joins the retrieved values for you
console.log('db:host+db:username+db:password+db:port', 'mongodb://' + config.get('db:username') + ':' + config.get('db:password') + '@' + config.get('db:host') + ':' + config.get('db:port') + '/' + config.get('db:collection'));
console.log('db:host+db:username+db:password+db:port', 'mongodb://' + config.joinGets(['db:username', 'db:password', 'db:host', 'db:port', 'db:collection'], [':', '@', ':', '/']));
console.log('mongodb://' + config.get('db:username') + ':' + config.get('db:password') + '@' + config.get('db:host') + ':' + config.get('db:port') + '/' + config.get('db:collection'));
console.log('mongodb://' + config.joinGets(['db:username', 'db:password', 'db:host', 'db:port', 'db:collection'], [':', '@', ':', '/']));
````
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