{"id":19557366,"url":"https://github.com/andrefs/node-read-record","last_synced_at":"2025-09-08T15:41:18.127Z","repository":{"id":35035074,"uuid":"197796036","full_name":"andrefs/node-read-record","owner":"andrefs","description":"Async generator functions which return records read from a stream, string or text file using a custom record separator.","archived":false,"fork":false,"pushed_at":"2022-12-30T18:17:36.000Z","size":54,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-14T20:18:37.268Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/andrefs.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":"2019-07-19T15:15:50.000Z","updated_at":"2019-08-29T19:54:18.000Z","dependencies_parsed_at":"2023-01-15T12:28:01.165Z","dependency_job_id":null,"html_url":"https://github.com/andrefs/node-read-record","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrefs%2Fnode-read-record","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrefs%2Fnode-read-record/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrefs%2Fnode-read-record/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrefs%2Fnode-read-record/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrefs","download_url":"https://codeload.github.com/andrefs/node-read-record/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240814864,"owners_count":19861957,"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-11-11T04:42:05.606Z","updated_at":"2025-02-26T08:15:29.317Z","avatar_url":"https://github.com/andrefs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# read-record\n\nAsync generator functions which return records read from a stream,\nstring or text file using a custom record separator.\n\nIn Perl or Awk, by default, files are read line by line, because `\\n`\nis used as the record or input field separator. If you want to change\nthis (to read records separated, for example, by ';' you can chage\n`$/` (in Perl) or `RS` (in Awk) to ';'.\n\nNode.js `readline` module\n[documentation](https://nodejs.org/api/readline.html#readline_rl_symbol_asynciterator)\nexplains how to use a `for await...of` loop to read lines from a file.\nBut what if it is not lines you want to read?\n\n## Install\n\n```shell\nnpm i -S read-record\n```\n\n```js\nconst rr = require('read-record');\n```\n\n[Try it in your browser](https://npm.runkit.com/read-record)\n\n\n## API\n\n* `rr.records(stream, recsep)`\n  * `stream` is a [Readable\n  Stream](https://nodejs.org/api/stream.html#stream_readable_streams)\n  * `recsep` is either a String or Regular Expression (anything that can\nbe passed on to `String.split()` method)\n\n* `rr.recordsFromFile(path, recsep)`\n  * `path` is a String containing a valid path to a text file.\n\n* `rr.recordsFromString(str, recsep)`\n  * `str` is a String.\n\n## Example\n\n```js\nconst rr = require('read-record');\n\nconst records = rr.recordsFromString('This is a string', ' ');\n\nfor await (const rec of records){\n  console.log(rec);\n}\n\n// This\n// is\n// a\n// string\n```\n\n## To do\n\n* add option to discard empty records\n* add option to define size of `fs.createReadStream` `highWaterMark`\n* add option to define size of `fs.createReadStream` `encoding`\n  param\n* evalutate (and increase) efficiency\n* use event 'line' instead of `for await...of` loop\n* use `indexOf` instead of regular expressions?\n\n\n## Bugs and stuff\nOpen a GitHub issue or, preferably, send me a pull request.\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2019 André Santos \u003candrefs@andrefs.com\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrefs%2Fnode-read-record","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrefs%2Fnode-read-record","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrefs%2Fnode-read-record/lists"}