{"id":17109563,"url":"https://github.com/monken/node-splitly","last_synced_at":"2026-01-19T07:32:36.858Z","repository":{"id":42963830,"uuid":"225253459","full_name":"monken/node-splitly","owner":"monken","description":"Split a stream on a new-line character and reassemble it into line-sized chunks. Zero dependencies with a focus on speed and simplicity.","archived":false,"fork":false,"pushed_at":"2023-03-04T05:19:55.000Z","size":428,"stargazers_count":1,"open_issues_count":8,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-25T17:58:24.460Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/monken.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-02T00:37:24.000Z","updated_at":"2021-08-11T22:57:46.000Z","dependencies_parsed_at":"2025-02-12T08:28:43.428Z","dependency_job_id":null,"html_url":"https://github.com/monken/node-splitly","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/monken/node-splitly","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monken%2Fnode-splitly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monken%2Fnode-splitly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monken%2Fnode-splitly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monken%2Fnode-splitly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/monken","download_url":"https://codeload.github.com/monken/node-splitly/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monken%2Fnode-splitly/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28562993,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T03:31:16.861Z","status":"ssl_error","status_checked_at":"2026-01-19T03:31:15.069Z","response_time":67,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-14T16:23:37.450Z","updated_at":"2026-01-19T07:32:36.840Z","avatar_url":"https://github.com/monken.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![GitHub Workflow Status](https://img.shields.io/github/workflow/status/monken/node-splitly/build?style=flat-square)\n![Apache License](https://img.shields.io/badge/license-Apache--2.0-yellow?style=flat-square)\n![Dependencies](https://img.shields.io/badge/dependencies-0-blue?style=flat-square)\n\n# Splitly\n\nSplits a stream on a new-line character and reassemble it into a stream of line-sized chunks. Zero dependencies with a focus on speed and simplicity.\n\nThere are a number of alternatives our there, namely [split](https://github.com/dominictarr/split), [binary-split](https://github.com/maxogden/binary-split) and [split2](https://github.com/mcollina/split2). All of which are significantly slower than this implementation and some have additional dependencies. Splitly extends `stream.Duplex` instead of `stream.Transform` for greater control over memory pressure and speed.\n\n``` js\nconst splitly = require('splitly');\n\nfs.createReadStream(file)\n  .pipe(splitly.createStream())\n  .on('data', function (line) {\n    // each chunk is a separate line\n    // chunks are buffers and are not stripped of the newline character(s)\n    const trimmed = line.toString().trim();\n  });\n```\n\n**Note:** Usage of the `data` event is not recommended in production code and should only be used for strictly synchronous/blocking code. Instead, pipe the output of the stream to another stream capable of propagating back pressure (such as `process.stdout` or a stream that writes to a database or makes an API call).\n\n`splitly` requires the newline character(s) to be defined as a Buffer, unlike other split stream implementations which also accept regular expressions. Additionally, the newline character is not truncated from the chunk passed to the `data` event. The default newline character is `\\n`. If you want to split on `/\\r?\\n/` instead, keep the default newline character and `trim()` the chunk in the data callback.\n\n# API\n\n## createStream({ newlineChar: Buffer },  DuplexOptions )\n\n* `newlineChar` \\\u003cBuffer\u003e **Default:** `Buffer.from('\\n')`\n* `DuplexOptions` \\\u003cObject\u003e **Default:** `{}` passed to `stream.Duplex` constructor\n\n## Custom Newline Character\n\n``` js\nconst splitly = require('splitly');\n\nconst stream = splitly.createStream({\n  // split on zero-byte delimited lines, must be provided as Buffer\n  newlineChar: Buffer.from('\\0'),\n});\n\n```\n\n# Benchmark\n\n`/dev/null` is the raw performance of piping the test stream to `/dev/null`. This is the lower boundary of the performance that can be achieved. It also makes sure the file is in the OS file cache. See [./benchmark/index.js](./benchmark/index.ts) for details. Run under NodeJS v14.18.3.\n\n| name | time | stdev |\n| -- | -- | -- |\n| /dev/null | 5.41 | 2.67 |\n| **splitly** | 10.35 | 4.91 |\n| split2 | 34.24 | 3.04 |\n| split | 34.71 | 4.78 |\n| byline | 39.55 | 13.72 |\n| binary-split | 46.55 | 9.22 |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonken%2Fnode-splitly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonken%2Fnode-splitly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonken%2Fnode-splitly/lists"}