Coder Social home page Coder Social logo

littlefs-js's Introduction

A javascript wrapper for the little filesystem

This project puts together two things that should probably never go together:
embedded system filesystems, and web-side javascript.

The result is a fully functional javascript API for littlefs, complete with simulated block devices. This was all built using emscripten, a backend for the LLVM that can compile C to javascript. There's no smoke and mirrors here, this is actually running littlefs in your browser.

Difference from the original littlefs-js

  • link to the littlefs library via git submodule.
  • upgrade littlefs to v2.5.1
  • comfigured to only generate .js file, this will allow easier integrations (but worse performance).
  • suppout asynchronous block device's api, which make it possible to directly access real devices via Web Bluetooth, Web USB, Web Serial and so on.
  • all filesystem's operations are asynchronous, include tell and seek, don't forget to await.

Try the demo

You need compile the project before run the demo. This will generate the lfs.js.

# install emcc (emscripten) 3.1.31 first.
make

You can try it with node demo.js or deno run demo.js.

Useage

lfs.js and lfs_js.js are required. and only es module are supported.

You can implement your own block device by extend BlockDevice class. Refer to MemoryBlockDevice class for example.

  • read and prog functions are required. erase and sync are optional.
  • read, prog, erase, sync functions can be asynchronous, and return a number. 0 means success, < 0 means failed, and the error code return to the io-operation-caller.
  • outside lfs_js.js, use LFSModule.HEAPU8 to access raw memory.
  • this.block_size and this.block_count are required.
  • write_size, read_size, cache_size don't affect the data on the filesystem. so they are all set to this.block_size.

littlefs-js's People

Contributors

dreagonmon avatar geky avatar

Stargazers

 avatar  avatar

Forkers

hurzhurz

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.