diff options
Diffstat (limited to 'js/remove.ts')
-rw-r--r-- | js/remove.ts | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/js/remove.ts b/js/remove.ts index 95294e6cf..f2a94f395 100644 --- a/js/remove.ts +++ b/js/remove.ts @@ -1,20 +1,11 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers"; +import { sendSync, sendAsync } from "./dispatch_json"; +import * as dispatch from "./dispatch"; export interface RemoveOption { recursive?: boolean; } -function req( - path: string, - options: RemoveOption -): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] { - const builder = flatbuffers.createBuilder(); - const path_ = builder.createString(path); - const inner = msg.Remove.createRemove(builder, path_, !!options.recursive); - return [builder, msg.Any.Remove, inner]; -} - /** Removes the named file or directory synchronously. Would throw * error if permission denied, not found, or directory not empty if `recursive` * set to false. @@ -23,7 +14,7 @@ function req( * Deno.removeSync("/path/to/dir/or/file", {recursive: false}); */ export function removeSync(path: string, options: RemoveOption = {}): void { - sendSync(...req(path, options)); + sendSync(dispatch.OP_REMOVE, { path, recursive: !!options.recursive }); } /** Removes the named file or directory. Would throw error if @@ -37,5 +28,5 @@ export async function remove( path: string, options: RemoveOption = {} ): Promise<void> { - await sendAsync(...req(path, options)); + await sendAsync(dispatch.OP_REMOVE, { path, recursive: !!options.recursive }); } |