@emartech/data-aggregator-language
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -1,9 +0,8 @@ | ||
const chevrotain = require('chevrotain'); | ||
const aggregator = require('./src/aggregator'); | ||
const { tokens } = require('./src/lib/aggregator/tokens'); | ||
const { tokens } = require('./src/aggregator/tokens'); | ||
const tokenNames = require('./src/lib/token-names'); | ||
module.exports = { | ||
aggregator, | ||
tokens: tokens.map(currTok => chevrotain.tokenName(currTok)) | ||
tokens: tokenNames(tokens) | ||
}; |
@@ -8,3 +8,3 @@ { | ||
"test": "npm run test:style && npm run test:unit", | ||
"test:unit": "mocha ./test/**/*.spec.js", | ||
"test:unit": "mocha ./test/setup-tests.js ./**/*.spec.js", | ||
"test:style": "eslint --fix --ext .js src test" | ||
@@ -30,3 +30,3 @@ }, | ||
}, | ||
"version": "2.0.0" | ||
"version": "2.1.0" | ||
} |
@@ -1,6 +0,6 @@ | ||
# Data Aggregator | ||
# Data Aggregator Language | ||
Execute aggregation expressions on a given data set. | ||
# What it Does | ||
## What it Does | ||
Given the following input data structure, | ||
@@ -27,3 +27,3 @@ ```js | ||
* an aggregation expression mixed with arithmetic: `SUM reservations.silver + 3` would yield `(12 + 3) + 3 = 18` | ||
# Usage | ||
## Usage | ||
```js | ||
@@ -34,6 +34,6 @@ const aggregator = require('@emartech/data-aggregator-language')(input); | ||
# Supported Syntax in Aggregation Expressions | ||
## Supported Syntax in Aggregation Expressions | ||
Examples below are for the `input` defined above. | ||
## Constants | ||
### Constants | ||
* LENGTH | ||
@@ -45,3 +45,3 @@ * `LENGTH` (yields 2) | ||
## Unary Operators | ||
### Unary Operators | ||
* SUM | ||
@@ -54,3 +54,3 @@ * `SUM reservations.silver` (yields 15) | ||
## Binary Operators | ||
### Binary Operators | ||
+, -, *, / | ||
@@ -60,6 +60,31 @@ | ||
# Commit Convention | ||
## Using with Webpack | ||
Because of the [way the underlying Chevrotain library is implemented](https://github.com/SAP/chevrotain/blob/master/examples/parser/minification/README.md), name mangling | ||
interferes with the parser's operation. To resolve this issue, webpacked host projects need to disable name mangling for the token names used in this grammar. | ||
To help with this, the module exports these names in a `tokens` array. | ||
To configure webpack, include the following in your `webpack.config.js`: | ||
```js | ||
const { tokens } = require('@emartech/data-aggregator-language'); | ||
// other config | ||
module.exports.optimization = { | ||
minimizer: [ | ||
new UglifyJsPlugin({ | ||
uglifyOptions: { | ||
mangle: { | ||
reserved: tokens | ||
} | ||
} | ||
}) | ||
] | ||
}; | ||
``` | ||
## Commit Convention | ||
Semantic release depends on the [Angular commit message conventions](https://gist.github.com/stephenparish/9941e89d80e2bc58a153). Please follow these. | ||
# Credit | ||
## Credit | ||
Uses [SAP/chevrotain](https://github.com/SAP/chevrotain) for parsing. |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
20828
19
456
86
1