Git Product home page Git Product logo

fuse-fs's Introduction

fuse-fs

A tweakable fs-like that can be mounted via FUSE

Background

Uses fuse-bindings to mount an fs-like object via FUSE.

Differs from fs-fuse in that:

  • calls can be intercepted and tweaked to adjust behaviour
  • does not try to provide full support
  • uses Promise, async

Written for my own use.

API

FuseFS

const fuseFs = new FuseFS(fsLike[, options])

creates a FuseFS object from the fs-like object. Options are passed to fuse-bindings

.mount

await fuseFS.mount(mountPoint)

mounts the FuseFS object at the mount point. Returns a promise of the fact that it mounted

.unmount

await fuseFS,unmount

unmounts the FuseFS object, returning a promise of the fact.

.before

fuseFS.before(method[, method...], function[, function...])

adds before intercepts for the specified methods. Returns a function to remove them.

.after

fuseFS.after(method[, method...], function[, function...])

adds after intercepts for the specified methods. Returns a function to remove them.

Intercepts

Intercept functions are called in the order they are specified. The before ones are called before the call (duh!), and the after ones after the call.

They all take one parameter, and are awaited, so can be async. The parameter is a context object with the following:

  • name - the FUSE name of the method being called
  • origArgs[] - the original args called (before any intercepts)
  • args[] - the args that will be used to make the call. Can be modified by before intercepts.
  • origResults[] - the original results from the call (before any after intercepts)
  • results[] - the results of the call to be sent back to the called. Can be modified by after intercepts

results and origResults will be undefined for any before intercepts. If however, an intercept sets results then no call will be made to the fs-like, and instead it will be passed on to the chain of after intercepts.

Return values of intercept functions are ignored. Any changes must be made to the context object.

.invoke

const [err, results] = await fuseFS.invoke(method, ...args)

Invokes a FUSE callback - with the chains of intercepts - and resolves to the array of values that would be sent back to FUSE

fuse-fs's People

Contributors

ludlovian avatar

Stargazers

Stephen Corya avatar

Watchers

James Cloos avatar

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.