import '@muze-nl/jsfs'
const client = jsfs.fs(
new jsfs.adapters.https('https://example.org/')
)JSFS is a light-weight filesystem abstraction for javascript, inspired by PHP's Flysystem. Unlike other solutions, like ZenFS, it has a minimal API. Just these functions:
cdreadwritedeleteexistslist
There is no support for streaming reads or writes yet.
npm install @muze-nl/jsfsIn the browser, using a cdn:
<script src="https://cdn.jsdelivr.net/npm/@muze-nl/jsfs/dist/browser.js"></script>Using ES6 modules, in the browser or Node (or Deno, or...):
import '@muze-nl/jsfs'
const client = jsfs.fs(new jsfs.adapters.https('https://example.org/'))Using Adapters, you can connect any filesystem-like API. By default JSFS comes with an HttpAdapter, that fetches HTML pages and parses them to extract filesystem data. Any site that is compatible with Apaches default directory listing will work. Calling write() results in a PUT request to the given path. Similarly delete() will send a DELETE request. exists() will send a HEAD request.
In a separate package, you can get an Adapter written for Solid PODs (see https://solidproject.org/). Check out @muze-nl/jsfs-solid for more information.
To write a new Adapter, you must implement this interface:
{
get name()
get path()
supportsWrite()
cd(path)
async write(path, contents, metadata=null)
async read(path)
async exists(path)
async delete(path)
async list(path)
}The list method must return an array of objects with at least these properties:
{
filename,
path,
name
}The read method must return an object with at least these properties:
{
type,
name,
contents,
}This software is licensed under MIT open source license. See the License file.