Installations
npm install @wwog/idbfs
Developer Guide
Typescript
Yes
Module System
ESM
Node Version
20.15.1
NPM Version
10.7.0
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (99.41%)
HTML (0.59%)
Developer
wwog
Download Statistics
Total Downloads
323
Last Day
1
Last Week
8
Last Month
25
Last Year
323
GitHub Statistics
3 Commits
1 Watching
1 Branches
1 Contributors
Bundle Size
11.78 kB
Minified
3.66 kB
Minified + Gzipped
Sponsor this package
Package Meta Information
Latest Version
1.0.2
Package Id
@wwog/idbfs@1.0.2
Unpacked Size
64.76 kB
Size
12.69 kB
File Count
8
NPM Version
10.7.0
Node Version
20.15.1
Publised On
29 Jul 2024
Total Downloads
Cumulative downloads
Total Downloads
323
Last day
0%
1
Compared to previous day
Last week
60%
8
Compared to previous week
Last month
108.3%
25
Compared to previous month
Last year
0%
323
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
4
IndexedDB File System
A file system built on the front end of the web, using
indexedDB
as the back-end storage, as an alternative storage solution or compatible solution for Opfs. It supports reading and writing of filestream
and can be used for uploading and downloading large files..Most of the APIs refer to NodeJS, which is used in a similar way.
Features
- Support
Stream
Api - Store file data in chunks to IndexedDB
- Maintain metadata of files
- Support Save disk
Useage
1import { mount } from "@wwog/idbfs"; 2 3const fs = await mount(); 4 5const result = await fs.readdir("/"); 6console.log(result); // {dirs:[], files:[]}
Write the file to the disk
1const handle = await window.showSaveFilePicker(); 2//Use the stream internally 3await fs.saveFile(handle, "/bigFile");
Streams the selected file into IDBFS
1const file = fileInput.files?.[0]; 2if (!file) { 3 return alert("please select file"); 4} 5const path = "/" + file.name; 6const idbFile = await fs.createFile(path, { mimeType: file.type }); 7const wStream = fs.createWriteStream(idbFile); 8await file.stream().pipeTo(wStream);
Read the file from the disk
1import { streamToAsyncIterator } from "@wwog/idbfs"; 2const rStream = fs.createReadStream(path); 3for await (chunk of streamToAsyncIterator(rStream)) { 4 console.log(chunk); 5}
FS API
- async appendFile(path: string|IDBFile, data: ArrayBuffer): Promise
; - async getFile(path: string): Promise
- async save(dbHandle: FileSystemFileHandle, path: string): Promise
- async createFile(path: string, desc: FileDesc): Promise
- createWriteStream(file: IDBFile): WritableStream
- createReadStream(path: string): ReadableStream
- async rm(path: string, recursive?: boolean): Promise
- async readdir(path: string): Promise<{ dirs: Directory[]; files: IDBFile[] }>
- async writeFileByWebFile(path: string, file: File): Promise
- async writeFile(path: string,data: ArrayBuffer,desc: FileDesc): Promise
- async readFile(path: string): Promise
- async mkdir(path: string): Promise
- async stat(path: string): Promise
- async exists(path: string): Promise
No vulnerabilities found.
No security vulnerabilities found.