@loom-io/in-memory-adapter
Version:
A file system wrapper for Node.js and Bun
26 lines (25 loc) • 689 B
JavaScript
import { MEMORY_TYPE } from '../definitions.js';
import { addPrecedingAndTailingSlash } from '@loom-io/common';
export class ObjectDirent {
_object;
_basePath;
constructor(_object, _basePath) {
this._object = _object;
this._basePath = _basePath;
}
isDirectory() {
return this._object.$type === MEMORY_TYPE.DIRECTORY;
}
isFile() {
return this._object.$type === MEMORY_TYPE.FILE;
}
get name() {
if (this._object.$type === MEMORY_TYPE.FILE) {
return this._object.name;
}
return this._object.name;
}
get path() {
return addPrecedingAndTailingSlash(this._basePath);
}
}