vvvfs 0.0.1-alpha.2 → 0.0.2

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,基于IndexedDBLinux虚拟文件系统
3
+ 一个使用Dexie.js,基于IndexedDB的轻量、简单的Linux虚拟文件系统
4
4
 
5
5
  ## 快速开始
6
6
 
@@ -30,7 +30,9 @@ const VVVFS = require("vvvfs"); // CommonJS
30
30
  3. 初始化
31
31
 
32
32
  ```javascript
33
- const vvvfs = new VVFS("vvvfs"); // 创建一个名为vvvfs的虚拟文件系统
33
+ const vvvfs = new VVVFS("vvvfs", {
34
+ throwError: true, // 设置为true后,操作文件失败时,不会返回false,而是会抛出错误
35
+ }); // 创建一个名为vvvfs的虚拟文件系统
34
36
  ```
35
37
 
36
38
  4. 使用
@@ -39,18 +41,18 @@ const vvvfs = new VVFS("vvvfs"); // 创建一个名为vvvfs的虚拟文件系统
39
41
  // 所有操作都是异步的
40
42
  (async function () {
41
43
  await vvvfs.reset(); // 重置文件系统
42
- await vvvfs.mkdir("/home/user/Desktop"); // 创建目录
43
- await vvvfs.write(
44
+ await vvvfs.createDir("/home/user/Desktop"); // 创建目录,返回true和false
45
+ await vvvfs.writeText(
44
46
  "/home/user/Desktop/test.txt",
45
- new File(["Hello World!"], "test.txt", { type: "text/plain" }),
46
- ); // 写入文件
47
- console.log(await vvvfs.read("/home/user/Desktop/test.txt")); // 读取文件
48
- await vvvfs.delete("/home/user/Desktop/test.txt"); // 删除文件
47
+ "Hello World!"
48
+ ); // 写入文本文件,写入文件还包括write(path: string, content: Blob)和writeJson(path: string, content: Record<string, any>)方法,返回true和false
49
+ console.log(await vvvfs.readText("/home/user/Desktop/test.txt")); // 读取文本文件,读取文件还包括read(path: string): Blob和readJson(path: string): Record<string, any>方法
50
+ await vvvfs.delete("/home/user/Desktop/test.txt"); // 删除文件,返回true和false
49
51
  if (await vvvfs.exists("/home/user/Desktop")) {
50
- // 判断目录是否存在
52
+ // 判断文件或目录是否存在
51
53
  }
52
- console.log(await vvvfs.list("/home/user/Desktop")); // 列出目录下的文件
53
- if (await vvvfs.isDirectory("/home/user/Desktop")) {
54
+ console.log(await vvvfs.list("/home/user/Desktop")); // 列出目录下的文件,返回string[]
55
+ if (await vvvfs.isDir("/home/user/Desktop")) {
54
56
  // 判断是否为目录
55
57
  }
56
58
  if (await vvvfs.isFile("/home/user/Desktop/test.txt")) {
@@ -58,17 +60,24 @@ const vvvfs = new VVFS("vvvfs"); // 创建一个名为vvvfs的虚拟文件系统
58
60
  }
59
61
  await vvvfs.rename(
60
62
  "/home/user/Desktop/test.txt",
61
- "/home/user/Desktop/test2.txt",
62
- ); // 重命名文件
63
+ "test2.txt",
64
+ ); // 重命名文件,返回true和false
63
65
  await vvvfs.move(
64
66
  "/home/user/Desktop/test2.txt",
65
67
  "/home/user/Desktop/test.txt",
66
- ); // 移动文件
68
+ ); // 移动文件,返回true和false
67
69
  await vvvfs.copy(
68
70
  "/home/user/Desktop/test.txt",
69
71
  "/home/user/Desktop/test2.txt",
70
- ); // 复制文件
71
- await vvvfs.chmod("/home/user/Desktop/test.txt", 0o777); // 修改文件权限
72
- await vvvfs.chown("/home/user/Desktop/test.txt", "root", "root"); // 修改文件所有者
72
+ ); // 复制文件,返回true和false
73
+ await vvvfs.search("/home/user/Desktop", "test.txt"); // 搜索文件,返回string[]
73
74
  })();
74
75
  ```
76
+
77
+ ## 更新日志
78
+
79
+ ### 0.0.2
80
+ - 添加 `throwError` 选项,默认为 `false`
81
+
82
+ ### 0.0.1
83
+ - 发布正式版