@emartech/data-aggregator-language
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -29,3 +29,3 @@ { | ||
}, | ||
"version": "2.2.0" | ||
"version": "2.3.0" | ||
} |
@@ -61,3 +61,3 @@ # Data Aggregator Language | ||
* UNION | ||
* `UNION customers` (yields ['brad', 'angelina']) | ||
* `UNION customers` (yields ['brad', 'angelina']) | ||
@@ -64,0 +64,0 @@ ## Using with Webpack |
@@ -13,3 +13,3 @@ 'use strict'; | ||
campaigns: { email: { open: 3 }, values_for_test: [4, 10, 2] }, | ||
programs: { ids: ['1', '2'] } | ||
programs: { ids: ['1', '2'], users: [] } | ||
}, | ||
@@ -19,3 +19,3 @@ { | ||
campaigns: { email: { open: 4 }, values_for_test: [2, 9] }, | ||
programs: { ids: ['2', '3', '4'] } | ||
programs: { ids: ['2', '3', '4'], users: [] } | ||
} | ||
@@ -153,2 +153,12 @@ ]); | ||
}); | ||
describe('Empty Operator', () => { | ||
it('works for non-empty arrays', () => { | ||
expect(aggregate('EMPTY UNION programs.ids')).to.eql(false); | ||
}); | ||
it('works for empty array', () => { | ||
expect(aggregate('EMPTY UNION programs.users')).to.eql(true); | ||
}); | ||
}); | ||
}); | ||
@@ -155,0 +165,0 @@ |
@@ -31,2 +31,6 @@ 'use strict'; | ||
emptyExpression(ctx) { | ||
return this._isEmpty(this.visit(ctx.unionExpression)); | ||
} | ||
additionExpression(ctx) { | ||
@@ -94,2 +98,6 @@ return this.visit(ctx.lhs) + this._accumulateAdditiveRhs(ctx.rhs); | ||
} | ||
_isEmpty(array) { | ||
return array.length === 0; | ||
} | ||
} | ||
@@ -96,0 +104,0 @@ |
@@ -14,2 +14,3 @@ 'use strict'; | ||
averageOperator, | ||
emptyOperator, | ||
unionOperator, | ||
@@ -42,3 +43,6 @@ lengthConstant, | ||
$.RULE('setOperationExpression', () => { | ||
$.SUBRULE($.unionExpression, { LABEL: 'expression' }); | ||
$.OR([ | ||
{ ALT: () => $.SUBRULE($.unionExpression, { LABEL: 'expression' }) }, | ||
{ ALT: () => $.SUBRULE($.emptyExpression, { LABEL: 'expression' }) } | ||
]); | ||
}); | ||
@@ -51,2 +55,7 @@ | ||
$.RULE('emptyExpression', () => { | ||
$.CONSUME(emptyOperator); | ||
$.SUBRULE($.unionExpression); | ||
}); | ||
$.RULE('additionExpression', () => { | ||
@@ -53,0 +62,0 @@ $.SUBRULE($.minusExpression, { LABEL: 'lhs' }); |
@@ -30,2 +30,7 @@ 'use strict'; | ||
const emptyOperator = createToken({ | ||
name: 'emptyOperator', | ||
pattern: /EMPTY/ | ||
}); | ||
const plusOperator = createToken({ | ||
@@ -82,2 +87,3 @@ name: 'plusOperator', | ||
averageOperator, | ||
emptyOperator, | ||
unionOperator, | ||
@@ -84,0 +90,0 @@ lengthConstant, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24438
584