Code Monkey home page Code Monkey logo

peerfs's Introduction

peer-fs

A multiwriter peer-to-peer filesystem. Supports Hyperdrive V10.

Usage

See test/index.test.js for examples.

API

var drive = KappaDrive(storage, key, opts)

Returns a KappaCore instance. Passes these options directly to that instance.

In addition, peer-fs accepts the following optional arguments:

  • resolveFork: a function taking values of known versions of that file. If there are more than one here, there is a fork. By default, this returns the first item in the list. Overwrite this to get more fancy.

drive.replicate()

Replicate between two peer-fs instances.

drive.readFile(filename, cb)

Read asyncronously.

drive.writeFile(filename, content, cb)

Write asyncronously.

drive.createWriteStream(filename, cb)

Write to a stream.

drive.createReadStream(filename, cb)

Read file from a stream.

drive.exists(filename, cb)

Check a file exists

drive.truncate(filename, cb)

Truncate a file

drive.readdir(name, cb)

List all files within a specified directory

License

MIT

Credit

Huge credit to Karissa for ideating and writing peerfs and allowing us to run with it and complete the API.

๐Ÿ–ค ๐Ÿ’œ ๐Ÿ’š

TODO

  • Move all of the functions over from hyperdrive to the top constructor instance (e.g. stat)
  • Improve performance and stability of index writes by using something other than JSON.
  • Allow resolveFork function to get access to the stat object of the file on that write so that it can make a more intelligent display or make better decisions about the fork
  • Allow forks to be unresolved cc @substack
  • When writing, in the link we should record the seq of the hyperdrive, and on whoHasFile, checkout to that seq if its not the latest

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.