@zenfs/core 0.4.1 → 0.4.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/dist/backends/backend.d.ts +1 -1
- package/dist/backends/backend.js +1 -1
- package/dist/browser.min.js +3 -3
- package/dist/browser.min.js.map +3 -3
- package/dist/stats.d.ts +16 -0
- package/dist/stats.js +30 -0
- package/license.md +3 -3
- package/package.json +5 -5
- package/readme.md +12 -12
package/dist/stats.d.ts
CHANGED
|
@@ -202,3 +202,19 @@ export declare class BigIntStats extends StatsCommon<bigint> implements Node.Big
|
|
|
202
202
|
*/
|
|
203
203
|
static clone(stats: BigIntStats | Stats): BigIntStats;
|
|
204
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* @returns true if stats is a file.
|
|
207
|
+
*/
|
|
208
|
+
export declare function isFile(stats: StatsLike): boolean;
|
|
209
|
+
/**
|
|
210
|
+
* @returns True if stats is a directory.
|
|
211
|
+
*/
|
|
212
|
+
export declare function isDirectory(stats: StatsLike): boolean;
|
|
213
|
+
/**
|
|
214
|
+
* @returns true if stats is a symbolic link
|
|
215
|
+
*/
|
|
216
|
+
export declare function isSymbolicLink(stats: StatsLike): boolean;
|
|
217
|
+
export declare function isSocket(): boolean;
|
|
218
|
+
export declare function isBlockDevice(): boolean;
|
|
219
|
+
export declare function isCharacterDevice(): boolean;
|
|
220
|
+
export declare function isFIFO(): boolean;
|
package/dist/stats.js
CHANGED
|
@@ -246,3 +246,33 @@ export class BigIntStats extends StatsCommon {
|
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
BigIntStats;
|
|
249
|
+
/**
|
|
250
|
+
* @returns true if stats is a file.
|
|
251
|
+
*/
|
|
252
|
+
export function isFile(stats) {
|
|
253
|
+
return (Number(stats.mode) & S_IFMT) === S_IFREG;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* @returns True if stats is a directory.
|
|
257
|
+
*/
|
|
258
|
+
export function isDirectory(stats) {
|
|
259
|
+
return (Number(stats.mode) & S_IFMT) === S_IFDIR;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* @returns true if stats is a symbolic link
|
|
263
|
+
*/
|
|
264
|
+
export function isSymbolicLink(stats) {
|
|
265
|
+
return (Number(stats.mode) & S_IFMT) === S_IFLNK;
|
|
266
|
+
}
|
|
267
|
+
export function isSocket() {
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
export function isBlockDevice() {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
export function isCharacterDevice() {
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
export function isFIFO() {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
package/license.md
CHANGED
|
@@ -22,8 +22,8 @@ SOFTWARE.
|
|
|
22
22
|
|
|
23
23
|
This license applies to all parts of ZenFS, except for the following items:
|
|
24
24
|
|
|
25
|
-
-
|
|
26
|
-
|
|
25
|
+
- The test fixtures located in `test/fixtures/node`. Their license follows:
|
|
26
|
+
"""
|
|
27
27
|
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
|
28
28
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
29
29
|
of this software and associated documentation files (the "Software"), to
|
|
@@ -42,4 +42,4 @@ This license applies to all parts of ZenFS, except for the following items:
|
|
|
42
42
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
43
43
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
44
44
|
IN THE SOFTWARE.
|
|
45
|
-
|
|
45
|
+
"""
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenfs/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "A filesystem in your browser",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
|
-
"format": "prettier --write
|
|
45
|
-
"format:check": "prettier --check
|
|
46
|
-
"lint": "eslint src
|
|
44
|
+
"format": "prettier --write .",
|
|
45
|
+
"format:check": "prettier --check .",
|
|
46
|
+
"lint": "eslint src tests && tsc -p tsconfig.json --noEmit",
|
|
47
47
|
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules npx jest",
|
|
48
48
|
"build": "node scripts/build.js",
|
|
49
49
|
"build:docs": "typedoc --out docs --name ZenFS src/index.ts",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"esbuild": "^0.17.18",
|
|
66
66
|
"eslint": "^8.36.0",
|
|
67
67
|
"jest": "^29.5.0",
|
|
68
|
-
"prettier": "^2.
|
|
68
|
+
"prettier": "^3.2.5",
|
|
69
69
|
"ts-jest": "^29.1.0",
|
|
70
70
|
"typedoc": "^0.25.1",
|
|
71
71
|
"typescript": "^4.9.5"
|
package/readme.md
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
# ZenFS
|
|
2
2
|
|
|
3
|
-
ZenFS is a file system that emulates the [
|
|
3
|
+
ZenFS is a file system that emulates the [NodeJS filesystem API](http://nodejs.org/api/fs.html).
|
|
4
4
|
|
|
5
|
-
It works using a system of backends, which are used by ZenFS to store and retrieve data. ZenFS can also integrate
|
|
5
|
+
It works using a system of backends, which are used by ZenFS to store and retrieve data. ZenFS can also integrate with other tools.
|
|
6
6
|
|
|
7
7
|
ZenFS is a fork of [BrowserFS](https://github.com/jvilk/BrowserFS).
|
|
8
8
|
|
|
9
9
|
## Backends
|
|
10
10
|
|
|
11
|
-
ZenFS is
|
|
11
|
+
ZenFS is modular and extensible. The core includes a few built-in backends:
|
|
12
12
|
|
|
13
|
-
- `InMemory`: Stores files in-memory.
|
|
14
|
-
- `Overlay`:
|
|
15
|
-
- `AsyncMirror`: Use an asynchronous backend synchronously.
|
|
13
|
+
- `InMemory`: Stores files in-memory. This is cleared when the runtime ends (e.g. a user navigating away from a web page or a Node process exiting)
|
|
14
|
+
- `Overlay`: Use read-only file system as read-write by overlaying a writable file system on top of it.
|
|
15
|
+
- `AsyncMirror`: Use an asynchronous backend synchronously. This is very helpful for asynchronous backends
|
|
16
16
|
|
|
17
17
|
> [!NOTE]
|
|
18
18
|
> When constructed, `AsyncMirror` loads the entire contents of the async file system into a synchronous backend. It performs operations on the synchronous file system and then queues them to be mirrored onto the asynchronous backend.
|
|
19
19
|
|
|
20
|
-
More backends can be defined by separate libraries
|
|
20
|
+
ZenFS supports a number of other backends. Many are provided as seperate packages under `@zenfs`. More backends can be defined by separate libraries by extending the `FileSystem` class and/or providing a `Backend` object.
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
For more information, see the [API documentation for ZenFS](https://zen-fs.github.io/core).
|
|
22
|
+
For more information, see the [docs](https://zen-fs.github.io/core).
|
|
25
23
|
|
|
26
24
|
## Installing
|
|
27
25
|
|
|
@@ -32,10 +30,12 @@ npm install @zenfs/core
|
|
|
32
30
|
## Usage
|
|
33
31
|
|
|
34
32
|
> [!NOTE]
|
|
35
|
-
> The examples are written in ESM.
|
|
33
|
+
> The examples are written in ESM.
|
|
34
|
+
> If you are using CJS, you can `require` the package.
|
|
35
|
+
> If using a browser environment without support for `type=module` in `script` tags, you can add a `script` tag to your HTML pointing to the `browser.min.js` and use ZenFS with the global `ZenFS` object.
|
|
36
36
|
|
|
37
37
|
```js
|
|
38
|
-
import fs from '@zenfs/core';
|
|
38
|
+
import fs from '@zenfs/core'; // You can also use the named export, `fs`
|
|
39
39
|
|
|
40
40
|
fs.writeFileSync('/test.txt', 'Cool, I can do this in any JS environment (including browsers)!');
|
|
41
41
|
|