fix iterators, use tsx for test
Release / release (push) Successful in 24s

This commit is contained in:
2026-05-01 10:28:22 -07:00
parent 00e027ef71
commit f361c6b931
4 changed files with 567 additions and 20 deletions
+20 -18
View File
@@ -24,30 +24,32 @@ export default class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle
else throw error
}
}
entries(): FileSystemDirectoryHandleAsyncIterator<[string, NodeFileSystemDirectoryHandle | NodeFileSystemFileHandle]> {
const entries: Array<[string, NodeFileSystemDirectoryHandle | NodeFileSystemFileHandle]> = []
fs.readdirSync(this.path).forEach(name => {
if (fs.lstatSync(name).isDirectory()) {
entries.push([name, new NodeFileSystemDirectoryHandle(Path.join(this.path, name), { origin: this.origin || this })])
async* entries(): FileSystemDirectoryHandleAsyncIterator<[string, NodeFileSystemDirectoryHandle | NodeFileSystemFileHandle]> {
for (const name of await asyncfs.readdir(this.path)) {
const entryPath = Path.join(this.path, name)
const stat = await asyncfs.lstat(entryPath)
if (stat.isDirectory()) {
yield [name, new NodeFileSystemDirectoryHandle(entryPath, { origin: this.origin || this })]
} else {
entries.push([name, new NodeFileSystemFileHandle(Path.join(this.path, name), { origin: this.origin || this })])
yield [name, new NodeFileSystemFileHandle(entryPath, { origin: this.origin || this })]
}
})
return entries[Symbol.asyncIterator]
}
}
keys(): FileSystemDirectoryHandleAsyncIterator<string> {
return fs.readdirSync(this.path)[Symbol.asyncIterator]
async* keys(): FileSystemDirectoryHandleAsyncIterator<string> {
for (const name of await asyncfs.readdir(this.path)) {
yield name
}
}
values(): FileSystemDirectoryHandleAsyncIterator<NodeFileSystemDirectoryHandle | NodeFileSystemFileHandle> {
const values: Array<NodeFileSystemDirectoryHandle | NodeFileSystemFileHandle> = [];
fs.readdirSync(this.path).forEach(name => {
if (fs.lstatSync(name).isDirectory()) {
values.push(new NodeFileSystemDirectoryHandle(Path.join(this.path, name), { origin: this.origin || this }))
async* values(): FileSystemDirectoryHandleAsyncIterator<NodeFileSystemDirectoryHandle | NodeFileSystemFileHandle> {
for (const name of await asyncfs.readdir(this.path)) {
const entryPath = Path.join(this.path, name)
const stat = await asyncfs.lstat(entryPath)
if (stat.isDirectory()) {
yield new NodeFileSystemDirectoryHandle(entryPath, { origin: this.origin || this })
} else {
values.push(new NodeFileSystemFileHandle(Path.join(this.path, name), { origin: this.origin || this }))
yield new NodeFileSystemFileHandle(entryPath, { origin: this.origin || this })
}
})
return values[Symbol.asyncIterator]
}
}
#getValidatedPath(name: string) {
name = Path.normalize(name)