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.6.3 to 1.7.0

25

lib/index.js

@@ -25,6 +25,2 @@ 'use strict';

var _config = new WeakMap();
var _defaults = new WeakMap();
var currentPath = null;
var Cz = function () {

@@ -34,4 +30,5 @@ function Cz() {

this[_config] = {};
this[_defaults] = {};
this._config = new WeakMap();
this._defaults = new WeakMap();
this._path = null;
}

@@ -42,3 +39,3 @@

value: function get(prop) {
var wholeObj = Object.assign((0, _utils.weakToJSON)(_defaults), (0, _utils.weakToJSON)(_config));
var wholeObj = Object.assign((0, _utils.weakToJSON)(this._defaults), (0, _utils.weakToJSON)(this._config));
if (arguments.length === 0) {

@@ -62,3 +59,3 @@ return wholeObj;

(0, _lodash.set)(_config, key, prop[key]);
(0, _lodash.set)(this._config, key, prop[key]);
}

@@ -80,3 +77,3 @@ } catch (err) {

} else {
(0, _lodash.set)(_config, prop.replace(':', '.'), value);
(0, _lodash.set)(this._config, prop.replace(':', '.'), value);
}

@@ -87,3 +84,3 @@ }

value: function defaults(obj) {
_defaults = obj;
this._defaults = obj;
}

@@ -94,3 +91,3 @@ }, {

var file = _fs2.default.readFileSync(newPath, 'utf-8');
currentPath = newPath;
this._path = newPath;
if (file.length >= 1) {

@@ -100,3 +97,3 @@ var data = JSON.parse(file);

if ({}.hasOwnProperty.call(data, prop)) {
_config[prop] = data[prop];
this._config[prop] = data[prop];
}

@@ -109,3 +106,3 @@ }

value: function save(newPath) {
_fs2.default.writeFileSync(_path2.default.normalize(newPath || currentPath), JSON.stringify(_config, null, 4) + '\n', 'utf8');
_fs2.default.writeFileSync(_path2.default.normalize(newPath || this._path), JSON.stringify(this._config, null, 4) + '\n', 'utf8');
}

@@ -138,3 +135,3 @@ }, {

value: function reset() {
_config = new WeakMap();
this._config = new WeakMap();
}

@@ -141,0 +138,0 @@ }]);

{
"name": "cz",
"version": "1.6.3",
"version": "1.7.0",
"description": "A simple config utility for nodejs",

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

@@ -12,2 +12,3 @@ 'use strict';

const config = new Cz();
const configTwo = new Cz();

@@ -91,1 +92,13 @@ describe('set config using string param and string value', () => {

});
describe('new Cz() should create a seperate config store', () => {
before(() => {
config.reset();
config.defaults({
test: 'value'
});
configTwo.set('anotherTest', 'value');
});
it(`config.get() should be different to newConfig.get()`, () => expect(JSON.stringify(config.get())).to.not.equal(JSON.stringify(configTwo.get())));
});
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