Socket
Socket
Sign inDemoInstall

@emartech/data-aggregator-language

Package Overview
Dependencies
Maintainers
97
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@emartech/data-aggregator-language - npm Package Compare versions

Comparing version 2.4.4 to 2.5.0

16

package.json

@@ -7,3 +7,3 @@ {

"semantic-release": "semantic-release",
"test": "npm run test:style && npm run test:unit",
"test": "npm run test:unit && npm run test:style",
"test:unit": "mocha ./test/setup-tests.js ./**/*.spec.js",

@@ -15,3 +15,3 @@ "test:style": "eslint --fix --ext .js src test"

"dependencies": {
"chevrotain": "4.3.2",
"chevrotain": "4.8.1",
"lodash": "4.17.11"

@@ -21,13 +21,13 @@ },

"chai": "4.2.0",
"eslint": "5.16.0",
"eslint": "6.0.1",
"eslint-config-emarsys": "5.1.0",
"eslint-plugin-require-path-exists": "1.1.9",
"mocha": "6.0.2",
"semantic-release": "15.13.3"
"mocha": "6.1.4",
"semantic-release": "15.13.17"
},
"engines": {
"node": "8.12.0",
"npm": "6.4.1"
"node": "10.16.0",
"npm": "6.9.0"
},
"version": "2.4.4"
"version": "2.5.0"
}

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

});
it('return NaN if its a division by zero', () => {
expect(aggregate('0 / 0')).to.eql(NaN);
});
});

@@ -197,6 +201,10 @@ });

});
it('throws an exception when the operator is lowercase', function() {
expect(() => aggregate('last campaigns.email')).to.throw('Error parsing "last campaigns.email"');
});
});
context('partially has data', function() {
it('works', function() {
context('has data for some keys only', function() {
it('returns the result when some keys have data', function() {
const periodDataWithMissingValues = [{ date: '2018-03-10', value: 1 }];

@@ -209,7 +217,16 @@

expect(aggregate('AVERAGE value + AVERAGE otherVal')).to.eql(1);
expect(aggregate('SUM otherVal')).to.eql(0);
expect(aggregate('LAST otherVal')).to.eql(0);
expect(aggregate('AVERAGE otherVal')).to.eql(0);
});
it('returns null when one key has no data', function() {
expect(aggregate('SUM otherVal')).to.eql(null);
expect(aggregate('LAST otherVal')).to.eql(null);
expect(aggregate('AVERAGE otherVal')).to.eql(null);
});
it('returns null when all keys have no data', function() {
expect(aggregate('SUM otherVal + SUM someOtherVal')).to.eql(null);
expect(aggregate('LAST otherVal + LAST someOtherVal')).to.eql(null);
expect(aggregate('AVERAGE otherVal + AVERAGE someOtherVal')).to.eql(null);
});
});
});

@@ -40,15 +40,31 @@ 'use strict';

additionExpression(ctx) {
return this.visit(ctx.lhs) + this._accumulateAdditiveRhs(ctx.rhs);
let lhs = this.visit(ctx.lhs);
if (lhs === null) {
return null;
}
return lhs + this._accumulateAdditiveRhs(ctx.rhs);
}
minusExpression(ctx) {
return this.visit(ctx.lhs) - this._accumulateAdditiveRhs(ctx.rhs);
let lhs = this.visit(ctx.lhs);
if (lhs === null) {
return null;
}
return lhs - this._accumulateAdditiveRhs(ctx.rhs);
}
multiplicationExpression(ctx) {
return this.visit(ctx.lhs) * this._accumulateMultiplicativeRhs(ctx.rhs);
let lhs = this.visit(ctx.lhs);
if (lhs === null) {
return null;
}
return lhs * this._accumulateMultiplicativeRhs(ctx.rhs);
}
divisionExpression(ctx) {
return this.visit(ctx.lhs) / this._accumulateMultiplicativeRhs(ctx.rhs);
let lhs = this.visit(ctx.lhs);
if (lhs === null) {
return null;
}
return lhs / this._accumulateMultiplicativeRhs(ctx.rhs);
}

@@ -55,0 +71,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