@cypsela/browser-source
Version:
W3C's FileSystemEntry and FileSystemHandle as a sources for @helia/unixfs
16 lines (15 loc) • 505 B
JavaScript
import { browserFsItemSource } from "./util.js";
export async function* getDirHandleEntries(dirHandle) {
for await (const [_, handle] of dirHandle.entries()) {
yield handle;
}
}
export async function getFileHandleFile(fileHandle) {
return fileHandle.getFile();
}
export function getHandleKind(handle) {
return handle.kind;
}
export function fsHandleSource(handle, options) {
return browserFsItemSource(handle, getDirHandleEntries, getFileHandleFile, getHandleKind, options);
}