vvvfs 0.1.6 → 0.1.7
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 +14 -0
- package/index.ts +4 -0
- package/package.json +1 -1
- package/types/index.d.ts +3 -1
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
一个使用Dexie.js,基于IndexedDB的轻量、简单的浏览器中的Linux虚拟文件系统
|
|
4
4
|
|
|
5
|
+
GitHub仓库: https://github.com/IFTC-XLKJ/vvvfs
|
|
6
|
+
|
|
5
7
|
## 快速开始
|
|
6
8
|
|
|
7
9
|
1. 安装依赖
|
|
@@ -32,6 +34,7 @@ const VVVFS = require("vvvfs"); // CommonJS
|
|
|
32
34
|
```javascript
|
|
33
35
|
const vvvfs = new VVVFS("vvvfs", {
|
|
34
36
|
throwError: true, // 设置为true后,操作文件失败时,不会返回false,而是会抛出错误
|
|
37
|
+
init: "IFTC", // 自动初始化,用户名为 IFTC
|
|
35
38
|
}); // 创建一个名为vvvfs的虚拟文件系统
|
|
36
39
|
```
|
|
37
40
|
|
|
@@ -92,6 +95,10 @@ const vvvfs = new VVVFS("vvvfs", {
|
|
|
92
95
|
|
|
93
96
|
## 更新日志
|
|
94
97
|
|
|
98
|
+
### 0.1.7
|
|
99
|
+
|
|
100
|
+
- 新增 `init` 选项,用于是否自动初始化,传入字符串时,则为初始化的用户名,传入true时,则为默认用户名。
|
|
101
|
+
|
|
95
102
|
### 0.1.6
|
|
96
103
|
|
|
97
104
|
- 新增 `VVVFS.path` ,用法与 NodeJS 的 `path` 模块类似。
|
|
@@ -168,6 +175,8 @@ const vvvfs = new VVVFS("vvvfs", {
|
|
|
168
175
|
|
|
169
176
|
A lightweight and simple Linux virtual file system in the browser, based on IndexedDB, built with Dexie.js
|
|
170
177
|
|
|
178
|
+
GitHub repository: https://github.com/IFTC-XLKJ/vvvfs
|
|
179
|
+
|
|
171
180
|
## Quick Start
|
|
172
181
|
|
|
173
182
|
1. Install the dependency
|
|
@@ -198,6 +207,7 @@ const VVVFS = require("vvvfs"); // CommonJS
|
|
|
198
207
|
```javascript
|
|
199
208
|
const vvvfs = new VVVFS("vvvfs", {
|
|
200
209
|
throwError: true, // When set to true, failed file operations throw an error instead of returning false
|
|
210
|
+
init: "IFTC", // Automatically initialize with the username IFTC
|
|
201
211
|
}); // Create a virtual file system named vvvfs
|
|
202
212
|
```
|
|
203
213
|
|
|
@@ -258,6 +268,10 @@ Using the `VVVFS.File` class:
|
|
|
258
268
|
|
|
259
269
|
## Changelog
|
|
260
270
|
|
|
271
|
+
### 0.1.7
|
|
272
|
+
|
|
273
|
+
- Added the `init` option to control automatic initialization: when passed a string, it is used as the username for initialization; when passed `true`, the default username is used.
|
|
274
|
+
|
|
261
275
|
### 0.1.6
|
|
262
276
|
|
|
263
277
|
- Added `VVVFS.path`, which works in a similar way to the `path` module in NodeJS.
|
package/index.ts
CHANGED
|
@@ -37,9 +37,11 @@ export interface VVVFSDatabase extends Dexie {
|
|
|
37
37
|
/**
|
|
38
38
|
* 虚拟文件系统配置项
|
|
39
39
|
* @param throwError 是否抛出错误
|
|
40
|
+
* @param init 是否自动初始化,传入字符串时,为用户名,传入true时,使用默认用户名
|
|
40
41
|
*/
|
|
41
42
|
export interface VVVFSOptions {
|
|
42
43
|
throwError: boolean;
|
|
44
|
+
init: boolean | string;
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
/**
|
|
@@ -582,6 +584,7 @@ class VVVFS {
|
|
|
582
584
|
name?: string,
|
|
583
585
|
options = {
|
|
584
586
|
throwError: false,
|
|
587
|
+
init: false,
|
|
585
588
|
},
|
|
586
589
|
) {
|
|
587
590
|
this.options = options;
|
|
@@ -599,6 +602,7 @@ class VVVFS {
|
|
|
599
602
|
}
|
|
600
603
|
});
|
|
601
604
|
});
|
|
605
|
+
this.options.init ? this.init(this.options.init == true ? "root" : this.options.init) : void 0;
|
|
602
606
|
} catch (error) {
|
|
603
607
|
console.error("创建数据库失败", error);
|
|
604
608
|
throw new VVVFSError("CreateDatabase", "创建数据库失败");
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -44,9 +44,11 @@ declare interface VVVFSDatabase extends Dexie {
|
|
|
44
44
|
/**
|
|
45
45
|
* 虚拟文件系统配置项
|
|
46
46
|
* @param throwError 是否抛出错误
|
|
47
|
+
* @param init 是否自动初始化,传入字符串时,为用户名,传入true时,使用默认用户名
|
|
47
48
|
*/
|
|
48
|
-
|
|
49
|
+
export interface VVVFSOptions {
|
|
49
50
|
throwError: boolean;
|
|
51
|
+
init: boolean | string;
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
/**
|