{"id":28684880,"url":"https://github.com/node-modules/aggregate-base","last_synced_at":"2025-06-14T03:07:27.457Z","repository":{"id":57174480,"uuid":"144407839","full_name":"node-modules/aggregate-base","owner":"node-modules","description":"Base class for aggregate operation","archived":false,"fork":false,"pushed_at":"2018-08-26T06:13:08.000Z","size":14,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-05-19T11:39:08.132Z","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/node-modules.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-11T18:09:04.000Z","updated_at":"2023-07-12T11:39:41.000Z","dependencies_parsed_at":"2022-08-29T00:10:45.379Z","dependency_job_id":null,"html_url":"https://github.com/node-modules/aggregate-base","commit_stats":null,"previous_names":["node-modules/aggregate-base","alibaba-archive/aggregate-base"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Faggregate-base","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Faggregate-base/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Faggregate-base/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Faggregate-base/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/node-modules","download_url":"https://codeload.github.com/node-modules/aggregate-base/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-modules%2Faggregate-base/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":257177892,"owners_count":22501835,"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","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":"2025-06-14T03:07:26.727Z","updated_at":"2025-06-14T03:07:27.443Z","avatar_url":"https://github.com/node-modules.png","language":"JavaScript","readme":"# aggregate-base\n\nBase class for aggregate operation, sush as http request, write file.\n\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][codecov-image]][codecov-url]\n[![David deps][david-image]][david-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![NPM download][download-image]][download-url]\n\n[npm-image]: https://img.shields.io/npm/v/aggregate-base.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/aggregate-base\n[travis-image]: https://img.shields.io/travis/node-modules/aggregate-base.svg?style=flat-square\n[travis-url]: https://travis-ci.org/node-modules/aggregate-base\n[codecov-image]: https://codecov.io/gh/node-modules/aggregate-base/branch/master/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/node-modules/aggregate-base\n[david-image]: https://img.shields.io/david/node-modules/aggregate-base.svg?style=flat-square\n[david-url]: https://david-dm.org/node-modules/aggregate-base\n[snyk-image]: https://snyk.io/test/npm/aggregate-base/badge.svg?style=flat-square\n[snyk-url]: https://snyk.io/test/npm/aggregate-base\n[download-image]: https://img.shields.io/npm/dm/aggregate-base.svg?style=flat-square\n[download-url]: https://npmjs.org/package/aggregate-base\n\n\n## Usage\n\n```bash\nnpm i aggregate-base --save\n```\n\nYou can wrap Class for aggregate operation, if you have a Logger that write log to file.\n\n```js\nclass Logger {\n  info(log) {\n    this.writeToFile(log);\n  }\n\n  writeToFile() {\n    // your implementation\n  }\n}\n```\n\nHowever, it has bad performance that write file system every function call, so you can use this module to merge the operations.\n\n```js\nconst { wrap } = require('aggregate-base');\n\nclass Logger {\n  info(log) {\n    this.writeToFile(log);\n  }\n\n  flush(logs) {\n    this.writeToFile(logs.join('\\n'));\n  }\n\n  writeToFile() {\n    // your implementation\n  }\n}\n\nconst WrapLogger = wrap(Logger, {\n  interval: 1000,\n  intercept: 'info',\n  flush: 'flush',\n});\n```\n\nThe module will create a loop (configured by interval), it will collect data by intercepting the specified `intercept` method, and call `flush` method after `interval` with all collected data.\n\n## Options\n\n- interval: the time between flush\n- intercept: the intercept method name of class, the method will not be run.\n- interceptTransform: the function that can tranform the arguments of intercept method, **if it return false, it won't cache this data**\n- flush: the flush method name of class.\n- close: the close method name of class, it should be a async function.\n\n## License\n\n[MIT](LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-modules%2Faggregate-base","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnode-modules%2Faggregate-base","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-modules%2Faggregate-base/lists"}