@poe-platform/safe-fs 0.1.535 → 0.1.536
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -203,7 +203,7 @@ export class DeviceFileSystem {
|
|
|
203
203
|
if (!this.#filesystem.readStream)
|
|
204
204
|
throw new FsError("ENOTSUP", { path });
|
|
205
205
|
return this.#filesystem.readStream(path, options);
|
|
206
|
-
});
|
|
206
|
+
}, options.signal);
|
|
207
207
|
}
|
|
208
208
|
async openReadFile(path, options = {}) {
|
|
209
209
|
const resolved = await this.#resolve(path, options);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ByteSource } from "../../contracts/io.js";
|
|
2
2
|
import type { FileReadHandle } from "../../contracts/filesystem.js";
|
|
3
|
-
export declare function deviceReadStream(open: () => Promise<ByteSource
|
|
3
|
+
export declare function deviceReadStream(open: () => Promise<ByteSource>, signal?: AbortSignal): ByteSource;
|
|
4
4
|
export declare function drainDeviceFile(handle: FileReadHandle, signal?: AbortSignal): Promise<void>;
|
|
5
5
|
export declare function drainDeviceInput(source: ByteSource, signal?: AbortSignal): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { finishCleanup } from "../../contracts/cleanup.js";
|
|
2
|
-
export function deviceReadStream(open) {
|
|
2
|
+
export function deviceReadStream(open, signal) {
|
|
3
3
|
return { [Symbol.asyncIterator]() {
|
|
4
4
|
let opened;
|
|
5
5
|
let closing;
|
|
@@ -12,7 +12,19 @@ export function deviceReadStream(open) {
|
|
|
12
12
|
return { done: true, value: undefined };
|
|
13
13
|
}
|
|
14
14
|
try {
|
|
15
|
-
|
|
15
|
+
const source = await iterator();
|
|
16
|
+
signal?.throwIfAborted();
|
|
17
|
+
if (closing) {
|
|
18
|
+
await closing;
|
|
19
|
+
return { done: true, value: undefined };
|
|
20
|
+
}
|
|
21
|
+
const next = source.next;
|
|
22
|
+
signal?.throwIfAborted();
|
|
23
|
+
if (closing) {
|
|
24
|
+
await closing;
|
|
25
|
+
return { done: true, value: undefined };
|
|
26
|
+
}
|
|
27
|
+
return await Reflect.apply(next, source, []);
|
|
16
28
|
}
|
|
17
29
|
catch (error) {
|
|
18
30
|
await finishCleanup(close, true);
|