{"id":13482690,"url":"https://github.com/mcollina/syncthrough","last_synced_at":"2026-04-02T23:22:10.062Z","repository":{"id":65412305,"uuid":"76952081","full_name":"mcollina/syncthrough","owner":"mcollina","description":"Transform your data as it pass by, synchronously.","archived":false,"fork":false,"pushed_at":"2024-10-14T08:46:16.000Z","size":55,"stargazers_count":99,"open_issues_count":1,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-30T02:37:05.736Z","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/mcollina.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},"funding":{"github":["mcollina"]}},"created_at":"2016-12-20T11:47:57.000Z","updated_at":"2024-10-22T20:15:04.000Z","dependencies_parsed_at":"2024-05-22T07:26:58.396Z","dependency_job_id":"19efa2ca-a118-45b8-98c1-567dfd10c7ce","html_url":"https://github.com/mcollina/syncthrough","commit_stats":{"total_commits":58,"total_committers":6,"mean_commits":9.666666666666666,"dds":"0.24137931034482762","last_synced_commit":"63f58752f0f0f5d3fcad70d511c0aea75d47aa04"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcollina%2Fsyncthrough","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcollina%2Fsyncthrough/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcollina%2Fsyncthrough/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcollina%2Fsyncthrough/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcollina","download_url":"https://codeload.github.com/mcollina/syncthrough/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247149500,"owners_count":20891954,"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-31T17:01:04.527Z","updated_at":"2026-04-02T23:22:10.052Z","avatar_url":"https://github.com/mcollina.png","language":"JavaScript","funding_links":["https://github.com/sponsors/mcollina"],"categories":["JavaScript","Modules","模块"],"sub_categories":["Stream","数据流-Stream"],"readme":"# syncthrough\u0026nbsp;\u0026nbsp;[![ci](https://github.com/mcollina/syncthrough/actions/workflows/ci.yml/badge.svg)](https://github.com/mcollina/syncthrough/actions/workflows/ci.yml)\n\nTransform your data as it pass by, synchronously.\n\n**syncthrough** is a synchronous transform stream, similar to [Transform\nstream][transform] and [through2](https://github.com/rvagg/through2), but with a synchronous processing function.\n**syncthrough** enforces backpressure, but it maintain no internal\nbuffering, allowing much greater throughput.\nIn fact, it delivers 10x performance over a standard\n[`Transform`][transform].\n\nBecause of the [caveats](#caveats), it is best used in combination of\n[`pipe()`][pipe], [`pump()`][pump], [`pipeline()`][pipeline], or `stream.compose()`.\n\n## Install\n\n```\nnpm i syncthrough --save\n```\n\n## Example\n\n```js\nimport { createReadStream } from 'node:fs'\nimport { pipeline } from 'node:stream/promises'\nimport { syncthrough } from 'syncthrough'\n\nawait pipeline(\n  createReadStream(import.meta.filename),\n  syncthrough(function (chunk) {\n    // there is no callback here\n    // you can return null to end the stream\n    // returning undefined will let you skip this chunk\n    return chunk.toString().toUpperCase()\n  }),\n  process.stdout)\n```\n\n## API\n\n### syncthrough([transform(chunk)], [flush()])\n\nReturns a new instance of `syncthrough`, where `transform(chunk)` is the\ntransformation that will be applied to all incoming chunks.\n\nThe default `transform` function is:\n\n```js\nfunction (chunk) {\n  return chunk\n}\n```\n\nIf it returns `null`, the stream will be closed. If it returns\n`undefined`, the chunk will be skipped.\n\nThere is currently no way to split an incoming chunk into multiple\nchunks.\n\nThe `flush()` function will be called before the transform sends `end()`\non the destination.\n\n### syncthrough([transform(object)], [flush()])\n\nReturns a new instance of `syncthrough`, where `transform(object)` is the\ntransformation that will be applied to all incoming objects.\n\nSyncthrough is compatible with Streams in [Object Mode](https://nodejs.org/api/stream.html#stream_object_mode),\nthe API is exactly the same, simply expect objects instead of buffer chunks.\n\n### instance.push(chunk)\n\nPush a chunk to the destination.\n\n## Caveats\n\nThe API is the same of a streams 3 [`Transform`][transform], with some major differences:\n\n1. *backpressure is enforced*, and the instance performs no buffering,\n   e.g. when `write()` cannot be called after it returns false or it will `throw`\n   (you need to wait for a `'drain'` event).\n2. It does not inherits from any of the Streams classes, and it does not\n   have `_readableState` nor `_writableState`.\n3. it does not have a `read(n)` method, nor it emits the\n   `'readable'` event, the data is pushed whenever ready.\n\n\u003ca name=\"acknowledgements\"\u003e\u003c/a\u003e\n## Acknowledgements\n\nThis project was kindly sponsored by [nearForm](http://nearform.com).\n\n## License\n\nMIT\n\n[transform]: https://nodejs.org/api/stream.html#stream_class_stream_transform\n[pipe]: https://nodejs.org/api/stream.html#stream_readable_pipe_destination_options\n[pump]: https://github.com/mafintosh/pump\n[pipeline]: https://nodejs.org/api/stream.html#streampipelinesource-transforms-destination-options\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcollina%2Fsyncthrough","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcollina%2Fsyncthrough","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcollina%2Fsyncthrough/lists"}