feat: Add getChildren function to DataAccessor interface

DataAccessors are now no longer responsible for generating ldp:contains triples.
This commit is contained in:
Joachim Van Herwegen
2021-05-11 14:40:42 +02:00
parent 52a3b84ee0
commit cae9d54fac
12 changed files with 187 additions and 137 deletions

View File

@@ -1,4 +1,5 @@
import type { Stats } from 'fs';
import type { Dirent, Stats } from 'fs';
import { PassThrough } from 'stream';
import streamifyArray from 'streamify-array';
import type { SystemError } from '../../src/util/errors/SystemError';
@@ -149,6 +150,19 @@ export function mockFs(rootFilepath?: string, time?: Date): { data: any } {
}
return Object.keys(folder[name]);
},
async* opendir(path: string): AsyncIterableIterator<Dirent> {
const { folder, name } = getFolder(path);
if (!folder[name]) {
throwSystemError('ENOENT');
}
for (const child of Object.keys(folder[name])) {
yield {
name: child,
isFile: (): boolean => typeof folder[name][child] === 'string',
isDirectory: (): boolean => typeof folder[name][child] === 'object',
} as Dirent;
}
},
mkdir(path: string): void {
const { folder, name } = getFolder(path);
if (folder[name]) {