2020-05-04 18:59:37 -04:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2020-11-26 07:50:08 -05:00
|
|
|
import type { WriteFileOptions } from "../_fs_common.ts";
|
|
|
|
import type { Encodings } from "../../_utils.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-07-14 15:24:17 -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();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|