{"id":17402840,"url":"https://github.com/thlorenz/ndjson-aggregator","last_synced_at":"2025-03-29T20:14:21.641Z","repository":{"id":31925203,"uuid":"35494592","full_name":"thlorenz/ndjson-aggregator","owner":"thlorenz","description":"Aggregates ndjson output into one JSON object, keyed by a given property.","archived":false,"fork":false,"pushed_at":"2015-05-12T16:03:15.000Z","size":144,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-04T22:37:42.687Z","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/thlorenz.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2015-05-12T14:55:46.000Z","updated_at":"2019-04-06T05:21:49.000Z","dependencies_parsed_at":"2022-08-27T04:10:17.309Z","dependency_job_id":null,"html_url":"https://github.com/thlorenz/ndjson-aggregator","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thlorenz%2Fndjson-aggregator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thlorenz%2Fndjson-aggregator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thlorenz%2Fndjson-aggregator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thlorenz%2Fndjson-aggregator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thlorenz","download_url":"https://codeload.github.com/thlorenz/ndjson-aggregator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246237436,"owners_count":20745348,"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":"2024-10-16T18:30:00.202Z","updated_at":"2025-03-29T20:14:21.622Z","avatar_url":"https://github.com/thlorenz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ndjson-aggregator [![build status](https://secure.travis-ci.org/thlorenz/ndjson-aggregator.png)](http://travis-ci.org/thlorenz/ndjson-aggregator)\n\n[![testling badge](https://ci.testling.com/thlorenz/ndjson-aggregator.png)](https://ci.testling.com/thlorenz/ndjson-aggregator)\n\nAggregates ndjson output into one JSON object, keyed by a given property.\n\n```js\nvar aggregate = require('ndjson-aggregator')\n\nvar lines = [\n    '{\"name\":\"buffers/buffer-creation\",\"config\":{\"type\":\"fast\",\"len\":10,\"n\":1024},\"time\":\"5400.10125\"}'\n  , '{\"name\":\"buffers/buffer-creation\",\"config\":{\"type\":\"fast\",\"len\":1024,\"n\":1024},\"time\":\"2097.43265\"}'\n  , '{\"name\":\"buffers/buffer-deletion\",\"config\":{\"type\":\"fast\",\"len\":10,\"n\":1024},\"time\":\"5400.10125\"}'\n  , '{\"name\":\"buffers/buffer-deletion\",\"config\":{\"type\":\"fast\",\"len\":1024,\"n\":1024},\"time\":\"2097.43265\"}'\n  , '{\"config\":{\"type\":\"fast\",\"len\":10,\"n\":1024},\"time\":\"5400.10125\"}'\n  , '{\"config\":{\"type\":\"fast\",\"len\":1024,\"n\":1024},\"time\":\"2097.43265\"}'\n]\n\nvar res = aggregate(lines, 'name')\nconsole.log(res)\n```\n\n```\n{ 'buffers/buffer-creation':\n   [ { name: 'buffers/buffer-creation',\n       config: { type: 'fast', len: 10, n: 1024 },\n       time: '5400.10125' },\n     { name: 'buffers/buffer-creation',\n       config: { type: 'fast', len: 1024, n: 1024 },\n       time: '2097.43265' } ],\n  'buffers/buffer-deletion':\n   [ { name: 'buffers/buffer-deletion',\n       config: { type: 'fast', len: 10, n: 1024 },\n       time: '5400.10125' },\n     { name: 'buffers/buffer-deletion',\n       config: { type: 'fast', len: 1024, n: 1024 },\n       time: '2097.43265' } ],\n  'ENOEXIST name':\n   [ { config: { type: 'fast', len: 10, n: 1024 },\n       time: '5400.10125' },\n     { config: { type: 'fast', len: 1024, n: 1024 },\n       time: '2097.43265' } ] }\n```\n\n## Installation\n\n    npm install ndjson-aggregator\n\n## CLI\n\nA cli tool name `ndja` will be in your path if you install this package globally.\n\nIt takes a stream of ndjson data from *stdin* and outputs aggregated JSON to *stdout*.\n\n```sh\nndja \u003cproperty\u003e \u003c in-ndjson.data \u003e out.json \n\n## Example\n\nndja name \u003c examples/ndjson.data \u003e out.json \n```\n\n## API\n\n\u003c!-- START docme generated API please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN docme TO UPDATE --\u003e\n\n\u003cdiv\u003e\n\u003cdiv class=\"jsdoc-githubify\"\u003e\n\u003csection\u003e\n\u003carticle\u003e\n\u003cdiv class=\"container-overview\"\u003e\n\u003cdl class=\"details\"\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cdl\u003e\n\u003cdt\u003e\n\u003ch4 class=\"name\" id=\"aggregate\"\u003e\u003cspan class=\"type-signature\"\u003e\u003c/span\u003eaggregate\u003cspan class=\"signature\"\u003e(lines, \u003cspan class=\"optional\"\u003eprop\u003c/span\u003e)\u003c/span\u003e\u003cspan class=\"type-signature\"\u003e \u0026rarr; {Object}\u003c/span\u003e\u003c/h4\u003e\n\u003c/dt\u003e\n\u003cdd\u003e\n\u003cdiv class=\"description\"\u003e\n\u003cp\u003eAggregates lines of \u003ca href=\"http://ndjson.org/\"\u003enew line delimited JSON\u003c/a\u003e into\none JavaScript object keyed by a property if it is supplied.\u003c/p\u003e\n\u003cp\u003eIf the key property is not supplied all ndjson lines will just be\naggregated into one Array.\u003c/p\u003e\n\u003c/div\u003e\n\u003ch5\u003eParameters:\u003c/h5\u003e\n\u003ctable class=\"params\"\u003e\n\u003cthead\u003e\n\u003ctr\u003e\n\u003cth\u003eName\u003c/th\u003e\n\u003cth\u003eType\u003c/th\u003e\n\u003cth\u003eArgument\u003c/th\u003e\n\u003cth class=\"last\"\u003eDescription\u003c/th\u003e\n\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003ctd class=\"name\"\u003e\u003ccode\u003elines\u003c/code\u003e\u003c/td\u003e\n\u003ctd class=\"type\"\u003e\n\u003cspan class=\"param-type\"\u003eArray.\u0026lt;String\u003e\u003c/span\u003e\n\u003c/td\u003e\n\u003ctd class=\"attributes\"\u003e\n\u003c/td\u003e\n\u003ctd class=\"description last\"\u003e\u003cp\u003endjson lines (each line must be parseable JSON)\u003c/p\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd class=\"name\"\u003e\u003ccode\u003eprop\u003c/code\u003e\u003c/td\u003e\n\u003ctd class=\"type\"\u003e\n\u003cspan class=\"param-type\"\u003eString\u003c/span\u003e\n\u003c/td\u003e\n\u003ctd class=\"attributes\"\u003e\n\u0026lt;optional\u003e\u003cbr\u003e\n\u003c/td\u003e\n\u003ctd class=\"description last\"\u003e\u003cp\u003ethe property to key the aggregated JSON by\u003c/p\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003cdl class=\"details\"\u003e\n\u003cdt class=\"tag-source\"\u003eSource:\u003c/dt\u003e\n\u003cdd class=\"tag-source\"\u003e\u003cul class=\"dummy\"\u003e\n\u003cli\u003e\n\u003ca href=\"https://github.com/thlorenz/ndjson-aggregator/blob/master/index.js\"\u003eindex.js\u003c/a\u003e\n\u003cspan\u003e, \u003c/span\u003e\n\u003ca href=\"https://github.com/thlorenz/ndjson-aggregator/blob/master/index.js#L24\"\u003elineno 24\u003c/a\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\u003c/dd\u003e\n\u003c/dl\u003e\n\u003ch5\u003eReturns:\u003c/h5\u003e\n\u003cdiv class=\"param-desc\"\u003e\n\u003cp\u003endjson aggregated into one JavaScript Object\u003c/p\u003e\n\u003c/div\u003e\n\u003cdl\u003e\n\u003cdt\u003e\nType\n\u003c/dt\u003e\n\u003cdd\u003e\n\u003cspan class=\"param-type\"\u003eObject\u003c/span\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/article\u003e\n\u003c/section\u003e\n\u003c/div\u003e\n\n*generated with [docme](https://github.com/thlorenz/docme)*\n\u003c/div\u003e\n\u003c!-- END docme generated API please keep comment here to allow auto update --\u003e\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthlorenz%2Fndjson-aggregator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthlorenz%2Fndjson-aggregator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthlorenz%2Fndjson-aggregator/lists"}