From 2235dd795d3cc6c24ff1bdd1bbdcd110b4b0bdfc Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sat, 24 Aug 2019 13:20:48 -0700 Subject: Revert json ops (#2814) * Revert "port more ops to JSON (#2809)" This reverts commit 137f33733d365026903d40e7cde6e34ac6c36dcf. * Revert "port ops to JSON: compiler, errors, fetch, files (#2804)" This reverts commit 79f82cf10ed1dbf91346994250d7311a4d74377a. * Revert "Port rest of os ops to JSON (#2802)" This reverts commit 5b2baa5c990fbeae747e952c5dcd7a5369e950b1. --- js/get_random_values.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'js/get_random_values.ts') diff --git a/js/get_random_values.ts b/js/get_random_values.ts index 154e77f75..d5c0828c5 100644 --- a/js/get_random_values.ts +++ b/js/get_random_values.ts @@ -1,8 +1,15 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import * as dispatch from "./dispatch"; -import { sendSync } from "./dispatch_json"; +import { sendSync, msg, flatbuffers } from "./dispatch_flatbuffers"; import { assert } from "./util"; +function req( + typedArray: ArrayBufferView +): [flatbuffers.Builder, msg.Any, flatbuffers.Offset, ArrayBufferView] { + const builder = flatbuffers.createBuilder(); + const inner = msg.GetRandomValues.createGetRandomValues(builder); + return [builder, msg.Any.GetRandomValues, inner, typedArray]; +} + /** Synchronously collects cryptographically secure random values. The * underlying CSPRNG in use is Rust's `rand::rngs::ThreadRng`. * @@ -21,11 +28,6 @@ export function getRandomValues< >(typedArray: T): T { assert(typedArray !== null, "Input must not be null"); assert(typedArray.length <= 65536, "Input must not be longer than 65536"); - const ui8 = new Uint8Array( - typedArray.buffer, - typedArray.byteOffset, - typedArray.byteLength - ); - sendSync(dispatch.OP_GET_RANDOM_VALUES, {}, ui8); + sendSync(...req(typedArray as ArrayBufferView)); return typedArray; } -- cgit v1.2.3