{"id":16974019,"url":"https://github.com/tsuk1ko/fsa-promises","last_synced_at":"2025-10-07T04:29:21.609Z","repository":{"id":254617255,"uuid":"845988914","full_name":"Tsuk1ko/fsa-promises","owner":"Tsuk1ko","description":"Web File System Access API to Node fs promises API","archived":false,"fork":false,"pushed_at":"2025-07-26T08:54:09.000Z","size":41,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-26T12:11:52.964Z","etag":null,"topics":["file-system-access-api","file-system-api","node-fs"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@tsuk1ko/fsa-promises","language":"TypeScript","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/Tsuk1ko.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,"zenodo":null}},"created_at":"2024-08-22T10:18:39.000Z","updated_at":"2025-07-26T08:54:12.000Z","dependencies_parsed_at":"2024-08-27T04:45:21.424Z","dependency_job_id":null,"html_url":"https://github.com/Tsuk1ko/fsa-promises","commit_stats":null,"previous_names":["tsuk1ko/fsa-promises"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/Tsuk1ko/fsa-promises","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tsuk1ko%2Ffsa-promises","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tsuk1ko%2Ffsa-promises/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tsuk1ko%2Ffsa-promises/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tsuk1ko%2Ffsa-promises/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tsuk1ko","download_url":"https://codeload.github.com/Tsuk1ko/fsa-promises/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tsuk1ko%2Ffsa-promises/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269355664,"owners_count":24403479,"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-08T02:00:09.200Z","response_time":72,"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":["file-system-access-api","file-system-api","node-fs"],"created_at":"2024-10-14T01:04:22.053Z","updated_at":"2025-10-07T04:29:16.570Z","avatar_url":"https://github.com/Tsuk1ko.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fsa-promises\n\nWeb File System API to Node fs promises API.\n\nLearn more about: [File System API](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API)\n\n\u003e [!NOTE]  \n\u003e This library was originally implemented for use with [isomorphic-git](https://github.com/isomorphic-git/isomorphic-git). But the actual test found that the performance was so bad and there were inexplicable problems, so I gave up. ☹️\n\n[![NPM version](https://img.shields.io/npm/v/@tsuk1ko/fsa-promises?style=flat-square)](https://www.npmjs.com/package/@tsuk1ko/fsa-promises)\n\n## Install\n\n```bash\n# npm\nnpm install @tsuk1ko/fsa-promises\n\n# yarn\nyarn add @tsuk1ko/fsa-promises\n\n# bun\nbun add @tsuk1ko/fsa-promises\n```\n\n## Usage\n\n```ts\nimport { FsaPromises } from '@tsuk1ko/fsa-promises';\n\n// Use `navigator.storage.getDirectory()` as root\nconst fs = new FsaPromises();\n\n// Use directory \"path/to/some/dir\" of `navigator.storage.getDirectory()` as root,\n// will be create recursively if not exists\nconst fs = new FsaPromises('path/to/some/dir');\n\n// Use `showDirectoryPicker()` to select a directory as root\nconst fs = new FsaPromises(showDirectoryPicker({ mode: 'readwrite' }));\n\n// Use almost the same way as node fsPromises module\nawait fs.writeFile('file.txt', 'hello world');\n```\n\n## APIs\n\n### `new FsaPromises([options])`\n\n`options` can be `string`, `FileSystemDirectoryHandle`, `Promise\u003cFileSystemDirectoryHandle\u003e` or an `FsaPromisesOptions` object.\n\n```ts\ninterface FsaPromisesOptions {\n  root?: string | FileSystemDirectoryHandle | Promise\u003cFileSystemDirectoryHandle\u003e;\n  useSyncAccessHandleForFile?: boolean;\n  cacheDirHandle?: boolean;\n}\n```\n\n#### `useSyncAccessHandleForFile`\n\nWhen it is `true`, the library will use `createSyncAccessHandle()` instead of `createWritable()` to write file.\n\nIt is only usable inside dedicated Web Workers with the origin private file system.\n\nFor more information, please check [here](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/createSyncAccessHandle).\n\n#### `cacheDirHandle`\n\nWhether to enable directory handle cache.\n\nWhen it is `true`, all `FileSystemDirectoryHandle` objects created at runtime will be cached until they are deleted via `rmdir()` or manually by calling `clearDirCache()`.\n\nThis is useful when you need to frequently read or write files in deep directories, as it avoids creating new `FileSystemDirectoryHandle` objects layer by layer each time.\n\nHowever, please note that if other processes are also operating on the file system, this may lead to unexpected behavior. For example, if a directory is deleted elsewhere, you may need to call `clearDirCache()` at the appropriate time.\n\n### `readFile(path[, options])`\n\nRefer to [fsPromises.readFile](https://nodejs.org/api/fs.html#fspromisesreadfilepath-options).\n\n`flag` and `signal` are not supported.\n\n### `writeFile(file, data[, options])`\n\nRefer to [fsPromises.writeFile](https://nodejs.org/api/fs.html#fspromiseswritefilefile-data-options).\n\n`mode` is not supported.\n\n`flush` is usable only when `useSyncAccessHandleForFile` is `true`.\n\n`signal` is not usable when `useSyncAccessHandleForFile` is `true`.\n\n#### `options.ensureDir`\n\nThis option is added for convenience and does not exist in the standard options.\n\nWhen it is set to `true`, directories will be created recursively and automatically.\n\n### `unlink(path)`\n\nRefer to [fsPromises.unlink](https://nodejs.org/api/fs.html#fspromisesunlinkpath).\n\n### `readdir(path[, options])`\n\nRefer to [fsPromises.readdir](https://nodejs.org/api/fs.html#fspromisesreaddirpath-options).\n\n`encoding` only support `undefine`, `null` or `\"buffer\"`.\n\n### `mkdir(path[, options])`\n\nRefer to [fsPromises.mkdir](https://nodejs.org/api/fs.html#fspromisesmkdirpath-options).\n\n`mode` is not supported.\n\n### `rmdir(path[, options])`\n\nRefer to [fsPromises.rmdir](https://nodejs.org/api/fs.html#fspromisesrmdirpath-options).\n\n`maxRetries` and `retryDelay` are not supported.\n\n### `exists(path)`\n\nThis API does not exist in node fsPromises. It is provided for convenience.\n\n### `stat(path[, options])`\n\nRefer to [fsPromises.stat](https://nodejs.org/api/fs.html#fspromisesstatpath-options).\n\n### `lstat(path[, options])`\n\nSame as `stat()` because symlink isn't implemented.\n\n### `readlink(path[, options])`\n\nNot implemented, don't use.\n\n### `symlink(target, path[, type])`\n\nNot implemented, don't use.\n\n### `chmod(path, mode)`\n\nDo nothing, just for compatibility.\n\n### `clearDirCache()`\n\nClear directory handle cache.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsuk1ko%2Ffsa-promises","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsuk1ko%2Ffsa-promises","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsuk1ko%2Ffsa-promises/lists"}