{"id":19245085,"url":"https://github.com/rxtoolkit/fs","last_synced_at":"2025-02-23T15:15:41.532Z","repository":{"id":214784034,"uuid":"348911910","full_name":"rxtoolkit/fs","owner":"rxtoolkit","description":"💾 RxJS utilities for working with files and file streams locally","archived":false,"fork":false,"pushed_at":"2024-02-16T18:40:02.000Z","size":481,"stargazers_count":1,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-05T04:49:13.618Z","etag":null,"topics":["files","filesystem","fp","functional-programming","observables","package","reactive-programming","rxjs"],"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/rxtoolkit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2021-03-18T02:10:05.000Z","updated_at":"2024-01-02T15:46:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"5f110979-fb5c-4597-8076-57ccaaedf663","html_url":"https://github.com/rxtoolkit/fs","commit_stats":null,"previous_names":["rxtoolkit/fs"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxtoolkit%2Ffs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxtoolkit%2Ffs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxtoolkit%2Ffs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxtoolkit%2Ffs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rxtoolkit","download_url":"https://codeload.github.com/rxtoolkit/fs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240331362,"owners_count":19784646,"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":["files","filesystem","fp","functional-programming","observables","package","reactive-programming","rxjs"],"created_at":"2024-11-09T17:26:35.540Z","updated_at":"2025-02-23T15:15:41.421Z","avatar_url":"https://github.com/rxtoolkit.png","language":"JavaScript","readme":"# @rxtk/fs\n\u003e 💾 RxJS operators and utilities for working with files and file streams locally\n\n## Installation\nThis is a private package. It requires setting up access in your npm config.\n\n```bash\nnpm i @rxtk/fs\n```\n\n```bash\nyarn add @rxtk/fs\n```\n\n## API\n\n### `appendToFile`\nAppends a stream of data to a file:\n```javascript\nimport path from 'path';\nimport {of} from 'rxjs';\nimport {appendFile} from 'rxfs';\n\nconst data = [\n  '\"animal\",\"coolness\"',\n  '\"dolphin\",10',\n  '\"algea\",1',\n  '\"mermaid\",6',\n  '\"octopus\",9',\n  '\"octopus\",9',\n  '\"narwhale\",8',\n];\n\nconst writeStream$ = of(...data).pipe(\n  appendFile({filePath: path.resolve(__dirname, './output.csv')})\n);\n// write the input observable to the file\nwriteStream$.subscribe(console.log);\n```\n\n### `fromFile`\nStreams data from a file as a stream of Buffers.\n```js\nimport path from 'path';\nimport {fromFile} from '@rxtk/fs';\n\nconst csvContentAsBuffer$ = fromFile({\n  filePath: path.resolve(__dirname, './my-csv.csv'),\n});\ncsvContentBuffer$.subscribe(console.log);\n// \"name\",\"scariness\"\n// \"Blackbeard\",10\n// \"Morgan\",9\n// \"Sparrow\",2\n// \"Crunch\",1\n```\n\n### `shortenChunks`\nTakes a stream of Buffer objects and ensures that they are shortened to the desired size, while preserving order/sequence.  Useful, for example, if you want to control the size of a file upload.\n```js\nimport path from 'path';\nimport {fromFile,shortenChunks} from '@rxtk/fs';\n\nconst csvContentAsBuffer$ = fromFile({\n  filePath: path.resolve(__dirname, './my-csv.csv'),\n});\nconst chunkSize = 512;\nconst shortenedBuffer$ = fileChunk$.pipe(\n  shortenChunks(chunkSize)\n);\nshortenedBuffer$.subscribe(console.log);\n```\n\n### `writeToFile`\nWrites data to file (overwriting any previous contents).\n```js\nimport path from 'path';\nimport {of} from 'rxjs';\nimport {writeToFile} from '@rxtk/fs';\n\nconst data = [\n  '\"animal\",\"coolness\"',\n  '\"dolphin\",10',\n  '\"algea\",1',\n  '\"mermaid\",6',\n  '\"octopus\",9',\n  '\"octopus\",9',\n  '\"narwhale\",8',\n];\n\nconst writeStream$ = of(...data).pipe(\n  writeToFile({filePath: path.resolve(__dirname, './output.csv')})\n);\n// write the input observable to the file\nwriteStream$.subscribe(console.log);\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxtoolkit%2Ffs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frxtoolkit%2Ffs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxtoolkit%2Ffs/lists"}