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

confidence

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

confidence - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

30

lib/store.js

@@ -30,8 +30,7 @@ // Load modules

internals.Store.prototype.get = function (key /*, [criteria,] [depth] */) {
internals.Store.prototype.get = function (key, criteria) {
var self = this;
var criteria = (typeof arguments[1] === 'object' ? arguments[1] : {});
var depth = (arguments.length === 3 ? arguments[2] : (arguments.length === 2 && typeof arguments[1] === 'number' ? arguments[1] : undefined));
criteria = criteria || {};

@@ -63,3 +62,3 @@ var path = [];

return internals.walk(node, criteria, depth);
return internals.walk(node, criteria);
};

@@ -91,5 +90,3 @@

if (typeof node !== 'object' ||
node instanceof Array) {
if (typeof node !== 'object') {
return null;

@@ -224,6 +221,6 @@ }

if (!node ||
typeof node !== 'object' || node instanceof Array || // Value
!node.$filter) { // Fork
typeof node !== 'object' || // Value
!node.$filter) { // Fork
return node || null; // Override undefined
return node || null; // Override undefined
}

@@ -269,7 +266,6 @@

internals.walk = function (node, criteria, depth) {
internals.walk = function (node, criteria) {
if (!node ||
typeof node !== 'object' ||
node instanceof Array) {
typeof node !== 'object') {

@@ -279,8 +275,4 @@ return node || null; // Override undefined

if (depth === 0) {
return {};
}
var parent = (node instanceof Array ? [] : {});
var parent = {};
var keys = Object.keys(node);

@@ -290,3 +282,3 @@ for (var i = 0, il = keys.length; i < il; ++i) {

var child = internals.filter(node[key], criteria);
var value = internals.walk(child, criteria, depth !== undefined ? depth - 1 : undefined);
var value = internals.walk(child, criteria);
if (value) {

@@ -293,0 +285,0 @@ parent[key] = value;

{
"name": "confidence",
"description": "Configuration API",
"version": "0.5.0",
"version": "0.6.0",
"author": "Eran Hammer <eran@hueniverse.com> (http://hueniverse.com)",

@@ -6,0 +6,0 @@ "repository": "git://github.com/spumko/confidence",

@@ -235,3 +235,3 @@ <a href="https://github.com/spumko"><img src="https://raw.github.com/spumko/spumko/master/images/from.png" align="right" /></a>

### store.get(key, [criteria,] [depth])
### store.get(key, [criteria])

@@ -242,3 +242,2 @@ Retrieves a value from the configuration document after applying the provided criteria where:

- `criteria` - optional object used as criteria for applying filters in the configuration document. Defaults to `{}`.
- `depth` - optional number used to determine how deep the resulting tree is. Defaults to full depth.

@@ -245,0 +244,0 @@ Returns the value found after applying the criteria. If the key is invalid or not found, returns null.

@@ -51,3 +51,3 @@ // Load modules

},
key4: [12, 13, 14],
key4: [12, 13, { $filter: 'none', x: 10, $default: 14 }],
key5: {},

@@ -70,7 +70,7 @@ ab: {

var get = function (key, result, criteria, depth) {
var get = function (key, result, criteria) {
it('gets value for ' + key + (criteria ? ' with criteria ' + JSON.stringify(criteria) : ''), function (done) {
var value = store.get(key, criteria, depth);
var value = store.get(key, criteria);
expect(value).to.deep.equal(result);

@@ -88,7 +88,4 @@ done();

get('/key5', {});
get('/key5', {}, null, 5);
get('/', { key1: 'abc', key2: 2, key3: { sub1: 123 }, key4: [12, 13, 14], key5: {}, ab: 6 });
get('/', { key1: 'abc', key2: 2, key3: { sub1: 123, sub2: 6 }, key4: [12, 13, 14], key5: {}, ab: 6 }, { xfactor: 'yes' });
get('/', { key1: 'abc', key2: 2, key3: {}, key4: [12, 13, 14], key5: {}, ab: 6 }, null, 1);
get('/', { key1: 'abc', key2: 2, key3: { sub1: 123 }, key4: [12, 13, 14], key5: {}, ab: 6 }, null, 2);
get('/ab', 4, { random: { 1: 9 } });

@@ -106,23 +103,2 @@ get('/ab', 4, { random: { 1: 10 } });

});
it('accepts 1 arguments', function (done) {
var value = store.get('/key1');
expect(value).to.equal('abc');
done();
});
it('accepts 2 arguments with criteria', function (done) {
var value = store.get('/key1', {});
expect(value).to.equal('abc');
done();
});
it('accepts 2 arguments with depth', function (done) {
var value = store.get('/', 2);
expect(value).to.deep.equal({ key1: 'abc', key2: 2, key3: { sub1: 123 }, key4: [12, 13, 14], key5: {}, ab: 6 });
done();
});
});

@@ -129,0 +105,0 @@

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