Universal js library for reading/writing files.
https://web.dev/storage-for-the-web/
In node, it uses the fs
package to read/write.
The default behavior of the implementation uses the best option available to the browser. The order of preference is as follows:
- File and Entries API
- IndexedDB
- LocalStorage
Both IndexedDB and the Cache API both throw a DOMError named QuotaExceededError when you've exceeded the quota available.
The following web API was chosen to support a generic browser FileSystem.
Feature | Firefox | Chrome | Edge | Safari | IE |
---|---|---|---|---|---|
IndexedDB | yes | yes | yes | yes | no |
The following APIs were all considered in choosing a backend to support
Rejected APIs | Reason |
---|---|
File and Entries API | Requires permission for each request |
Cache | Requires a request URL |
SessionStorage | Limited storage |
LocalStorage | Limited storage |
Cookies | really? |
File System Access API | Chromium only |
WebSQL | deprecated |
Application Cache | deprecated |