diff options
Diffstat (limited to 'js/read_link.ts')
-rw-r--r-- | js/read_link.ts | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/js/read_link.ts b/js/read_link.ts index 8cac67dd1..fae1e64b6 100644 --- a/js/read_link.ts +++ b/js/read_link.ts @@ -1,30 +1,13 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { assert } from "./util"; -import { sendSync, sendAsync, msg, flatbuffers } from "./dispatch_flatbuffers"; - -function req(name: string): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] { - const builder = flatbuffers.createBuilder(); - const name_ = builder.createString(name); - const inner = msg.Readlink.createReadlink(builder, name_); - return [builder, msg.Any.Readlink, inner]; -} - -function res(baseRes: null | msg.Base): string { - assert(baseRes !== null); - assert(msg.Any.ReadlinkRes === baseRes!.innerType()); - const res = new msg.ReadlinkRes(); - assert(baseRes!.inner(res) !== null); - const path = res.path(); - assert(path !== null); - return path!; -} +import { sendSync, sendAsync } from "./dispatch_json"; +import * as dispatch from "./dispatch"; /** Returns the destination of the named symbolic link synchronously. * * const targetPath = Deno.readlinkSync("symlink/path"); */ export function readlinkSync(name: string): string { - return res(sendSync(...req(name))); + return sendSync(dispatch.OP_READ_LINK, { name }); } /** Returns the destination of the named symbolic link. @@ -32,5 +15,5 @@ export function readlinkSync(name: string): string { * const targetPath = await Deno.readlink("symlink/path"); */ export async function readlink(name: string): Promise<string> { - return res(await sendAsync(...req(name))); + return await sendAsync(dispatch.OP_READ_LINK, { name }); } |