@zenfs/core
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -56,3 +56,3 @@ import { FileSystem } from '../filesystem.js'; | ||
*/ | ||
isAvailable(): boolean; | ||
isAvailable(): boolean | Promise<boolean>; | ||
} | ||
@@ -59,0 +59,0 @@ /** |
@@ -80,3 +80,3 @@ import { ApiError, ErrorCode } from '../ApiError.js'; | ||
} | ||
if (!backend.isAvailable()) { | ||
if (!(await backend.isAvailable())) { | ||
throw new ApiError(ErrorCode.EPERM, 'Backend not available: ' + backend); | ||
@@ -83,0 +83,0 @@ } |
@@ -205,1 +205,17 @@ /// <reference types="node" resolution-mode="require"/> | ||
} | ||
/** | ||
* @returns true if stats is a file. | ||
*/ | ||
export declare function isFile(stats: StatsLike): boolean; | ||
/** | ||
* @returns True if stats is a directory. | ||
*/ | ||
export declare function isDirectory(stats: StatsLike): boolean; | ||
/** | ||
* @returns true if stats is a symbolic link | ||
*/ | ||
export declare function isSymbolicLink(stats: StatsLike): boolean; | ||
export declare function isSocket(): boolean; | ||
export declare function isBlockDevice(): boolean; | ||
export declare function isCharacterDevice(): boolean; | ||
export declare function isFIFO(): boolean; |
@@ -249,1 +249,31 @@ import { Cred } from './cred.js'; | ||
BigIntStats; | ||
/** | ||
* @returns true if stats is a file. | ||
*/ | ||
export function isFile(stats) { | ||
return (Number(stats.mode) & S_IFMT) === S_IFREG; | ||
} | ||
/** | ||
* @returns True if stats is a directory. | ||
*/ | ||
export function isDirectory(stats) { | ||
return (Number(stats.mode) & S_IFMT) === S_IFDIR; | ||
} | ||
/** | ||
* @returns true if stats is a symbolic link | ||
*/ | ||
export function isSymbolicLink(stats) { | ||
return (Number(stats.mode) & S_IFMT) === S_IFLNK; | ||
} | ||
export function isSocket() { | ||
return false; | ||
} | ||
export function isBlockDevice() { | ||
return false; | ||
} | ||
export function isCharacterDevice() { | ||
return false; | ||
} | ||
export function isFIFO() { | ||
return false; | ||
} |
@@ -25,4 +25,4 @@ Copyright (c) 2023-2024 James P. and other ZenFS contributors. | ||
- The test fixtures located in `test/fixtures/node`. Their license follows: | ||
""" | ||
- The test fixtures located in `test/fixtures/node`. Their license follows: | ||
""" | ||
Copyright Joyent, Inc. and other Node contributors. All rights reserved. | ||
@@ -46,2 +46,2 @@ Permission is hereby granted, free of charge, to any person obtaining a copy | ||
IN THE SOFTWARE. | ||
""" | ||
""" |
{ | ||
"name": "@zenfs/core", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "A filesystem in your browser", | ||
@@ -44,5 +44,5 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"format": "prettier --write src test", | ||
"format:check": "prettier --check src test", | ||
"lint": "eslint src test && tsc -p tsconfig.json --noEmit", | ||
"format": "prettier --write .", | ||
"format:check": "prettier --check .", | ||
"lint": "eslint src tests && tsc -p tsconfig.json --noEmit", | ||
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules npx jest", | ||
@@ -69,3 +69,3 @@ "build": "node scripts/build.js", | ||
"jest": "^29.5.0", | ||
"prettier": "^2.8.7", | ||
"prettier": "^3.2.5", | ||
"ts-jest": "^29.1.0", | ||
@@ -72,0 +72,0 @@ "typedoc": "^0.25.1", |
# ZenFS | ||
ZenFS is a file system that emulates the [Node JS file system API](http://nodejs.org/api/fs.html). | ||
ZenFS is a file system that emulates the [NodeJS filesystem API](http://nodejs.org/api/fs.html). | ||
It works using a system of backends, which are used by ZenFS to store and retrieve data. ZenFS can also integrate nicely with other tools. | ||
It works using a system of backends, which are used by ZenFS to store and retrieve data. ZenFS can also integrate with other tools. | ||
@@ -11,7 +11,7 @@ ZenFS is a fork of [BrowserFS](https://github.com/jvilk/BrowserFS). | ||
ZenFS is highly extensible, and includes a few built-in backends: | ||
ZenFS is modular and extensible. The core includes a few built-in backends: | ||
- `InMemory`: Stores files in-memory. It is a temporary file store that clears when the user navigates away. | ||
- `Overlay`: Mount a read-only file system as read-write by overlaying a writable file system on top of it. Like Docker's overlayfs, it will only write changed files to the writable file system. | ||
- `AsyncMirror`: Use an asynchronous backend synchronously. Invaluable for Emscripten; let your Emscripten applications write to larger file stores with no additional effort! | ||
- `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) | ||
- `Overlay`: Use read-only file system as read-write by overlaying a writable file system on top of it. | ||
- `AsyncMirror`: Use an asynchronous backend synchronously. This is very helpful for asynchronous backends | ||
@@ -21,8 +21,6 @@ > [!NOTE] | ||
More backends can be defined by separate libraries, as long as they implement `FileSystem`. | ||
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. | ||
ZenFS supports a number of other backends. Many are provided as seperate packages under `@zenfs`. | ||
For more information, see the [docs](https://zen-fs.github.io/core). | ||
For more information, see the [API documentation for ZenFS](https://zen-fs.github.io/core). | ||
## Installing | ||
@@ -37,6 +35,8 @@ | ||
> [!NOTE] | ||
> The examples are written in ESM. If you are using CJS, you can `require` the package. If running in a browser you can add a script tag to your HTML pointing to the `browser.min.js` and use ZenFS via the global `ZenFS` object. | ||
> The examples are written in ESM. | ||
> If you are using CJS, you can `require` the package. | ||
> 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. | ||
```js | ||
import fs from '@zenfs/core'; | ||
import fs from '@zenfs/core'; // You can also use the named export, `fs` | ||
@@ -43,0 +43,0 @@ fs.writeFileSync('/test.txt', 'Cool, I can do this in any JS environment (including browsers)!'); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1481658
11527