npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fatfs-wasm

v1.0.0

Published

WASM port of FatFs, the Generic FAT Filesystem Module by ChaN

Downloads

83

Readme

FatFs-Wasm

FatFs is a generic FAT/exFAT filesystem module for small embedded systems, authored by CHaN. FatFs-Wasm is a library which uses a WebAssembly build of FatFs to manipulate FAT image files from node or the browser.

Features:

  • Read, write, rename, stat, chmod, and delete files
  • Create, iterate, rename, and delete directories
  • Supports FAT12, FAT16, and FAT32

Limitations:

  • ExFat is not enabled in this build
  • LFN is not enabled in this build
  • Async drivers not supported

Getting Started

FatFs-Wasm can be used from Node.js or the browser , In the browser, include fatfs-wasm.js, which makes fatfs-wasm available in the window namespace:

<script src="fatfs-wasm.js"></script>
<script>
    const { FatFsDisk } = window['fatfs-wasm']
    // ...
</script>

Using npm

npm install --save fatfs-wasm

Then in Javascript

const { FatFsDisk } = require('fatfs-wasm')

Using

FatFs can be used with typed arrays to partition and format disk images:

const data = new Uint8Array(1 << 23);
const disk = FatFsDisk.create(data);
disk.fdisk(0, [100]); // Partition 100% to volume 0
disk.mkfs('', 0);     // Format default drive
disk.mount('');       // Mount workspace

Or open existing ones:

const response = await fetch('disk.img');
const data = new Uint8Array(response.arrayBuffer());
const disk = FatFsDisk.create(data);
disk.mount('');       // Mount workspace

Once a workspace is mounted, the library provides APIs for manipulating files:

const file = disk.open('file.txt', FatFsMode.READ);
const buffer = new Uint8Array(1024);
file.read(buffer);
file.close();

As well as iterating directories

const dir = disk.open('folder');
for (const file of dir) {
    // ...
}
dir.close();

See the API documentation for details

API Documentation

API Documentation

Modifying FatFs C Code

FatFs has many feature gates defined using the preprocessor. See native/ff15/source/ffconf.h to make adjustments. Please note that any changes to the C code must be reflected in the `src/fatfs.ts`` wrapper, which is not automatically generated. Make changes at your own risk!

To build, open a terminal in MacOS, Linux, or WSL with clang installed and run the build script:

cd native
./build.sh

This will build ff.wasm and copy it to the src directory.

Running Tests

npx jest