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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@b9g/filesystem

v0.2.0

Published

Universal File System Access API implementations for all platforms

Downloads

434

Readme

@b9g/filesystem

File System Access API implementations for server-side runtimes. Provides FileSystemDirectoryHandle and FileSystemFileHandle backed by local disk, memory, or S3-compatible storage.

Installation

npm install @b9g/filesystem

Backends

Each backend is a separate entry point:

Node.js / Bun local filesystem

import {NodeFSDirectory} from "@b9g/filesystem/node-fs";

const dir = new NodeFSDirectory("data", {path: "./data"});

In-memory

import {MemoryDirectory} from "@b9g/filesystem/memory";

const dir = new MemoryDirectory();

Bun S3

import {S3Directory} from "@b9g/filesystem/bun-s3";

const dir = new S3Directory("uploads", {
  bucket: "my-bucket",
  accessKeyId: process.env.AWS_ACCESS_KEY_ID,
  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
});

Usage

All backends implement the standard FileSystemDirectoryHandle interface:

// Create a directory
const subdir = await dir.getDirectoryHandle("uploads", {create: true});

// Create and write a file
const file = await subdir.getFileHandle("readme.txt", {create: true});
const writable = await file.createWritable();
await writable.write("Hello World!");
await writable.close();

// Read a file
const fileData = await file.getFile();
const text = await fileData.text();

// List entries
for await (const [name, handle] of dir.entries()) {
  console.log(name, handle.kind); // "file" or "directory"
}

// Remove entries
await dir.removeEntry("old-file.txt");
await dir.removeEntry("old-dir", {recursive: true});

Shovel Configuration

When used with Shovel, directories are configured in shovel.json:

{
  "directories": {
    "uploads": {
      "module": "@b9g/filesystem/node-fs",
      "export": "NodeFSDirectory",
      "path": "./uploads"
    }
  }
}

The path field is resolved relative to the project root. Access configured directories via self.directories:

const uploads = await self.directories.open("uploads");

CustomDirectoryStorage

The main entry point exports CustomDirectoryStorage, a registry for named directories with lazy instantiation:

import {CustomDirectoryStorage} from "@b9g/filesystem";
import {NodeFSDirectory} from "@b9g/filesystem/node-fs";

const directories = new CustomDirectoryStorage((name) => {
  return new NodeFSDirectory(name, {path: `./data/${name}`});
});

const uploads = await directories.open("uploads");
const tmp = await directories.open("tmp");

Custom Backends

Implement the FileSystemBackend interface to create custom storage backends:

import {type FileSystemBackend, ShovelDirectoryHandle} from "@b9g/filesystem";

class MyBackend implements FileSystemBackend {
  async stat(path: string) { /* ... */ }
  async readFile(path: string) { /* ... */ }
  async writeFile(path: string, data: Uint8Array) { /* ... */ }
  async listDir(path: string) { /* ... */ }
  async createDir?(path: string) { /* ... */ }
  async remove?(path: string, recursive?: boolean) { /* ... */ }
}

const dir = new ShovelDirectoryHandle(new MyBackend(), "/");

Exports

Main (@b9g/filesystem)

  • ShovelHandle - Abstract base handle class
  • ShovelFileHandle - FileSystemFileHandle implementation
  • ShovelDirectoryHandle - FileSystemDirectoryHandle implementation
  • CustomDirectoryStorage - Named directory registry

Types

  • FileSystemBackend - Backend interface for custom implementations
  • FileSystemConfig - Configuration interface
  • FileSystemPermissionDescriptor - Permission descriptor
  • DirectoryStorage - Directory storage interface (open, has, delete, keys)
  • DirectoryFactory - Factory function type (name: string) => FileSystemDirectoryHandle

@b9g/filesystem/node-fs

  • NodeFSDirectory - Local filesystem directory (Node.js/Bun)
  • NodeFSBackend - Local filesystem backend

@b9g/filesystem/memory

  • MemoryDirectory - In-memory directory
  • MemoryFileSystemBackend - In-memory backend

@b9g/filesystem/bun-s3

  • S3Directory - S3-compatible storage directory
  • S3FileSystemBackend - S3 storage backend

License

MIT