summaryrefslogtreecommitdiff
path: root/cli/js/write_text_file.ts
blob: ca7646c756223004f75fd098363b6b8cd6b9b7ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { writeFileSync, writeFile, WriteFileOptions } from "./write_file.ts";

export function writeTextFileSync(
  path: string | URL,
  data: string,
  options: WriteFileOptions = {}
): void {
  const encoder = new TextEncoder();
  return writeFileSync(path, encoder.encode(data), options);
}

export function writeTextFile(
  path: string | URL,
  data: string,
  options: WriteFileOptions = {}
): Promise<void> {
  const encoder = new TextEncoder();
  return writeFile(path, encoder.encode(data), options);
}