@zenfs/core
Advanced tools
Comparing version 1.8.5 to 1.8.6
@@ -7,2 +7,3 @@ import { pick } from 'utilium'; | ||
import { Stats } from '../../stats.js'; | ||
import { decodeUTF8 } from '../../utils.js'; | ||
import { InMemory } from '../memory.js'; | ||
@@ -9,0 +10,0 @@ import * as RPC from './rpc.js'; |
@@ -59,3 +59,3 @@ import type { TransferListItem } from 'node:worker_threads'; | ||
} | ||
export { FileData as File }; | ||
export type { FileData as File }; | ||
export declare function isMessage(arg: unknown): arg is Message; | ||
@@ -62,0 +62,0 @@ type _Executor = Parameters<ConstructorParameters<typeof Promise<any>>[0]>; |
@@ -26,4 +26,6 @@ import type { InodeLike } from './inode.js'; | ||
toString(): string; | ||
directoryEntries(path: string): Record<string, number>; | ||
/** | ||
* Gets a list of entries for each directory in the index. Memoized. | ||
* Gets a list of entries for each directory in the index. | ||
* Use | ||
*/ | ||
@@ -30,0 +32,0 @@ directories(): Map<string, Record<string, number>>; |
@@ -28,8 +28,21 @@ /* Note: this file is named file_index.ts because Typescript has special behavior regarding index.ts which can't be disabled. */ | ||
} | ||
directoryEntries(path) { | ||
const node = this.get(path); | ||
if (!node) | ||
throw ErrnoError.With('ENOENT', path); | ||
if ((node.mode & S_IFMT) != S_IFDIR) | ||
throw ErrnoError.With('ENOTDIR', path); | ||
const entries = {}; | ||
for (const entry of this.keys()) { | ||
if (dirname(entry) == path && entry != path) { | ||
entries[basename(entry)] = this.get(entry).ino; | ||
} | ||
} | ||
return entries; | ||
} | ||
/** | ||
* Gets a list of entries for each directory in the index. Memoized. | ||
* Gets a list of entries for each directory in the index. | ||
* Use | ||
*/ | ||
directories() { | ||
if (this._directories) | ||
return this._directories; | ||
const dirs = new Map(); | ||
@@ -46,3 +59,2 @@ for (const [path, node] of this) { | ||
} | ||
this._directories = dirs; | ||
return dirs; | ||
@@ -49,0 +61,0 @@ } |
{ | ||
"name": "@zenfs/core", | ||
"version": "1.8.5", | ||
"version": "1.8.6", | ||
"description": "A filesystem, anywhere", | ||
@@ -5,0 +5,0 @@ "funding": { |
655626
16477