{"id":16490699,"url":"https://github.com/awinterman/format-stream","last_synced_at":"2025-08-03T00:42:30.771Z","repository":{"id":10381867,"uuid":"12528908","full_name":"AWinterman/format-stream","owner":"AWinterman","description":"read from one stream for a while, then read from another stream, then the first stream again.","archived":false,"fork":false,"pushed_at":"2013-09-08T02:17:07.000Z","size":116,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-09T20:36:54.542Z","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/AWinterman.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":"2013-09-02T00:06:16.000Z","updated_at":"2014-04-17T04:27:28.000Z","dependencies_parsed_at":"2022-09-12T21:00:46.058Z","dependency_job_id":null,"html_url":"https://github.com/AWinterman/format-stream","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/AWinterman/format-stream","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWinterman%2Fformat-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWinterman%2Fformat-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWinterman%2Fformat-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWinterman%2Fformat-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AWinterman","download_url":"https://codeload.github.com/AWinterman/format-stream/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AWinterman%2Fformat-stream/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268479902,"owners_count":24256887,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-11T13:48:45.769Z","updated_at":"2025-08-03T00:42:30.697Z","avatar_url":"https://github.com/AWinterman.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Format-Stream #\n\nA streaming simple formatter. \n\n## API ##\n\n```javascript\nvar format = new Format(token, stream)\n```\n\n`format` is a transform stream that checks if each chunk of data matches the\ntoken. If it does not, then the chunk is passed through. Otherwise, `format`\nemits data from the second argument, `stream` until it is consumed.\n\n## Example ##\nSuppose you have a file called `base-template.html`:\n```html \n\u003chtml\u003e\n    \u003chead\u003e\n        \u003ctitle\u003e\"Your app!\"\u003c/title\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n        {{welcome}}\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\nAnd one called `welcome-template.html`.\n```\n\u003cp\u003e\"Hey you party people!\"\u003c/p\u003e\n```\n\nIn index.js you write:\n```javascript\nvar Sentinal = require('sentinal-stream')\n  , Format = require('format-stream')\n  , token = '{{welcome}}'\n\nvar inside_stream = fs.createReadStream('welcome-template.html')\n  , outside_stream = fs.createReadStream('base-template.html')\n\n// Make sure any instance of {{welcome}} is emitted in its\n// own data event\nvar tokenizer = new Sentinal(new Buffer(token)) \n  , format = new Format(token, inside_stream)\n\noutside_stream\n    .pipe(tokenizer)\n    .pipe(format)\n    .pipe(process.stdout)\n```\n\nThen `node index.js` will print:\n\n```\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003ctitle\u003e\"Your app!\"\u003c/title\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n        \u003cp\u003e\"Hey you party people!\"\u003c/p\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawinterman%2Fformat-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawinterman%2Fformat-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawinterman%2Fformat-stream/lists"}