UNPKG

@loom-io/in-memory-adapter

Version:

A file system wrapper for Node.js and Bun

17 lines (16 loc) 498 B
import { Directory, LoomFile } from '@loom-io/core/internal'; import { Adapter } from '../core/adapter.js'; import { dirname, basename } from 'node:path'; export class MemoryAdapter { adapter; constructor() { this.adapter = new Adapter(); } async file(path) { const dir = new Directory(this.adapter, dirname(path)); return new LoomFile(this.adapter, dir, basename(path)); } async dir(path) { return new Directory(this.adapter, path); } }