{"id":16186210,"url":"https://github.com/zenflow/stream-line-reader","last_synced_at":"2025-04-07T13:22:03.874Z","repository":{"id":57372009,"uuid":"312661442","full_name":"zenflow/stream-line-reader","owner":"zenflow","description":"Read through a stream of lines on-demand","archived":false,"fork":false,"pushed_at":"2020-11-13T20:10:25.000Z","size":77,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-24T06:03:10.328Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zenflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-13T19:06:52.000Z","updated_at":"2020-11-13T20:10:28.000Z","dependencies_parsed_at":"2022-08-30T16:42:46.884Z","dependency_job_id":null,"html_url":"https://github.com/zenflow/stream-line-reader","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenflow%2Fstream-line-reader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenflow%2Fstream-line-reader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenflow%2Fstream-line-reader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenflow%2Fstream-line-reader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zenflow","download_url":"https://codeload.github.com/zenflow/stream-line-reader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247657249,"owners_count":20974350,"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-10T07:17:36.201Z","updated_at":"2025-04-07T13:22:03.830Z","avatar_url":"https://github.com/zenflow.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stream-line-reader\n\nRead through a stream of lines on-demand\n\n[![npm stats](https://nodei.co/npm/stream-line-reader.png?compact=true)](http://npmjs.com/package/stream-line-reader)\n\n[![CI status](https://img.shields.io/github/workflow/status/zenflow/stream-line-reader/CI?logo=GitHub\u0026label=CI)](https://github.com/zenflow/stream-line-reader/actions?query=branch%3Amaster)\n[![dependencies status](https://img.shields.io/david/zenflow/stream-line-reader)](https://david-dm.org/zenflow/stream-line-reader)\n[![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability-percentage/zenflow/stream-line-reader?logo=Code%20Climate)](https://codeclimate.com/github/zenflow/stream-line-reader)\n[![Known Vulnerabilities](https://snyk.io/test/github/zenflow/stream-line-reader/badge.svg?targetFile=package.json)](https://snyk.io/test/github/zenflow/stream-line-reader?targetFile=package.json)\n[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)\n\n## Installation\n\n```\n$ npm install stream-line-reader\n```\n\n## Usage\n\n```js\nconst { spawn } = require('child_process');\nconst { StreamLineReader } = require('stream-line-reader');\n\nasync function example () {\n  const child = spawn('my-calculator-program');\n  const lines = new StreamLineReader(child.stdout);\n\n  console.log(await lines.readUntil('Done startup'));\n  // -\u003e ['Starting...', 'Done startup']\n\n  child.stdin.write('1+2\\n');\n  console.log(await lines.readUntil(/^Answer:/));\n  // -\u003e ['Question: 1+2', 'Calculating...', 'Answer: 3']\n\n  child.stdin.write('3+4\\n');\n  console.log(await lines.readUntil(line =\u003e line.startsWith('Answer:')));\n  // -\u003e ['Question: 3+4', 'Calculating...', 'Answer: 7']\n\n  child.stdin.end();\n  console.log(await lines.readRemaining());\n  // -\u003e ['Bye!', '']\n}\n\n```\n\nInstance can be created with a single stream, or an array of streams,\nin which case they are merged (interleaved), to be read as one stream.\n\nIf during a call to `.readUntil()` the stream ends without emitting a matching line,\nan error will be raised with details for debugging.\n\nInstances also have a `.readBuffered()` method for when some time has passed\nand you just want to read whatever lines have become available.\nIt takes no arguments and returns synchronously an array of lines.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenflow%2Fstream-line-reader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzenflow%2Fstream-line-reader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenflow%2Fstream-line-reader/lists"}