vvvfs 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # VVVFS
2
2
 
3
- 一个使用Dexie.js,基于IndexedDB的轻量、简单的Linux虚拟文件系统
3
+ 一个使用Dexie.js,基于IndexedDB的轻量、简单的浏览器中的Linux虚拟文件系统
4
4
 
5
5
  ## 快速开始
6
6
 
@@ -31,7 +31,7 @@ const VVVFS = require("vvvfs"); // CommonJS
31
31
 
32
32
  ```javascript
33
33
  const vvvfs = new VVVFS("vvvfs", {
34
- throwError: true, // 设置为true后,操作文件失败时,不会返回false,而是会抛出错误
34
+ throwError: true, // 设置为true后,操作文件失败时,不会返回false,而是会抛出错误
35
35
  }); // 创建一个名为vvvfs的虚拟文件系统
36
36
  ```
37
37
 
@@ -40,50 +40,62 @@ const vvvfs = new VVVFS("vvvfs", {
40
40
  ```javascript
41
41
  // 所有操作都是异步的
42
42
  (async function () {
43
- await vvvfs.reset(); // 重置文件系统
44
- await vvvfs.init("UserName"); // 初始化文件系统
45
- await vvvfs.createDir("/home/user/Desktop"); // 创建目录,返回true和false
46
- await vvvfs.writeText(
47
- "/home/user/Desktop/test.txt",
48
- "Hello World!"
49
- ); // 写入文本文件,写入文件还包括write(path: string, content: Blob)和writeJson(path: string, content: Record<string, any>)方法,返回true和false
50
- console.log(await vvvfs.readText("/home/user/Desktop/test.txt")); // 读取文本文件,读取文件还包括read(path: string): Blob | null和readJson(path: string): Record<string, any> | null方法
51
- await vvvfs.delete("/home/user/Desktop/test.txt"); // 删除文件,返回true和false
52
- if (await vvvfs.exists("/home/user/Desktop")) {
53
- // 判断文件或目录是否存在
54
- }
55
- console.log(await vvvfs.list("/home/user/Desktop")); // 列出目录下的文件,返回string[] | null
56
- if (await vvvfs.isDir("/home/user/Desktop")) {
57
- // 判断是否为目录
58
- }
59
- if (await vvvfs.isFile("/home/user/Desktop/test.txt")) {
60
- // 判断是否为文件
61
- }
62
- await vvvfs.rename(
63
- "/home/user/Desktop/test.txt",
64
- "test2.txt",
65
- ); // 重命名文件,返回true和false
66
- await vvvfs.move(
67
- "/home/user/Desktop/test2.txt",
68
- "/home/user/Desktop/test.txt",
69
- ); // 移动文件,返回true和false
70
- await vvvfs.copy(
71
- "/home/user/Desktop/test.txt",
72
- "/home/user/Desktop/test2.txt",
73
- ); // 复制文件,返回true和false
74
- await vvvfs.search("/home/user/Desktop", "test.txt"); // 搜索文件,返回string[] | null
43
+ await vvvfs.reset(); // 重置文件系统
44
+ await vvvfs.init("UserName"); // 初始化文件系统
45
+ await vvvfs.createDir("/home/user/Desktop"); // 创建目录,返回true和false
46
+ await vvvfs.writeText("/home/user/Desktop/test.txt", "Hello World!"); // 写入文本文件,写入文件还包括write(path: string, content: Blob)和writeJson(path: string, content: Record<string, any>)方法,返回true和false
47
+ console.log(await vvvfs.readText("/home/user/Desktop/test.txt")); // 读取文本文件,读取文件还包括read(path: string): Blob | null和readJson(path: string): Record<string, any> | null方法
48
+ await vvvfs.delete("/home/user/Desktop/test.txt"); // 删除文件,返回true和false
49
+ if (await vvvfs.exists("/home/user/Desktop")) {
50
+ // 判断文件或目录是否存在
51
+ }
52
+ console.log(await vvvfs.list("/home/user/Desktop")); // 列出目录下的文件,返回string[] | null
53
+ if (await vvvfs.isDir("/home/user/Desktop")) {
54
+ // 判断是否为目录
55
+ }
56
+ if (await vvvfs.isFile("/home/user/Desktop/test.txt")) {
57
+ // 判断是否为文件
58
+ }
59
+ await vvvfs.rename("/home/user/Desktop/test.txt", "test2.txt"); // 重命名文件,返回true和false
60
+ await vvvfs.move("/home/user/Desktop/test2.txt", "/home/user/Desktop/test.txt"); // 移动文件,返回true和false
61
+ await vvvfs.copy("/home/user/Desktop/test.txt", "/home/user/Desktop/test2.txt"); // 复制文件,返回true和false
62
+ await vvvfs.search("/home/user/Desktop", "test.txt"); // 搜索文件,返回string[] | null
75
63
  })();
76
64
  ```
77
65
 
66
+ 使用 `VVVFS.File` 类:
67
+
68
+ ```javascript
69
+ (async function () {
70
+ const file = new VVVFS.File("/home/user/Desktop/test.txt");
71
+ await file.writeText("Hello World!");
72
+ console.log(await file.readText());
73
+ await file.delete();
74
+ })();
75
+ // 用法与 vvvfs 相当
76
+ ```
77
+
78
78
  ## 更新日志
79
79
 
80
+ ### 0.0.5
81
+
82
+ - 新增 `VVVFS.File` 类
83
+
84
+ ### 0.0.4
85
+
86
+ - 修复IndexDB弹出一堆警告
87
+ - 修复 `search` 搜索时的bug
88
+
80
89
  ### 0.0.3
81
- - 添加完整路径和文件名最长值限制,完整路径最长4096字符,文件名最长255字符
82
- - 添加 `init` 方法,用于初始化Linux文件和目录
83
- - 修复 `list` 方法列出根目录时返回的数组中有空字符串的bug,该空字符串是根目录自身
90
+
91
+ - 添加完整路径和文件名最长值限制,完整路径最长4096字符,文件名最长255字符
92
+ - 添加 `init` 方法,用于初始化Linux文件和目录
93
+ - 修复 `list` 方法列出根目录时返回的数组中有空字符串的bug,该空字符串是根目录自身
84
94
 
85
95
  ### 0.0.2
86
- - 添加 `throwError` 选项,默认为 `false`
96
+
97
+ - 添加 `throwError` 选项,默认为 `false`
87
98
 
88
99
  ### 0.0.1
89
- - 发布正式版
100
+
101
+ - 发布正式版