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 🙏

© 2025 – Pkg Stats / Ryan Hefner

drive-fsa

v1.0.8

Published

Wrapper for the File System Access API

Downloads

304

Readme

Drive FSA

A simple wrapper to use browser File System Access API in a more convenient way.

Installation

npm install drive-fsa

createDrive

Helper function to create a drive object from a directory handle

import { createDrive } from 'drive-fsa';

const handle = await window.showDirectoryPicker();

const drive = createDrive(handle);

// list all files in the root directory
const entries = await drive.list('/');

// list all files in a subdirectory
const entries = await drive.list('/subdir1/subdir2');

// get individual file
const entry = await drive.get('/file.txt');

// read file, returns a Uint8Array
const uint8 = await drive.read('/file.txt');

// read file as text
const text = await drive.read('/file.txt', { contentType: 'text' });

// read file as json 
const json = await drive.read('/file.txt', { contentType: 'json' });

// write to file Uint8Array
await drive.write('/file.txt', new TextEncoder().encode('Hello, World!'));

// write to file text 
await drive.write('/file.txt', 'Hello, World!', { contentType: 'text' });

// write to file json 
await drive.write('/file.txt', { hello: 'world' }, { contentType: 'json' });

// delete file 
await drive.destroy('/file.txt');

findEntry

Get an entry by path

import { findEntry } from 'drive-fsa';

const handle = await window.showDirectoryPicker();

const entry = await findEntry(handle, '/file.txt');

listEntries

List all entries in a directory

import { listEntries } from 'drive-fsa';

const handle = await window.showDirectoryPicker();

const entries = await listEntries(handle, '/');

readEntry

Read the content of a file

import { readEntry } from 'drive-fsa';

const handle = await window.showDirectoryPicker();

const data = await readEntry(handle, '/file.txt'); // Promise<Uint8Array>

Use options to specify the content type

readEntry(handle, '/file.txt', { contentType: 'text' }); // Promise<string>
readEntry(handle, '/file.txt', { contentType: 'json' }); // Promise<Record<string, any>>
readEntry(handle, '/file.txt', { contentType: 'uint8array' }); // Promise<Uint8Array>

makeDirectoryEntry

Create a directory

import { makeDirectoryEntry } from 'drive-fsa'; 

const handle = await window.showDirectoryPicker();

await makeDirectoryEntry(handle, '/subdir1/subdir2');

Create a directory recursively

makeDirectoryEntry(handle, '/subdir1/subdir2', { recursive: true });

writeEntry

Write to a file

import { writeEntry, encode } from 'drive-fsa';

const handle = await window.showDirectoryPicker();

await writeEntry(handle, '/file.txt', encode('Hello, World!'));

Use options to specify the content type

writeEntry(handle, '/file.txt', 'Hello, World!', { contentType: 'text' });
writeEntry(handle, '/file.txt', { hello: 'world' }, { contentType: 'json' });
writeEntry(handle, '/file.txt', new Uint8Array([1, 2, 3]), { contentType: 'uint8array' });

Recursive write

writeEntry(handle, '/subdir1/subdir2/file.txt', 'Hello, World!', { recursive: true });

destroyEntry

Delete a file or a directory

import { destroyEntry } from 'drive-fsa';

const handle = await window.showDirectoryPicker();

await destroyEntry(handle, '/file.txt');

findHandle

Get a handle by path

Can be used to get a deep handle of a file or a directory

import { findHandle } from 'drive-fsa';

const handle = await window.showDirectoryPicker();

const fileHandle = await findHandle(handle, '/file.txt');

const dirHandle = await findHandle(handle, '/subdir1/subdir2');