From 1b6f8318750d319d689f7eeef9e7e1f2e56b94a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sun, 8 Mar 2020 13:09:22 +0100 Subject: reorg: move JS ops implementations to cli/js/ops/, part 1 (#4264) Following JS ops were moved to separate files in cli/js/ops directory: - compiler - dispatch_json - dispatch_minimal - errors - fetch - fs_events - os - random - repl - resources - runtime_compiler - runtime - tty --- cli/js/ops/fetch.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 cli/js/ops/fetch.ts (limited to 'cli/js/ops/fetch.ts') diff --git a/cli/js/ops/fetch.ts b/cli/js/ops/fetch.ts new file mode 100644 index 000000000..c5c0cb883 --- /dev/null +++ b/cli/js/ops/fetch.ts @@ -0,0 +1,28 @@ +// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. + +import { sendAsync } from "./dispatch_json.ts"; + +interface FetchRequest { + url: string; + method: string | null; + headers: Array<[string, string]>; +} + +export interface FetchResponse { + bodyRid: number; + status: number; + statusText: string; + headers: Array<[string, string]>; +} + +export async function fetch( + args: FetchRequest, + body: ArrayBufferView | undefined +): Promise { + let zeroCopy = undefined; + if (body) { + zeroCopy = new Uint8Array(body.buffer, body.byteOffset, body.byteLength); + } + + return await sendAsync("op_fetch", args, zeroCopy); +} -- cgit v1.2.3