@synet/fs
Version:
Robust, battle-tested filesystem abstraction for Node.js
48 lines (47 loc) • 1.49 kB
JavaScript
;
/**
* FS - Clean Factory for Filesystem Units
*
* Provides a clean, organized way to create filesystem units with
* clear separation between sync and async operations.
*
* Usage:
* ```typescript
* // Sync filesystems (local only)
* const syncFs = FS.sync.memory();
* const content = syncFs.readFile('./file.txt'); // Returns string
*
* // Async filesystems (including cloud)
* const asyncFs = FS.async.s3(s3Options);
* const content = await asyncFs.readFile('./file.txt'); // Returns Promise<string>
* ```
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.FS = void 0;
const filesystem_unit_1 = require("./filesystem.unit");
const async_filesystem_unit_1 = require("./promises/async-filesystem.unit");
const node_1 = require("./node");
const node_2 = require("./promises/node");
/**
* Clean filesystem factory with sync/async separation
*/
exports.FS = {
/**
* Synchronous filesystem operations (local only)
*/
sync: {
/**
* Node.js filesystem (sync) - Local file operations
*/
node: () => filesystem_unit_1.FileSystem.create({ adapter: new node_1.NodeFileSystem() }),
},
/**
* Asynchronous filesystem operations (including cloud)
*/
async: {
/**
* Node.js filesystem (async) - Non-blocking local file operations
*/
node: () => async_filesystem_unit_1.AsyncFileSystem.create({ adapter: new node_2.NodeFileSystem() }),
},
};