|
|
19 시간 전 | |
|---|---|---|
| .. | ||
| lib | 19 시간 전 | |
| LICENSE | 19 시간 전 | |
| README.md | 19 시간 전 | |
| package.json | 19 시간 전 | |
Adapter to convert Node.js fs API to File System Access API (FSA).
npm install @jsonjoy.com/fs-node-to-fsa
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);
}
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 });
nodeToFsa(fs, path, ctx) - Converts a Node.js fs module to a FileSystemDirectoryHandle.NodeFileSystemObserver - A FileSystemObserver implementation backed by fs.watch.