{"id":17659738,"url":"https://github.com/raphamorim/nbfs","last_synced_at":"2025-05-07T15:01:31.959Z","repository":{"id":57309115,"uuid":"95237447","full_name":"raphamorim/nbfs","owner":"raphamorim","description":"NonBlocking ~Nodejs~ File System","archived":false,"fork":false,"pushed_at":"2017-07-30T22:25:25.000Z","size":68,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-20T11:19:38.464Z","etag":null,"topics":["block","extensible","filesystem","fs","nodejs","non-blocking"],"latest_commit_sha":null,"homepage":"","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/raphamorim.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":"2017-06-23T16:30:41.000Z","updated_at":"2023-09-07T09:35:09.000Z","dependencies_parsed_at":"2022-09-20T23:22:14.487Z","dependency_job_id":null,"html_url":"https://github.com/raphamorim/nbfs","commit_stats":null,"previous_names":["raphamorim/ofs"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphamorim%2Fnbfs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphamorim%2Fnbfs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphamorim%2Fnbfs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raphamorim%2Fnbfs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raphamorim","download_url":"https://codeload.github.com/raphamorim/nbfs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252902604,"owners_count":21822259,"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":["block","extensible","filesystem","fs","nodejs","non-blocking"],"created_at":"2024-10-23T16:08:08.773Z","updated_at":"2025-05-07T15:01:31.874Z","avatar_url":"https://github.com/raphamorim.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003enbfs\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003eNonBlocking ~Nodejs~ File System\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://api.travis-ci.org/raphamorim/nbfs.svg?branch=master\"/\u003e\n  \u003cimg src=\"https://ci.appveyor.com/api/projects/status/aaxmlgja7ytam84x/branch/master?svg=true\"/\u003e\n  \u003cimg src=\"https://img.shields.io/npm/v/npm.svg\"/\u003e\n\u003c/p\u003e\n\n# Why?\n\nWhen running an application in NodeJS, it’s single threaded, and will only utilise a single core.\n\nWhen performing cpu-intensive or a great number of tasks, you may see this impacting performance, and see runtime/respond-time increase.\n\nIf your NodeJS Application has 100% cpu-usage and is taking a long time to complete or slow to respond, this can be improved by dividing the work to be done, and spreading it over multiple processes.\n\n### Traditional (Many tasks to a single node process)\n\n\u003cp align=\"center\"\u003e\u003cbr\u003e\u003cimg alt=\"Traditional\" src=\"assets/traditional.png\"/\u003e\u003cbr\u003e\u003c/p\u003e\n\n### Distributed (Many tasks to distributed to multiple worker processes)\n\n\u003cp align=\"center\"\u003e\u003cbr\u003e\u003cimg alt=\"Distributed\" src=\"assets/distributed.png\"/\u003e\u003cbr\u003e\u003c/p\u003e\n\nnbfs creates and manage multiples processes which communicate between themself. This approach helps a lot for a non-blocking nodejs architechure.\n\nEven if you use FS native stream API or based on async ways to this job, will always run on the nodejs main thread (in idle status or not).\n\n[Read more about it](https://medium.com/@NorbertdeLangen/communicating-between-nodejs-processes-4e68be42b917)\n\n# Install\n\nFor install nbfs, just run in your terminal:\n\n```bash\nnpm i nbfs -S\n```\n\n# Streams\n\n## read\n\n```js\nconst { read } = require('nbfs')\nconst stream = read('./my-file.js') // absolute path\n\nstream.on('read', (content) =\u003e {\n  console.log(content) // 'abc'\n})\n\nstream.on('end', (result) =\u003e {\n  console.log(result) // {path: './my-file.js', content: 'abc', operation: 'read'}\n})\n\nstream.on('error', (error) =\u003e {\n  console.log(error)\n})\n```\n\n## write\n\n```js\nconst { write } = require('nbfs')\nconst stream = write('./my-file.js', 'hello-world') // absolute path\n\nstream.on('write', (content) =\u003e {\n  console.log(content) // 'hello-world'\n})\n\nstream.on('end', (result) =\u003e {\n  console.log(result) // {path: './my-file.js', content: 'hello-world', operation: 'write'}\n})\n\nstream.on('error', (error) =\u003e {\n  console.log(error)\n})\n```\n\n## Benchmark\n\n```sh\nfs.readFile x 10,738 ops/sec ±2.46% (77 runs sampled)\nnbfs.read x 7,701 ops/sec ±2.74% (75 runs sampled)\nfs.readFileSync x 49,473 ops/sec ±1.75% (42 runs sampled)\nexec cat x 148 ops/sec ±1.57% (43 runs sampled)\n```\n\n## list\n\n## isDirectory\n\n## folderPath\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraphamorim%2Fnbfs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraphamorim%2Fnbfs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraphamorim%2Fnbfs/lists"}