summaryrefslogtreecommitdiff
path: root/runtime/js
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/js')
-rw-r--r--runtime/js/40_write_file.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/runtime/js/40_write_file.js b/runtime/js/40_write_file.js
index def9f6fee..6ced4e066 100644
--- a/runtime/js/40_write_file.js
+++ b/runtime/js/40_write_file.js
@@ -13,6 +13,9 @@
data,
options = {},
) {
+ if (options?.signal?.aborted) {
+ throw new DOMException("The write operation was aborted.", "AbortError");
+ }
if (options.create !== undefined) {
const create = !!options.create;
if (!create) {
@@ -68,12 +71,17 @@
await chmod(path, options.mode);
}
+ const signal = options?.signal ?? null;
let nwritten = 0;
- while (nwritten < data.length) {
+ while (!signal?.aborted && nwritten < data.length) {
nwritten += await file.write(TypedArrayPrototypeSubarray(data, nwritten));
}
file.close();
+
+ if (signal?.aborted) {
+ throw new DOMException("The write operation was aborted.", "AbortError");
+ }
}
function writeTextFileSync(