Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

opfs-extra

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opfs-extra

opfs-extra brings the user-friendly API to OPFS, just like fs-extra.

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

opfs-extra

opfs-extra brings the user-friendly API to OPFS, just like fs-extra

GitHub CI NPM License NPM Downloads

Playground

Try it online: opfs-extra Playground.

Installation

npm i opfs-extra

Usage

import { OPFS } from "opfs-extra";

// Initialization
const opfs = await OPFS.open();

// Directory Creating
await opfs.mkdir("/data");

// File Writing
await opfs.writeFile("/data/hello.txt", "Hello World");
await opfs.writeJSON("/data/hello.json", { text: "Hello World" });

// File Reading
const text = await opfs.readText("/data/hello.txt"); // "Hello World"
const json = await opfs.readJSON("/data/hello.json"); // { text: "Hello World" }

// Directory Reading
const files = await opfs.readdir("/data"); // ["hello.txt", "hello.json"]

// Exists
await opfs.exists("/data/hello.json"); // true

// Remove
await opfs.remove("/data");

API Reference

Initialization

  • open - Opens access to the Origin Private File System.

Storage

  • root - Gets the handle to the root directory of the Origin Private File System.
  • estimate - Estimates storage usage and quota.

Handles

File Reading

  • readBinary - Reads a file as an ArrayBuffer.
  • readText - Reads a file as plain text.
  • readJSON - Reads a file as a JSON Object.
  • readJSONL - Reads a JSONL file as a JSON Array.

File Writing

These methods will create file and parent directories automatically if needed.

Directory

  • mkdir - Creates a directory (creates directories if needed).
  • emptyDir - Empties a directory (creates directories if needed).
  • readdir - Reads the directory contents as names.
  • readdirHandles - Reads the directory contents as handles.

Path

  • exists - Tests whether a file or directory exists.
  • remove - Removes a file or directory recursively.

Keywords

opfs

FAQs

Package last updated on 09 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts