summaryrefslogtreecommitdiff
path: root/js/write_file.ts
diff options
context:
space:
mode:
authorKevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com>2019-07-23 08:16:39 -0700
committerRyan Dahl <ry@tinyclouds.org>2019-07-23 11:16:39 -0400
commite49d1e16ca2fca45e959c1add9b5a1d6866dbb90 (patch)
tree1415190fcd43e18e0994eba5f13b9babf2b474db /js/write_file.ts
parent70de8dd51d465ea2016d6bb7c0728111f4493668 (diff)
feat: expose writeAll() and writeAllSync() (#2298)
Symmetric with `readAll()` and `readAllSync()`. Also used in `xeval`. Also correct usage in `writeFile()`/`writeFileSync()`.
Diffstat (limited to 'js/write_file.ts')
-rw-r--r--js/write_file.ts5
1 files changed, 3 insertions, 2 deletions
diff --git a/js/write_file.ts b/js/write_file.ts
index 39372a27e..c7b71725c 100644
--- a/js/write_file.ts
+++ b/js/write_file.ts
@@ -2,6 +2,7 @@
import { stat, statSync } from "./stat";
import { open, openSync } from "./files";
import { chmod, chmodSync } from "./chmod";
+import { writeAll, writeAllSync } from "./buffer";
/** Options for writing to a file.
* `perm` would change the file's permission if set.
@@ -40,7 +41,7 @@ export function writeFileSync(
chmodSync(filename, options.perm);
}
- file.writeSync(data);
+ writeAllSync(file, data);
file.close();
}
@@ -70,6 +71,6 @@ export async function writeFile(
await chmod(filename, options.perm);
}
- await file.write(data);
+ await writeAll(file, data);
file.close();
}