{"id":13454497,"url":"https://github.com/jahewson/node-byline","last_synced_at":"2025-10-08T09:19:41.752Z","repository":{"id":42187260,"uuid":"2304658","full_name":"jahewson/node-byline","owner":"jahewson","description":"Line-by-line Stream reader for node.js","archived":false,"fork":false,"pushed_at":"2019-11-06T16:27:58.000Z","size":394,"stargazers_count":324,"open_issues_count":13,"forks_count":48,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-10T06:39:14.508Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/jahewson/node-byline","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jahewson.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":"2011-08-31T22:49:40.000Z","updated_at":"2025-02-11T15:47:13.000Z","dependencies_parsed_at":"2022-09-06T11:11:28.260Z","dependency_job_id":null,"html_url":"https://github.com/jahewson/node-byline","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jahewson%2Fnode-byline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jahewson%2Fnode-byline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jahewson%2Fnode-byline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jahewson%2Fnode-byline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jahewson","download_url":"https://codeload.github.com/jahewson/node-byline/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254319716,"owners_count":22051072,"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-07-31T08:00:54.698Z","updated_at":"2025-10-08T09:19:41.653Z","avatar_url":"https://github.com/jahewson.png","language":"JavaScript","readme":"# byline — buffered stream for reading lines\n\n![npm package](https://nodei.co/npm/byline.png?downloads=true\u0026downloadRank=true)\n\n`byline` is a simple module providing a `LineStream`.\n\n- node v0.10 `streams2` (transform stream)\n- supports `pipe`\n- supports both UNIX and Windows line endings\n- supports [Unicode UTS #18 line boundaries](http://www.unicode.org/reports/tr18/#Line_Boundaries)\n- can wrap any readable stream\n- can be used as a readable-writable \"through-stream\" (transform stream)\n- super-simple: `stream = byline(stream);`\n\n## Install\n\n    npm install byline\n\nor from source:\n\n    git clone git://github.com/jahewson/node-byline.git\n    cd node-byline\n    npm link\n\n# Convenience API\n\nThe `byline` module can be used as a function to quickly wrap a readable stream:\n\n```javascript\nvar fs = require('fs'),\n    byline = require('byline');\n\nvar stream = byline(fs.createReadStream('sample.txt', { encoding: 'utf8' }));\n```\n\nThe `data` event then emits lines:\n\n```javascript\nstream.on('data', function(line) {\n  console.log(line);\n});\n```\n\n# Standard API\n    \nYou just need to add one line to wrap your readable `Stream` with a `LineStream`.\n\n```javascript\nvar fs = require('fs'),\t\n    byline = require('byline');\n\nvar stream = fs.createReadStream('sample.txt');\nstream = byline.createStream(stream);\n\nstream.on('data', function(line) {\n  console.log(line);\n});\n```\n\n# Piping\n\n`byline` supports `pipe` (though it strips the line endings, of course).\n\n```javascript\nvar stream = fs.createReadStream('sample.txt');\nstream = byline.createStream(stream);\nstream.pipe(fs.createWriteStream('nolines.txt'));\n```\n\nAlternatively, you can create a readable/writable \"through-stream\" which doesn't wrap any specific\nstream:\n\n```javascript\nvar stream = fs.createReadStream('sample.txt');\nstream = byline.createStream(stream);\nstream.pipe(fs.createWriteStream('nolines.txt'));\n\t\nvar input = fs.createReadStream('LICENSE');\nvar lineStream = byline.createStream();\ninput.pipe(lineStream);\n\nvar output = fs.createWriteStream('test.txt');\nlineStream.pipe(output);\n```\n\n# Streams2 API\n    \nNode v0.10 added a new streams2 API. This allows the stream to be used in non-flowing mode and is\npreferred over the legacy pause() and resume() methods.\n\n```javascript\nvar stream = fs.createReadStream('sample.txt');\nstream = byline.createStream(stream);\n\nstream.on('readable', function() {\n  var line;\n  while (null !== (line = stream.read())) {\n    console.log(line);\n  }\n});\n```\n\n# Transform Stream\n\nThe `byline` transform stream can be directly manipulated like so:\n\n```javascript\nvar LineStream = require('byline').LineStream;\n\nvar input = fs.createReadStream('sample.txt');\nvar output = fs.createWriteStream('nolines.txt');\n\nvar lineStream = new LineStream();\ninput.pipe(lineStream);\nlineStream.pipe(output);\n\n```\n\n# Empty Lines\n\nBy default byline skips empty lines, if you want to keep them, pass the `keepEmptyLines` option in\nthe call to `byline.createStream(stream, options)` or `byline(stream, options)`.\n\n# Tests\n\n    npm test\n\n# v0.8\n\nIf you want to use `node-byline` with node v0.8 then you can use the 2.1.x series. Simply use the\nfollowing in your `package.json`:\n\n```javascript\n  \"dependencies\": {\n  \"byline\": \"\u003e=2.1.0 \u003c3.0.0\"\n},\n```\n\n# Simple\nUnlike other modules (of which there are many), `byline` contains no:\n\n- monkeypatching\n- dependencies\n- non-standard 'line' events which break `pipe`\n- limitations to only file streams\n- CoffeeScript\n- unnecessary code\n","funding_links":[],"categories":["Packages","Modules","Repository","包","目录","JavaScript","Streams"],"sub_categories":["Streams","文件流","流处理","流"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjahewson%2Fnode-byline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjahewson%2Fnode-byline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjahewson%2Fnode-byline/lists"}