2020-05-04 18:59:37 -04:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2020-07-08 05:26:39 -04:00
|
|
|
import type { Encodings, WriteFileOptions } from "../_fs_common.ts";
|
2020-05-04 18:59:37 -04:00
|
|
|
|
|
|
|
import { writeFile as writeFileCallback } from "../_fs_writeFile.ts";
|
|
|
|
|
|
|
|
export function writeFile(
|
2020-05-22 22:11:10 -04:00
|
|
|
pathOrRid: string | number | URL,
|
2020-05-04 18:59:37 -04:00
|
|
|
data: string | Uint8Array,
|
2020-06-23 22:32:43 -04:00
|
|
|
options?: Encodings | WriteFileOptions
|
2020-05-04 18:59:37 -04:00
|
|
|
): Promise<void> {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
writeFileCallback(pathOrRid, data, options, (err?: Error | null) => {
|
|
|
|
if (err) return reject(err);
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|