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

@emartech/data-aggregator-language

Package Overview
Dependencies
Maintainers
78
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.1.0 to 2.1.1

2

package.json

@@ -29,3 +29,3 @@ {

},
"version": "2.1.0"
"version": "2.1.1"
}

@@ -8,8 +8,5 @@ 'use strict';

const interpreterFactory = require('./interpreter');
const Period = require('../lib/period/period');
const evaluate = (lexer, parser, interpreter) => (text) => {
const lexResult = lexer.tokenize(text);
parser.input = lexResult.tokens;
const createAggregator = (lexer, parser, interpreter) => (text) => {
parser.input = lexer.tokenize(text).tokens;
const cst = parser.additionExpression();

@@ -33,7 +30,8 @@ const value = interpreter.visit(cst);

const AggregatorInterpreter = interpreterFactory(parser);
const interpreter = new AggregatorInterpreter();
module.exports = (input) => (text) => {
const interpreter = new AggregatorInterpreter(Period.create(input));
return evaluate(lexer, parser, interpreter)(text);
module.exports = (input) => {
interpreter.period = input;
return createAggregator(lexer, parser, interpreter);
};
})();

@@ -6,8 +6,11 @@ 'use strict';

describe('The Aggregator Grammar', () => {
const input = [
{ date: '2017-08-15', campaigns: { email: { open: 3 }, values_for_test: [4, 10, 2] } },
{ date: '2017-08-16', campaigns: { email: { open: 4 }, values_for_test: [2, 9] } }
];
const aggregate = subject(input);
let aggregate;
before(() => {
aggregate = subject([
{ date: '2017-08-15', campaigns: { email: { open: 3 }, values_for_test: [4, 10, 2] } },
{ date: '2017-08-16', campaigns: { email: { open: 4 }, values_for_test: [2, 9] } }
]);
});
describe('Binary Operands', () => {

@@ -14,0 +17,0 @@ it('has a last operator', () => {

'use strict';
const Period = require('../lib/period/period');
module.exports = (parser) => {

@@ -7,8 +9,12 @@ const BaseCstVisitor = parser.getBaseCstVisitorConstructor();

class AggregatorInterpreter extends BaseCstVisitor {
constructor(period) {
constructor() {
super();
this._period = period;
this._period = null;
this.validateVisitor();
}
set period(period) {
this._period = Period.create(period);
}
additionExpression(ctx) {

@@ -15,0 +21,0 @@ return this.visit(ctx.lhs) + this._accumulateAdditiveRhs(ctx.rhs);

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