From 2aed322dd507a8568b6ee6f4897e9a8e3220f763 Mon Sep 17 00:00:00 2001 From: Aaron O'Mullan Date: Mon, 5 Apr 2021 18:40:24 +0200 Subject: refactor: convert ops to use serde_v8 (#10009) This commit rewrites most of the ops to use "serde_v8" instead of "json" serialization. --- op_crates/fetch/26_fetch.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'op_crates/fetch/26_fetch.js') diff --git a/op_crates/fetch/26_fetch.js b/op_crates/fetch/26_fetch.js index d4b2680ec..0fd825e16 100644 --- a/op_crates/fetch/26_fetch.js +++ b/op_crates/fetch/26_fetch.js @@ -884,29 +884,29 @@ if (body != null) { zeroCopy = new Uint8Array(body.buffer, body.byteOffset, body.byteLength); } - return core.jsonOpSync("op_fetch", args, ...(zeroCopy ? [zeroCopy] : [])); + return core.jsonOpSync("op_fetch", args, zeroCopy); } /** - * @param {{rid: number}} args + * @param {number} rid * @returns {Promise<{status: number, statusText: string, headers: Record, url: string, responseRid: number}>} */ - function opFetchSend(args) { - return core.jsonOpAsync("op_fetch_send", args); + function opFetchSend(rid) { + return core.jsonOpAsync("op_fetch_send", rid); } /** - * @param {{rid: number}} args + * @param {number} rid * @param {Uint8Array} body * @returns {Promise} */ - function opFetchRequestWrite(args, body) { + function opFetchRequestWrite(rid, body) { const zeroCopy = new Uint8Array( body.buffer, body.byteOffset, body.byteLength, ); - return core.jsonOpAsync("op_fetch_request_write", args, zeroCopy); + return core.jsonOpAsync("op_fetch_request_write", rid, zeroCopy); } const NULL_BODY_STATUS = [101, 204, 205, 304]; @@ -1276,7 +1276,7 @@ */ async write(chunk, controller) { try { - await opFetchRequestWrite({ rid: requestBodyRid }, chunk); + await opFetchRequestWrite(requestBodyRid, chunk); } catch (err) { controller.error(err); } @@ -1288,7 +1288,7 @@ body.pipeTo(writer); } - return await opFetchSend({ rid: requestRid }); + return await opFetchSend(requestRid); } /** @@ -1400,9 +1400,9 @@ async pull(controller) { try { const chunk = new Uint8Array(16 * 1024 + 256); - const { read } = await core.jsonOpAsync( + const read = await core.jsonOpAsync( "op_fetch_response_read", - { rid }, + rid, chunk, ); if (read != 0) { -- cgit v1.2.3