{"id":23131258,"url":"https://github.com/emartech/data-aggregator-language","last_synced_at":"2025-08-17T08:31:17.750Z","repository":{"id":144756290,"uuid":"141718935","full_name":"emartech/data-aggregator-language","owner":"emartech","description":"Execute aggregation expressions on a given data set.","archived":false,"fork":false,"pushed_at":"2024-03-15T15:04:21.000Z","size":388,"stargazers_count":2,"open_issues_count":2,"forks_count":3,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-04-05T03:51:10.479Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emartech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-07-20T14:00:51.000Z","updated_at":"2023-07-21T15:58:41.000Z","dependencies_parsed_at":"2023-11-27T21:53:17.686Z","dependency_job_id":null,"html_url":"https://github.com/emartech/data-aggregator-language","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/emartech/data-aggregator-language","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emartech%2Fdata-aggregator-language","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emartech%2Fdata-aggregator-language/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emartech%2Fdata-aggregator-language/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emartech%2Fdata-aggregator-language/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emartech","download_url":"https://codeload.github.com/emartech/data-aggregator-language/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emartech%2Fdata-aggregator-language/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270822890,"owners_count":24652012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-17T11:12:25.488Z","updated_at":"2025-08-17T08:31:17.450Z","avatar_url":"https://github.com/emartech.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Data Aggregator Language\n\nExecute aggregation expressions on a given data set.\n\n## What it Does\nGiven the following input data structure,\n```js\nconst input = [{\n  date: '2017-09-16',\n  reservations: {\n    silver: 12,\n    gold: 5\n  },\n  customers: ['brad']\n}, {\n  date: '2017-09-17',\n  reservations: {\n    silver: 3,\n    gold: 2\n  },\n  customers: ['angelina']\n}]\n```\nthe parser allows mixing aggregation expressions over the input with common arithmetic operators.\n\nFor example,\n* an aggregation expression: `SUM reservations.silver` would yield `12 + 3 = 15`.\n* an aggregation expression mixed with arithmetic: `SUM reservations.silver + 3` would yield `(12 + 3) + 3 = 18`\n## Usage\n```js\nconst aggregator = require('@emartech/data-aggregator-language')(input);\nconst result = aggregator('SUM reservations.silver')\n```\n\n## Supported Syntax in Aggregation Expressions\n\nExamples below are for the `input` defined above.\n\n### Number Results\n\n#### Constants\n* LENGTH\n  * `LENGTH` (yields 2)\n  * `LENGTH + 3` (yields 5)\n* Any number literal\n  * `5` (yields 5)\n\n#### Unary Operators\n* SUM\n  * `SUM reservations.silver` (yields 15)\n* LAST\n  * `LAST reservations.silver` (yields 3)\n* AVERAGE\n  * `AVERAGE reservations.silver` (yields 7.5)\n\n#### Binary Operators\n+, -, *, /\nFor example, `(LAST reservations.silver + 3) * 2 / 2` (yields 6)\n\n\n### Array Results\n* UNION\n  * `UNION customers` (yields ['brad', 'angelina'])\n\n### Boolean Results\n\n* EMPTY\n  * `EMPTY UNION customers` (yields false)\n* NOT\n  * `NOT EMPTY UNION customers` (yields true)\n\n\n## Using with Webpack\nBecause of the [way the underlying Chevrotain library is implemented](https://github.com/SAP/chevrotain/blob/master/examples/parser/minification/README.md), name mangling\ninterferes 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.\n\nTo help with this, the module exports these names in a `tokens` array.\n\nTo configure webpack, include the following in your `webpack.config.js`:\n```js\nconst { tokens } = require('@emartech/data-aggregator-language');\n\n\nmodule.exports.optimization = {\n    minimizer: [\n      new UglifyJsPlugin({\n        uglifyOptions: {\n          mangle: {\n            reserved: tokens\n          }\n        }\n      })\n    ]\n  };\n```\n\n## Commit Convention\nSemantic release depends on the [Angular commit message conventions](https://gist.github.com/stephenparish/9941e89d80e2bc58a153). Please follow these.\n\n## Requirements\nSee [package.json](./package.json) for required libraries and versions.\n\n## Credit\nUses [SAP/chevrotain](https://github.com/SAP/chevrotain) for parsing.\n\n## Contributing\nThis project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/Emartech/data-aggregator-language/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md).\n\n## How to Obtain Support\nThis software is provided as-is.\n\n## Code of Conduct\n\nWe as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its [Code of Conduct](CODE_OF_CONDUCT.md) at all times.\n\n## Licensing\n\nCopyright 2018-2023 SAP SE or an SAP affiliate company and data-aggregator-language contributors. Please see our [LICENSE](LICENSE.txt) for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available [via the REUSE tool](https://api.reuse.software/info/github.com/Emartech/data-aggregator-language)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femartech%2Fdata-aggregator-language","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femartech%2Fdata-aggregator-language","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femartech%2Fdata-aggregator-language/lists"}