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

opfs-tools

v0.7.4

Published

EN: A simple, high-performance, and comprehensive file system API running in the browser, built on [OPFS](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system).

Readme

EN: A simple, high-performance, and comprehensive file system API running in the browser, built on OPFS.

CN: 在浏览器中运行的简单、高性能、完备的文件系统 API,基于 OPFS 构建。

API Documentation | Tips

Benchmark

Usage

import { file, dir, write } from 'opfs-tools';

// --------- Create / Write ---------
await dir('/test-dir').create(); // create a directory

await write('/dir/file.txt', ''); // empty file
await write('/dir/fetch-file', (await fetch('//example.com')).body);
// inputFile from the input element picked by the user
await write('/dir/input-file', inputFile.stream());

// For incremental file writes, please refer to the API documentation.
const writer = await file('/dir/file').createWriter();

// --------- Read ---------
await file('/dir/file.txt').text();
await file('/dir/input-file').arrayBuffer();
await file('/dir/input-file').stream();

// If you want to read file fragments, please refer to the API documentation.
const reader = await file('/dir/input-file').createReader();

await dir('/test-dir').children();

// --------- Remove ---------
await dir('/test-dir').remove();

await file('/dir/file.txt').remove();

// --------- copyTo / moveTo ---------
await file('/dir/file').copyTo(file('/dir/file copy1'));
await dir('/dir').moveTo(dir('/.Trash'));

// --------- import/export file  -----------
const [impHandle] = await window.showOpenFilePicker();
write('/import-file', (await impHandle.getFile()).stream());

const expHandle = await window.showSaveFilePicker({
  suggestedName: `opfs-export-file`,
});
(await file('/export-file').stream()).pipeTo(await expHandle.createWritable());

// --------- upload -------------
const formData = new FormData();
formData.append('file', await file('/upload-file').getOriginFile());
await fetch('/upload', {
  method: 'post',
  headers: { 'Content-Type': 'multipart/form-data' },
  body: formData,
});

作者的 OPFS 相关文章

DEMOS

  • opfs-finder
    使用 AI + OPFS 在浏览器中实现 MacOS Finder。Implement MacOS Finder in the browser using AI + OPFS.

  • opfs-tools-explorer
    Manage OPFS assets in your web site, supporting file creation, copying, and moving features, providing a user-friendly interactive experience.
    image

Features

  • Basic operations
    • [x] file
      • [x] remove
      • [x] exists
    • [x] dir
      • [x] create
      • [x] remove
      • [x] exists
      • [x] children
  • [x] Reading files
    • [x] getSize
    • [x] text
    • [x] stream
    • [x] arrayBuffer
  • [x] Random reading
    • [x] reader = file.createReader
    • [x] reader.read(bufLen, { at }
    • [x] reader.close
  • Writing files
    • [x] write(dest: string, input: string)
    • [x] write(dest: string, input: ArrayBuffer | ArrayBufferView)
    • [x] write(dest: string, input: ReadableStream)
  • Random writing
    • [x] writer = file.createWriter
    • [x] writer.write
    • [x] writer.flush
    • [x] writer.truncate
    • [x] writer.close