zheng 3cabbb3159 webpack 20 timmar sedan
..
lib 3cabbb3159 webpack 20 timmar sedan
LICENSE 3cabbb3159 webpack 20 timmar sedan
README.md 3cabbb3159 webpack 20 timmar sedan
package.json 3cabbb3159 webpack 20 timmar sedan

README.md

@jsonjoy.com/fs-node-to-fsa

Adapter to convert Node.js fs API to File System Access API (FSA).

Installation

npm install @jsonjoy.com/fs-node-to-fsa

Usage

import { nodeToFsa } from '@jsonjoy.com/fs-node-to-fsa';
import * as fs from 'fs';

const dir = nodeToFsa(fs, '/path/to/directory', { mode: 'readwrite' });

// Now use the FSA API
for await (const [name, handle] of dir.entries()) {
  console.log(name, handle.kind);
}

FileSystemObserver

NodeFileSystemObserver implements the FileSystemObserver proposal on top of the Node.js fs.watch API. It is a best-effort implementation, per the proposal's allowance for local file systems: rename events are classified into "appeared"/"disappeared" records by stat-ing the path, and no "moved" records are ever produced.

import { nodeToFsa, NodeFileSystemObserver } from '@jsonjoy.com/fs-node-to-fsa';
import * as fs from 'fs';

const dir = nodeToFsa(fs, '/path/to/directory', { mode: 'readwrite' });
const observer = new NodeFileSystemObserver(fs, records => console.log(records));
await observer.observe(dir, { recursive: true });

Reference