|
|
|
|
|
by lostcolony
1963 days ago
|
|
You've never worked with a generator before? That's a stateful function. For throwing after a file handle is closed, something like - const read = (fileHandle) => {
return () => {
if io:isOpen(fileHandle) && io:hasNext(fileHandle) => {
return io:readNext(fileHandle)
} else if io:isOpen(fileHandle) {return undefined
} else {throw "File is closed"}
}
}(myFile)
read()
read()
io:close(myFile)
read() //throws
|
|