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

e2e-conf

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

e2e-conf - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

43

conf.js

@@ -20,8 +20,5 @@ /**

}
Object.keys(left).forEach(function (prop) {
if (!compare(left[prop], right[prop])) {
return false;
}
return Object.keys(left).every(function (prop) {
return compare(left[prop], right[prop]);
});
return true;
} else {

@@ -110,3 +107,3 @@ return left === right;

exports.get = function get(key) {
_checkInitialized()
_checkInitialized();

@@ -123,3 +120,3 @@ return nconf.get(key);

exports.set = function set(key, value) {
_checkInitialized()
_checkInitialized();

@@ -135,3 +132,3 @@ return nconf.set(key, value);

exports.setObject = function setObject(object) {
_checkInitialized()
_checkInitialized();

@@ -180,3 +177,7 @@ Object.keys(object).forEach(function (prop) {

fs.writeFile(self.localFileName, JSON.stringify(diff, null, ' '), callback);
if( diff === undefined) {
fs.delete(self.localFileName, callback);
} else {
fs.writeFile(self.localFileName, JSON.stringify(diff, null, ' '), callback);
}
}

@@ -192,3 +193,3 @@ ], callback);

exports.localFile = function localFile() {
_checkInitialized()
_checkInitialized();

@@ -204,3 +205,3 @@ return this.localFileName;

exports.defaultFile = function defaultFile() {
_checkInitialized()
_checkInitialized();

@@ -211,15 +212,23 @@ return this.defaultFileName;

var difference = exports._difference = function difference(base, actual) {
var diff = {};
var diff = {},
same = true;
if (Array.isArray(base)) {
diff = compare(base, actual) ? [] : actual;
diff = compare(base, actual) ? undefined : actual;
} else {
Object.keys(actual).forEach(function (prop) {
var value = base[prop];
var value = base[prop],
localDiff;
if (prop in base) {
if (value instanceof Object) {
diff[prop] = difference(value, actual[prop]);
localDiff = difference(value, actual[prop]);
if( localDiff !== undefined) {
diff[prop] = localDiff;
same = false;
}
} else {
if (value !== actual[prop]) {
diff[prop] = actual[prop];
same = false;
}

@@ -230,4 +239,8 @@ }

diff[prop] = actual[prop];
same = false;
}
});
if(same) {
diff = undefined;
}
}

@@ -234,0 +247,0 @@

{
"name": "e2e-conf",
"version": "2.0.0",
"version": "2.1.0",
"main": "conf.js",

@@ -5,0 +5,0 @@ "dependencies": {

@@ -22,13 +22,20 @@ /**

test.deepEqual(conf._difference({a: 1}, {a: 1}), {});
test.deepEqual(conf._difference({a: 1}, {a: 1}), undefined);
test.done();
},
testNoDifference2: function (test) {
testNoDifferenceSubObject: function (test) {
var conf = this.conf;
test.deepEqual(conf._difference({a: 1}, {}), {});
test.deepEqual(conf._difference({a: {b: 1}, c: 'default'}, {a: {b: 1}, c: 'changed'}), {c: 'changed'});
test.done();
},
testMissingProperty: function (test) {
var conf = this.conf;
test.deepEqual(conf._difference({a: 1}, {}), undefined);
test.done();
},
testDifferenceOneProperty: function (test) {

@@ -84,3 +91,3 @@ var conf = this.conf;

test.deepEqual(conf._difference({o: {a: 1, b: 1, c: []}}, {}), {});
test.deepEqual(conf._difference({o: {a: 1, b: 1, c: []}}, {}), undefined);
test.done();

@@ -103,7 +110,43 @@ },

{a: 1}
]), []);
]), undefined);
test.done();
},
testDifferenceSubArrayNoDifference: function (test) {
var conf = this.conf;
test.deepEqual(conf._difference({a:['b','c']}, {a:['b','c']}), undefined);
test.done();
},
testDifferenceSubArrayChangeElement: function (test) {
var conf = this.conf;
test.deepEqual(conf._difference({a:['b','c']}, {a:['b','changed']}), {a:['b','changed']});
test.done();
},
testDifferenceSubArrayAddElement: function (test) {
var conf = this.conf;
test.deepEqual(conf._difference({a:['b','c']}, {a:['b','c','d']}), {a:['b','c','d']});
test.done();
},
testDifferenceSubArrayRemoveElement: function (test) {
var conf = this.conf;
test.deepEqual(conf._difference({a:['b','c']}, {a:['c']}), {a:['c']});
test.done();
},
testDifferenceSubArrayReorderElements: function (test) {
var conf = this.conf;
test.deepEqual(conf._difference({a:['b','c']}, {a:['c','b']}), {a:['c','b']});
test.done();
}
};

@@ -43,5 +43,3 @@ /**

testRead: function (test) {
var conf = this.conf,
self = this,
subprocess;
var subprocess;

@@ -48,0 +46,0 @@ test.expect(2);

@@ -29,7 +29,7 @@ /**

testChangeProperty: function (test) {
testChangePropertyAndRollback: function (test) {
var conf = this.conf,
self = this;
test.expect(5);
test.expect(8);

@@ -48,3 +48,14 @@ conf.init(this.basePath);

});
test.done();
// rollback the changes
test.equals(true, conf.set('hello', 'world'));
conf.save(function (err) {
var resolve = path.resolve(self.localConfig);
test.ifError(err);
test.deepEqual(fs.existsSync(resolve), false);
test.done();
});
});

@@ -55,4 +66,3 @@

testChangeObject: function (test) {
var conf = this.conf,
self = this;
var conf = this.conf;

@@ -106,3 +116,4 @@ test.expect(4);

test.deepEqual(fs.readJsonFileSync(resolve), {});
test.deepEqual(fs.existsSync(resolve), false);
test.done();

@@ -113,4 +124,3 @@ });

testSaveWithoutInit: function (test) {
var conf = this.conf,
self = this;
var conf = this.conf;

@@ -140,3 +150,4 @@ test.expect(1);

conf.save(function (err) {
test.equals(err.type, "unexpected_token");
test.ok((err.message === 'Unexpected token /') // node > 4.0
|| (err.type === "unexpected_token")); // node = 0.10

@@ -143,0 +154,0 @@ test.done();

@@ -157,4 +157,3 @@ /**

{
connection: {user: 'changed', passwd: 'changed'},
performance: {}
connection: {user: 'changed', passwd: 'changed'}
}

@@ -192,4 +191,3 @@ );

connection: {user: 'local', passwd: 'local'},
somethingnew: 1,
performance: {}
somethingnew: 1
}

@@ -196,0 +194,0 @@ );

Sorry, the diff of this file is not supported yet

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