summaryrefslogtreecommitdiff
path: root/runtime/js/40_write_file.js
diff options
context:
space:
mode:
authorLuca Casonato <lucacasonato@yahoo.com>2021-04-06 00:05:36 +0200
committerGitHub <noreply@github.com>2021-04-06 00:05:36 +0200
commitda60e2afcbd4b28e3b8ba69b5e38d4ff173ddbe1 (patch)
tree616031ffcb358a1ff3168a96bc95512f3648ff9f /runtime/js/40_write_file.js
parent2aed322dd507a8568b6ee6f4897e9a8e3220f763 (diff)
chore: deprecate Deno.Buffer and read/write utils (#9793)
This commit marks the `Deno.Buffer` / `Deno.readAll` / `Deno.readAllSync` / `Deno.writeAll` / `Deno.writeAllSync` utils as deprecated, and schedules them for removal in Deno 2.0. These utilities are implemented in pure JS, so should not be part of the Deno namespace. These utilities are now available in std/io/buffer and std/io/util: https://github.com/denoland/deno_std/pull/808. This additionallty removes all internal dependance on Deno.Buffer.
Diffstat (limited to 'runtime/js/40_write_file.js')
-rw-r--r--runtime/js/40_write_file.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/runtime/js/40_write_file.js b/runtime/js/40_write_file.js
index 5964dec5f..4662849a5 100644
--- a/runtime/js/40_write_file.js
+++ b/runtime/js/40_write_file.js
@@ -3,7 +3,6 @@
((window) => {
const { stat, statSync, chmod, chmodSync } = window.__bootstrap.fs;
const { open, openSync } = window.__bootstrap.files;
- const { writeAll, writeAllSync } = window.__bootstrap.buffer;
const { build } = window.__bootstrap.build;
function writeFileSync(
@@ -32,7 +31,11 @@
chmodSync(path, options.mode);
}
- writeAllSync(file, data);
+ let nwritten = 0;
+ while (nwritten < data.length) {
+ nwritten += file.writeSync(data.subarray(nwritten));
+ }
+
file.close();
}
@@ -62,7 +65,11 @@
await chmod(path, options.mode);
}
- await writeAll(file, data);
+ let nwritten = 0;
+ while (nwritten < data.length) {
+ nwritten += await file.write(data.subarray(nwritten));
+ }
+
file.close();
}