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

journeyapps

Package Overview
Dependencies
Maintainers
1
Versions
586
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

journeyapps - npm Package Compare versions

Comparing version 0.2.9 to 0.2.10

35

app/evaluator.js

@@ -119,2 +119,22 @@

// Merge hashes of hashes (no non-hash values)
// Sample:
// deepMerge({a: {}}, {b: {}}) => {a: {}, b: {}}
// deepMerge({a: {b: {c: {}}}, d: {}}, {a: {e: {}}}) => {a: {b: {c: {}}, e: {}}, d: {}}
function deepMerge(a, b) {
if((typeof a != 'object') || (typeof b != 'object')) {
throw new Error('Parameters must be objects only');
}
Object.keys(b).forEach(function(key) {
if(!(key in a)) {
// There are no actual "values" here, except for more nested hashes.
// The presence of keys is the important part.
a[key] = {};
}
deepMerge(a[key], b[key]);
});
return a;
}
function extract(type, expression, into, depth) {

@@ -127,3 +147,5 @@ var dot = expression.indexOf('.');

} else {
into[expression] = objectType.displayFormat.extractRelationshipStructure(objectType, depth+1);
var b = {};
b[expression] = objectType.displayFormat.extractRelationshipStructure(objectType, depth + 1);
deepMerge(into, b);
}

@@ -139,3 +161,5 @@ } else {

} else {
into[head] = {};
if(!(head in into)) {
into[head] = {};
}
extract(child, tail, into[head]);

@@ -149,3 +173,3 @@ }

// This will recursively evaluate format strings where required.
FormatString.prototype.extractRelationshipStructure = function(type, depth) {
FormatString.prototype.extractRelationshipStructure = function(type, depth, into) {
if(depth == null) {

@@ -157,3 +181,3 @@ depth = 0;

var result = {};
var result = into || {};

@@ -246,3 +270,4 @@ var tokens = this.tokens;

compile: compile,
formatString: formatString
formatString: formatString,
_deepMerge: deepMerge // Exposed for tests only
};

2

package.json
{
"name": "journeyapps",
"version": "0.2.9",
"version": "0.2.10",
"description": "Journey JS library",

@@ -5,0 +5,0 @@ "keywords": [

@@ -123,2 +123,14 @@

it('should handle repeats', function() {
companyType.displayFormat = new evaluator.FormatString("{name}");
var fs = new evaluator.FormatString('{company.category.name} {company.category} {company}');
expect(fs.extractRelationshipStructure(personType)).toEqual({company: {category: {}}});
});
it('should handle more repeats', function() {
companyType.displayFormat = new evaluator.FormatString("{name}");
var fs = new evaluator.FormatString('{company.category.name} {company.category} {company.name}');
expect(fs.extractRelationshipStructure(personType)).toEqual({company: {category: {}}});
});
it('should handle bad input', function() {

@@ -129,2 +141,8 @@ var fs = new evaluator.FormatString('{something.else} {company.what.is.this}');

it('should merge results', function() {
companyType.displayFormat = new evaluator.FormatString("{name}");
var fs = new evaluator.FormatString('{company.category.name} {company.category} {company}');
expect(fs.extractRelationshipStructure(personType, undefined, {company: {test: {}}})).toEqual({company: {test: {}, category: {}}});
});
it('should handle recursive display names', function() {

@@ -155,2 +173,7 @@ var theSchema = new schema.Schema();

it('should deepMerge', function() {
var deepMerge = evaluator._deepMerge;
expect(deepMerge({a: {}}, {b: {}})).toEqual({a: {}, b: {}});
expect(deepMerge({a: {b: {c: {}}}, d: {}}, {a: {e: {}}})).toEqual({a: {b: {c: {}}, e: {}}, d: {}});
});
});

Sorry, the diff of this file is too big to display

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