zheng 3cabbb3159 webpack 19 giờ trước cách đây
..
lib 3cabbb3159 webpack 19 giờ trước cách đây
LICENSE 3cabbb3159 webpack 19 giờ trước cách đây
README.md 3cabbb3159 webpack 19 giờ trước cách đây
package.json 3cabbb3159 webpack 19 giờ trước cách đây

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