1.2.8 • Published 8 months ago
petit-fs v1.2.8
petit-fs
FileSystem on browser using localStorage. Provides node fs compatible interface(Still in progress).
src/vfsUtil.ts is based on typescript harness.
Supporting methods
existsSync(path: string): boolean;
statSync(path: string): Stats; // Stats only supportes mtime, mtimeMs, isDirectory(), isSymbolicLink(). Time stamps other than mtime may be inaccurate.
utimesSync(path: string, atime: Date, mtime: Date): void;
lstatSync(path: string): Stats;
readdirSync(path: string): string[];
mkdirSync(path: string): void;
rmdirSync(path: string): void;
unlinkSync(path: string): void;
renameSync(src: string, dst: string): void;
symlinkSync(target: string, linkpath: string): void;
realpathSync(path: string): string;
readFileSync(path: string, encoding?: null): Buffer;
readFileSync(path: string, encoding: BufferEncoding): string;
readFileSync(path: string, encoding?: BufferEncoding | null): string | Buffer;
writeFileSync(path: string, data: string | Buffer, encoding?: string | null): void;
writeSync(fd: number, data: string | Buffer, encoding?: string | null): void;
appendFileSync(path: string, data: string | Buffer, encoding?: string | null): void;
watch(path: string, ...opts: any[]): void;
watchFile(path: string, ...opts: any[]): void;
openSync(path: string, mode: string): number; // mode "w" only
closeSync(fd: number): void;Use of RAM disk
fs.mountSync("/mnt/to/","ram") mounts RAM disk instead of localStorage, that have unlimited(Within browser memory) capacity but cleard on unload page.
Representation of files in localStorage
- The key represents the full path of a file.
- The value represents the file content in string
- If the file is a binary file, it is stored in data url.
- Whether the file is binary or text is determined by extension of the file
src/MIMETypes.jsmaps extension to content types. If content type is "text/....", it is regarded as text file
- The key of a directory entry always ends with /
- The value is a JSON with file list and attributes(lastUpdate).
1.2.8
8 months ago
1.2.4
8 months ago
1.2.3
8 months ago
1.2.2
9 months ago
1.2.1
9 months ago
1.2.0
10 months ago
1.1.9
10 months ago
1.1.8
10 months ago
1.1.7
10 months ago
1.1.6
10 months ago
1.1.5
10 months ago
1.1.4
10 months ago
1.1.3
10 months ago
1.1.2
10 months ago
1.1.1
10 months ago
1.1.0
11 months ago
1.0.9
11 months ago
1.0.8
11 months ago
1.0.7
11 months ago
1.0.6
11 months ago
1.0.5
11 months ago
1.0.4
11 months ago
1.0.3
11 months ago
1.0.2
11 months ago
1.0.1
11 months ago
1.0.0
11 months ago