{"id":21703562,"url":"https://github.com/codemonument/deno_downstream","last_synced_at":"2026-05-15T22:02:25.337Z","repository":{"id":57675657,"uuid":"483795706","full_name":"codemonument/deno_downstream","owner":"codemonument","description":"A deno module for downloading files as a readable stream, which allows for flexible targets and progress display","archived":false,"fork":false,"pushed_at":"2023-06-10T12:19:32.000Z","size":139,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-13T16:09:49.185Z","etag":null,"topics":["deno","library","webstreams"],"latest_commit_sha":null,"homepage":"https://deno.land/x/downstream","language":"TypeScript","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/codemonument.png","metadata":{"files":{"readme":"Readme.md","changelog":"Changelog.md","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":"2022-04-20T20:00:11.000Z","updated_at":"2022-11-11T08:34:31.000Z","dependencies_parsed_at":"2024-11-25T21:43:42.276Z","dependency_job_id":null,"html_url":"https://github.com/codemonument/deno_downstream","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":"codemonument/deno_module_template","purl":"pkg:github/codemonument/deno_downstream","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonument%2Fdeno_downstream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonument%2Fdeno_downstream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonument%2Fdeno_downstream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonument%2Fdeno_downstream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codemonument","download_url":"https://codeload.github.com/codemonument/deno_downstream/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonument%2Fdeno_downstream/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279016059,"owners_count":26085798,"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-10-13T02:00:06.723Z","response_time":61,"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":["deno","library","webstreams"],"created_at":"2024-11-25T21:33:33.111Z","updated_at":"2025-10-13T16:09:49.641Z","avatar_url":"https://github.com/codemonument.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Downstream\n\nA deno module for downloading files in a streaming fashion.\nThe base of this module is `downstream.ts`, which queries the file and returns the ReadableStream\u003cUInt8Array\u003e,\nas well as a progress Stream in percent (from 0 to 100).\n\nThis base function is then augmented with various utility functions for writing this stream into a file\nor passing it to other streams, as I see fit. (Not included yet)\n\n## Simple Usage (without Progress)\n\n```ts\nconst {fileStream, contentLength} = await downstream(File50MB);\n\n// Do anything with the fileStream, what you want, it's a normal WebStream Readable Stream.\n// For Example: Write it to a file:\n\n// 1. Create a Temp File\nconst tempFilePath = await Deno.makeTempFile();\n\n// 2. Open the Temp File for writing\nconst tempFile = await Deno.open(tempFilePath, {write: true});\n\n// 3. Pipe the file stream (readable stream) into the writeable stream of the tempFile\n// CAUTION: The 'await' will block this function until the download has finished!\n// For a solution, see next Usage example: 'Extended Usage (with Progress)'\nawait fileStream.pipeTo(tempFile.writable);\n```\n\n## Extended Usage (with ProgressBar Utility)\n\n```ts\n// 1. Initialize a ProgressBar\nconst progressBar = new ProgressBar({\n\ttitle: 'downloading: ',\n\ttotal: 100,\n});\n\n// 2. Use the downstream function and get the fileStream and the progressStream out\nconst {progressStream, fileStream} = await downstream(File1GB);\n\n// 3. Set up handling of your fileStream\n// CAUTION: DO NOT use await here, since this will block this function from running,\n// until the download has finished!\n// Instead,save the promise which is returned from the pipeTo() operator and await it after the progressStream handling,\n// at the end of this function.\n// If you don't do it like this,\n//  your progress stream will not show anything (since deno is waiting for the file handling to finish)\n\n// 3. a) Generate a temp file\nconst tempFilePath = await Deno.makeTempFile();\nconst tempFile = await Deno.open(tempFilePath, {write: true});\nconst fileHandlingPromise = fileStream.pipeTo(tempFile.writable);\n\n// 4. Get each progress stream event and render the state to the progress bar\nfor await (const progress of progressStream) {\n\tprogressBar.render(Number.parseFloat(progress));\n}\n\n// 5. Await the file handling promise from step 3\nawait fileHandlingPromise;\n\n// 6. Cleanup the temp file\nawait Deno.remove(tempFilePath);\n```\n\n## Running examples\n\nsee `tasks` property in `deno.json`\nRun each key there with `deno task \u003ctask-key\u003e`\n\n## Useful Links\n\n- Big test files for testing these download functions: https://testfiledownload.com/\n- How to pipe streams in deno: https://deno.land/manual/examples/fetch_data#files-and-streams\n- Guide to Web Streams: https://web.dev/streams/#creating-a-transform-stream\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemonument%2Fdeno_downstream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodemonument%2Fdeno_downstream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemonument%2Fdeno_downstream/lists"}