diff options
Diffstat (limited to 'js/copy_file.ts')
-rw-r--r-- | js/copy_file.ts | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/js/copy_file.ts b/js/copy_file.ts index 4c62ed1b0..b299a52bc 100644 --- a/js/copy_file.ts +++ b/js/copy_file.ts @@ -1,16 +1,6 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers"; - -function req( - from: string, - to: string -): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] { - const builder = flatbuffers.createBuilder(); - const from_ = builder.createString(from); - const to_ = builder.createString(to); - const inner = msg.CopyFile.createCopyFile(builder, from_, to_); - return [builder, msg.Any.CopyFile, inner]; -} +import { sendSync, sendAsync } from "./dispatch_json"; +import * as dispatch from "./dispatch"; /** Copies the contents of a file to another by name synchronously. * Creates a new file if target does not exists, and if target exists, @@ -22,7 +12,7 @@ function req( * Deno.copyFileSync("from.txt", "to.txt"); */ export function copyFileSync(from: string, to: string): void { - sendSync(...req(from, to)); + sendSync(dispatch.OP_COPY_FILE, { from, to }); } /** Copies the contents of a file to another by name. @@ -36,5 +26,5 @@ export function copyFileSync(from: string, to: string): void { * await Deno.copyFile("from.txt", "to.txt"); */ export async function copyFile(from: string, to: string): Promise<void> { - await sendAsync(...req(from, to)); + await sendAsync(dispatch.OP_COPY_FILE, { from, to }); } |