0.1.8 • Published 2 months ago

breadfs v0.1.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

BreadFS

version CI

Unified File System Abstraction.

import { fs as nfs } from 'breadfs/node'
import { WebDAVFS } from 'breadfs/webdav'

// Write something to hello.txt
const local = nfs.path('hello.txt')
await local.writeText('This is used for testing')

// Create WebDAV file system
const wfs = WebDAVFS.make("https://some-server.org", {
  username: "user",
  password: "pass"
})

// Copy the local hello.txt to the remote WebDAV server
const remote = wfs.path('/hello.txt')
await local.copyTo(remote)
await remote.readText()
// Return 'This is used for testing'

Installation

npm i breadfs

Notice

This package is built on the web native Streams API. You should add "lib": ["ES2018", "DOM"] to your tsconfig.json.

Usage

Node

import { fs as nfs } from 'breadfs/node'

const bin = nfs.path('/bin')

await bin.list()
await bin.join('node').stat()
await nfs.path('/home/.bashrc').readFile()
await nfs.path('/home/.bashrc').readText()
await nfs.path('/home/test.txt').writeText('This is used for testing')

WebDAV

npm i breadfs @breadfs/webdav
import { WebDAVFS } from 'breadfs/webdav'

const wfs = WebDAVFS.make("https://some-server.org", {
  username: "user",
  password: "pass"
})

await wfs.path('/test.txt').readText()

Across different file systems

import { fs as nfs } from 'breadfs/node'
import { WebDAVFS } from 'breadfs/webdav'

const wfs = WebDAVFS.make("https://some-server.org", {
  username: "user",
  password: "pass"
})

const local = nfs.path('hello.txt')
const remote = wfs.path('/hello.txt')
await local.writeText('This is used for testing')
await local.copyTo(remote)
await remote.readText()  // 'This is used for testing'

Operating files across various different file systems can be quite challenging, which means our implementation may not function perfectly in all scenarios. Even file system in your local machine may encounter some bugs.

So that the goal of this package is to provide a straightforward abstraction and utility for use in less complex or basic situations.

Related

This package is used to power AnimeSpace, offering a comprehensive solution for automatically following bangumis. It can fetch anime resources, download desired video content, and upload them to the local file system or remote WebDAV server. The upload process is facilitated by this package.

License

MIT License © 2023 XLor

0.1.8

2 months ago

0.1.2

4 months ago

0.1.7

4 months ago

0.1.4

4 months ago

0.1.3

4 months ago

0.1.6

4 months ago

0.1.5

4 months ago

0.1.0

4 months ago

0.1.1

4 months ago

0.0.7

8 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.2-beta.1

8 months ago

0.0.2-beta.0

8 months ago