Git Product home page Git Product logo

fslib's Introduction

libfs

fs.js module written in pure JavaScript. Has no native dependencies other than syscall function from libsys.

When you require libjs for the first time it has only synchronous methods:

var libfs = require('libfs');
libfs.openSync('file.txt'); // OK
libfs.open('file.txt'); // Error

libfs implements asynchronous methods in a few different ways, so you have to choose which implementation you want to use. After you have chosen once, the asynchronous functions will stay attached with the libfs object forever, so you have to do this only once.

useFake() will create fake async wrappers around the blocking fs functions. This is useful when you don't want to introduce new dependencies, but just want a quick way to conform with fs.js API, usage:

libfs.useFake(libfs);

useTagg() will use thread-a-go-go to execute async calls in a thread pool, similar to what libuv does. NOT IMPLEMENTED YET.

useLibaio will use Linux's async io_submit system calls. NOT IMPLEMENTED YET.

Incompatibilities with Node.js

libfs implements fs.js API as in the docs, with few minor differences, here are the known ones:

  1. Some error messages may be different.
  2. utimes() sets file time in seconds, instead of milliseconds.
  3. futimes() is not implemented.
  4. persistent option in watchFile() and watch() methods is always true, even if you set it to false, as I don't know how to detect if there are no more events in node's event loop, maybe somebody does know?
  5. watch() function is implemented using the same inotify(7) system calls that Node.js is using, however, I don't know why Node.js emits only change and rename events, when inotify(7) provides a much more diverse event set, so the mapping to change and rename might be a bit off. It internally uses Inotify class from libaio package, for more control and better performance use the libaio.Inotify class instead.
  6. readdir() results may differ as libfs implements it itself instead of using libc's C implementation.
  7. realpath() results may differ as libfs implements it itself instead of using libc's C implementation.
  8. fs.ReadStream and fs.WriteStream are not implemented yet.

fslib's People

Stargazers

 avatar  avatar

Watchers

 avatar  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.